RequestSession { private static String getReqProviderName(EidasRequest eidasRequest) { if (eidasRequest.getSectorType() == EidasRequestSectorType.PRIVATE) { if (eidasRequest.getRequesterId() != null) { return eidasRequest.getRequesterId(); } if (eidasRequest.getProviderName() != null) { return eidasRequest.getProviderName(); } } return null; } RequestSession(String relayState,
                 String reqId,
                 String reqDestination,
                 String reqProviderName,
                 String reqProviderEntityId);  RequestSession(String reqId,
                        String reqDestination,
                        String reqProviderName,
                        String reqProviderEntityId);  RequestSession(String relayState, EidasRequest eidasRequest);  RequestSession(EidasRequest eidasRequest); Optional<String> getRelayState();  }
@Test void whenRequestTypePrivateThenProviderNameIsRequesterId() { Mockito.when(eidasRequest.getSectorType()).thenReturn(EidasRequestSectorType.PRIVATE); Mockito.when(eidasRequest.getRequesterId()).thenReturn("private_SP"); RequestSession requestSession = new RequestSession("relayState", eidasRequest); Assertions.assertEquals("private_SP", requestSession.getReqProviderName()); }
@Test void whenRequestTypePrivateAndRequesterIdNullThenProviderNameIsProviderName() { Mockito.when(eidasRequest.getSectorType()).thenReturn(EidasRequestSectorType.PRIVATE); Mockito.when(eidasRequest.getRequesterId()).thenReturn(null); Mockito.when(eidasRequest.getProviderName()).thenReturn("providerName"); RequestSession requestSession = new RequestSession("relayState", eidasRequest); Assertions.assertEquals("providerName", requestSession.getReqProviderName()); }
@Test void whenRequesterTypePublicThenProviderNameNull() { Mockito.when(eidasRequest.getSectorType()).thenReturn(EidasRequestSectorType.PUBLIC); RequestSession requestSession = new RequestSession("relayState", eidasRequest); Assertions.assertNull(requestSession.getReqProviderName()); }