Advertisement
Guest User

Untitled

a guest
May 29th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.91 KB | None | 0 0
  1.  @Test
  2.     public void getAFEligibilitySuccessTest() {
  3.         expectationBuilder.expectAFEligibility(VALID_PERSON_ID, VALID_CAMPAIGN_ID);
  4.         AFEligibilityDTO afEligibility = hccnBackendService.getAFEligibility(VALID_PERSON_ID, VALID_CAMPAIGN_ID);
  5.         assertEquals(EligibilityStatus.A1E1, afEligibility.getEligibilityStatus());
  6.     }
  7.  
  8.     ExpectationBuilder.java
  9.  
  10.     expectAFEligibility(Long validPersonId, Long validCampaignId) {
  11.         BasicResponse<String> response = new BasicResponse<>();
  12.         if (validPersonId.equals(VALID_PERSON_ID) && validCampaignId.equals(VALID_CAMPAIGN_ID)) {
  13.             response.setCode(ResponseStatus.OK.getCode());
  14.             response.setValue(EligibilityStatus.A1E1.toString());
  15.         } else {
  16.             response.setCode(ResponseStatus.DATA_ERROR.getCode());
  17.             response.setMessage("Failed to get AF Eligibility");
  18.         }
  19.         MultiValueMap<String, String> params = new LinkedMultiValueMap<>(2);
  20.         params.add(PARAM_PERSON_ID, validPersonId.toString());
  21.         params.add(PARAM_CAMPAIGN_ID, validCampaignId.toString());
  22.         UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUri(URI.create(connectionConfiguration.getHccnBackendAddress() + GlobalVariables.URL_APPLICATION_FORM_GET_AFE_ELIGIBILITY)).queryParams(params);
  23.         mockRestServiceServer.expect(requestTo(uriComponentsBuilder.toUriString()))
  24.                 .andExpect(method(HttpMethod.GET))
  25.                 .andRespond(withSuccess(asJsonString(response), APPLICATION_JSON_UTF8));
  26.     }
  27.  
  28.     HccnBackendServiceImpl.java
  29.  
  30.      @Override
  31.     public AFEligibilityDTO getAFEligibility(Long personId, Long campaignId) {
  32.         LOG.debug("HCCN Backend API: " + URL_APPLICATION_FORM_GET_AFE_ELIGIBILITY);
  33.         MultiValueMap<String, Object> httpParameters = new LinkedMultiValueMap<>(2);
  34.         httpParameters.add(PARAM_PERSON_ID, personId);
  35.         httpParameters.add(PARAM_CAMPAIGN_ID, campaignId);
  36.  
  37.         JavaType javaType = createBasicResponseJavaType();
  38.         String afEligibilityCode = (String) callExchangeAndReturnBodyValue(
  39.                 getDefaultGetMethodHeaders(),
  40.                 httpParameters,
  41.                 connectionConfiguration.getHccnBackendAddress() + URL_APPLICATION_FORM_GET_AFE_ELIGIBILITY,
  42.                 javaType,
  43.                 HttpMethod.GET);
  44.  
  45.         LOG.debug("HCCN Backend API {} returned value: {}" + URL_APPLICATION_FORM_GET_AFE_ELIGIBILITY, afEligibilityCode);
  46.         return new AFEligibilityDTO(EligibilityStatus.valueOf(afEligibilityCode));
  47.     }
  48.  
  49.  
  50.      AFEligibilityDTO getAFEligibility(Long personId, Long campaignId);
  51.  
  52.       @Override
  53.     public AFEligibilityDTO getAFEligibility(Long personId, Long campaignId) {
  54.         LOG.debug("API: getAFEligibility called with personId: " + personId
  55.                 + "and campaignId: " + campaignId);
  56.         return hccnBackendService.getAFEligibility(personId, campaignId);
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement