PaullEndpoint { PaullSoapToken getToken(String sessionID) { if (sessionID != null) { try { String token = externalRestService.getPaullConnection(sessionID).get("token").asText(); Claims tokenClaim = Jwts.parser().setSigningKey(SECRET).parseClaimsJws(token).getBody(); if (tokenClaim.getExpiration().before(new Date())) { return null; } String tokenParsed = tokenClaim.getSubject(); ObjectMapper objectMapper = new ObjectMapper(); return objectMapper.readValue(tokenParsed, PaullSoapToken.class); } catch (IOException e) { LOGGER.error(e.getMessage()); return null; } } return null; } PaullEndpoint(PesAllerService pesAllerService, LocalAuthorityService localAuthorityService,
            ExternalRestService externalRestService, PesRetourService pesRetourService, SesileService sesileService); @PayloadRoot(namespace = NAMESPACE_URI, localPart = "depotPESAllerRequest") @ResponsePayload DepotPESAllerResponse depotPESAller(@RequestPayload DepotPESAllerRequest depotPesAller); @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getDetailsPESAllerRequest") @ResponsePayload GetDetailsPESAllerResponse getDetailsPESAller(
            @RequestPayload GetDetailsPESAllerRequest getDetailsPESAllerRequest); @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getPESAllerRequest") @ResponsePayload GetPESAllerResponse getPESAller(@RequestPayload GetPESAllerRequest getPESAllerRequest); @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getPESRetourRequest") @ResponsePayload GetPESRetourResponse getPESRetour(@RequestPayload GetPESRetourRequest getPESRetourRequest);  }
@Test public void getDetailsPesAllerNoToken() { String detailsPesAllerRequest = "<getDetailsPESAllerRequest xmlns='http: "<sessionId>sessionid</sessionId>" + "<IdPesAller>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</IdPesAller>" + "</getDetailsPESAllerRequest>"; String detailsPesAllerResponseNoToken = "<ns2:getDetailsPESAllerResponse xmlns:ns2='http: "<ns2:statusCode>NOK</ns2:statusCode>" + "<ns2:retour><ns2:message>SESSION_INVALID_OR_EXPIRED</ns2:message></ns2:retour>" + "</ns2:getDetailsPESAllerResponse>"; given(paullEndpoint.getToken(any())) .willReturn(null); mockClient.sendRequest(withPayload(new StringSource(detailsPesAllerRequest))) .andExpect(payload(new StringSource(detailsPesAllerResponseNoToken))); }
@Test public void getDetailsPesAllerNoLocalAuthority() { String detailsPesAllerRequest = "<getDetailsPESAllerRequest xmlns='http: "<sessionId>sessionid</sessionId>" + "<IdPesAller>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</IdPesAller>" + "</getDetailsPESAllerRequest>"; String detailsPesAllerResponseNoLocalAuthority = "<ns2:getDetailsPESAllerResponse xmlns:ns2='http: "<ns2:statusCode>NOK</ns2:statusCode>" + "<ns2:retour><ns2:message>LOCALAUTHORITY_NOT_GRANTED</ns2:message></ns2:retour>" + "</ns2:getDetailsPESAllerResponse>"; given(paullEndpoint.getToken(any())) .willReturn(new PaullSoapToken()); given(localAuthorityService.localAuthorityGranted(any(), any())) .willReturn(false); mockClient.sendRequest(withPayload(new StringSource(detailsPesAllerRequest))) .andExpect(payload(new StringSource(detailsPesAllerResponseNoLocalAuthority))); }