### Question:
RpAuthnResponseGeneratorService { public AuthnResponseFromHubContainerDto generate(ResponseFromHubDto responseFromHub) { try{ return createSuccessResponse(responseFromHub); } catch (Exception e) { throw new UnableToGenerateSamlException("Unable to generate RP authn response", e, Level.ERROR); } } @Inject  RpAuthnResponseGeneratorService(OutboundResponseFromHubToResponseTransformerFactory outboundResponseFromHubToResponseTransformerFactory,
                                           @Named("HubEntityId") String hubEntityId,
                                           final AssignableEntityToEncryptForLocator entityToEncryptForLocator); AuthnResponseFromHubContainerDto generate(ResponseFromHubDto responseFromHub); AuthnResponseFromHubContainerDto generate(AuthnResponseFromCountryContainerDto responseFromHub);  }### Answer:
@Test public void generateShouldReturnAnAuthnResponseFromHubContainerDtoFromAuthnResponseFromCountryContainerDto() { OutboundAuthnResponseFromCountryContainerToStringFunction transformerMock = mock(OutboundAuthnResponseFromCountryContainerToStringFunction.class); when(outboundResponseFromHubToResponseTransformerFactory.getCountryTransformer()).thenReturn(transformerMock); when(transformerMock.apply(countryContainer)).thenReturn(TRANSFORMED_SAML_RESPONSE); AuthnResponseFromHubContainerDto hubContainer = generatorService.generate(countryContainer); assertThat(hubContainer.getSamlResponse()).isEqualTo(TRANSFORMED_SAML_RESPONSE); assertThat(hubContainer.getPostEndpoint()).isEqualTo(POST_ENDPOINT); assertThat(hubContainer.getRelayState().get()).isEqualTo(RELAY_STATE); assertThat(hubContainer.getResponseId()).isEqualTo(RESPONSE_ID); }
@Test(expected = UnableToGenerateSamlException.class) public void generateWithAuthnResponseFromCountryContainerDtoShouldThrowUnableToGenerateSamlExceptionIfExceptionIsCaught() { when(outboundResponseFromHubToResponseTransformerFactory.getCountryTransformer()).thenThrow(NullPointerException.class); generatorService.generate(countryContainer); }