class 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;
  }

}

class RequestSessionTest {

  private static EidasRequest eidasRequest;

  @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());
  }

}