### Question:
CountrySingleSignOnServiceHelper { public URI getSingleSignOn(String entityId) { MetadataResolver metadataResolver = metadataResolverRepository.getMetadataResolver(entityId) .orElseThrow(() -> ApplicationException.createUnauditedException(ExceptionType.METADATA_PROVIDER_EXCEPTION, UUID.randomUUID(), new RuntimeException(format("no metadata resolver for EU Member State: {0}", entityId))) ); EntityDescriptor idpEntityDescriptor; try { CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(entityId)); idpEntityDescriptor = metadataResolver.resolveSingle(criteria); } catch (ResolverException e) { LOG.error(format("Exception when accessing metadata: {0}", e)); throw new RuntimeException(e); } if (idpEntityDescriptor != null) { final IDPSSODescriptor idpssoDescriptor = idpEntityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS); final List<SingleSignOnService> singleSignOnServices = idpssoDescriptor.getSingleSignOnServices(); if (singleSignOnServices.isEmpty()) { LOG.error(format("No singleSignOnServices present for IDP entityId: {0}", entityId)); } else { if (singleSignOnServices.size() > 1) { LOG.warn(format("More than one singleSignOnService present: {0} for {1}", singleSignOnServices.size(), entityId)); } return URI.create(singleSignOnServices.get(0).getLocation()); } } throw ApplicationException.createUnauditedException(ExceptionType.NOT_FOUND, UUID.randomUUID(), new RuntimeException(format("no entity descriptor for EU Member State: {0}", entityId))); } @Inject  CountrySingleSignOnServiceHelper(EidasMetadataResolverRepository metadataResolverRepository); URI getSingleSignOn(String entityId);  }### Answer:
@Test public void getSingleSignOn() throws Exception { SingleSignOnServiceBuilder singleSignOnServiceBuilder = new SingleSignOnServiceBuilder(); SingleSignOnService singleSignOnService = singleSignOnServiceBuilder.buildObject(); singleSignOnService.setLocation("http: IDPSSODescriptorBuilder idpssoDescriptorBuilder = new IDPSSODescriptorBuilder(); IDPSSODescriptor idpssoDescriptor = idpssoDescriptorBuilder.buildObject(); idpssoDescriptor.getSingleSignOnServices().add(singleSignOnService); idpssoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS); EntityDescriptorBuilder entityDescriptorBuilder = new EntityDescriptorBuilder(); EntityDescriptor entityDescriptor = entityDescriptorBuilder.buildObject(); entityDescriptor.setEntityID("an-entity-id"); entityDescriptor.getRoleDescriptors().add(idpssoDescriptor); EidasMetadataResolverRepository eidasMetadataResolverRepository = mock(EidasMetadataResolverRepository.class); MetadataResolver metadataResolver = mock(MetadataResolver.class); when(eidasMetadataResolverRepository.getMetadataResolver(any())).thenReturn(Optional.of(metadataResolver)); CountrySingleSignOnServiceHelper service = new CountrySingleSignOnServiceHelper(eidasMetadataResolverRepository); when(metadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(entityDescriptor.getEntityID())))).thenReturn(entityDescriptor); URI singleSignOnUri = service.getSingleSignOn(entityDescriptor.getEntityID()); assertThat(singleSignOnUri.toString()).isEqualTo(singleSignOnService.getLocation()); verify(metadataResolver).resolveSingle(any(CriteriaSet.class)); }