Search in sources :

Example 1 with AuthenticationTypeRepository

use of com.synopsys.integration.alert.database.user.AuthenticationTypeRepository in project hub-alert by blackducksoftware.

the class DefaultAuthenticationTypeAccessorTest method getAuthenticationTypeTest.

@Test
public void getAuthenticationTypeTest() {
    AuthenticationTypeRepository authenticationTypeRepository = Mockito.mock(AuthenticationTypeRepository.class);
    DefaultAuthenticationTypeAccessor authenticationTypeAccessor = new DefaultAuthenticationTypeAccessor(authenticationTypeRepository);
    assertEquals(AuthenticationType.DATABASE, authenticationTypeAccessor.getAuthenticationType(1L).get());
    assertEquals(AuthenticationType.LDAP, authenticationTypeAccessor.getAuthenticationType(2L).get());
    assertEquals(AuthenticationType.SAML, authenticationTypeAccessor.getAuthenticationType(3L).get());
    assertFalse(authenticationTypeAccessor.getAuthenticationType(5L).isPresent());
}
Also used : AuthenticationTypeRepository(com.synopsys.integration.alert.database.user.AuthenticationTypeRepository) Test(org.junit.jupiter.api.Test)

Example 2 with AuthenticationTypeRepository

use of com.synopsys.integration.alert.database.user.AuthenticationTypeRepository in project hub-alert by blackducksoftware.

the class DefaultAuthenticationTypeAccessorTest method getAuthenticationTypeDetailsNullTest.

@Test
public void getAuthenticationTypeDetailsNullTest() {
    AuthenticationTypeRepository authenticationTypeRepository = Mockito.mock(AuthenticationTypeRepository.class);
    DefaultAuthenticationTypeAccessor authenticationTypeAccessor = new DefaultAuthenticationTypeAccessor(authenticationTypeRepository);
    Mockito.when(authenticationTypeRepository.findById(Mockito.any())).thenReturn(Optional.empty());
    Optional<AuthenticationTypeDetails> testAuthenticationTypeDetails = authenticationTypeAccessor.getAuthenticationTypeDetails(AuthenticationType.DATABASE);
    assertFalse(testAuthenticationTypeDetails.isPresent());
}
Also used : AuthenticationTypeRepository(com.synopsys.integration.alert.database.user.AuthenticationTypeRepository) AuthenticationTypeDetails(com.synopsys.integration.alert.common.persistence.model.AuthenticationTypeDetails) Test(org.junit.jupiter.api.Test)

Example 3 with AuthenticationTypeRepository

use of com.synopsys.integration.alert.database.user.AuthenticationTypeRepository in project hub-alert by blackducksoftware.

the class DefaultAuthenticationTypeAccessorTest method getAuthenticationTypeDetailsTest.

@Test
public void getAuthenticationTypeDetailsTest() {
    AuthenticationTypeRepository authenticationTypeRepository = Mockito.mock(AuthenticationTypeRepository.class);
    DefaultAuthenticationTypeAccessor authenticationTypeAccessor = new DefaultAuthenticationTypeAccessor(authenticationTypeRepository);
    AuthenticationTypeEntity authenticationTypeEntity = new AuthenticationTypeEntity("name-test");
    Mockito.when(authenticationTypeRepository.findById(Mockito.any())).thenReturn(Optional.of(authenticationTypeEntity));
    Optional<AuthenticationTypeDetails> testAuthenticationTypeDetails = authenticationTypeAccessor.getAuthenticationTypeDetails(AuthenticationType.DATABASE);
    assertTrue(testAuthenticationTypeDetails.isPresent());
    AuthenticationTypeDetails authenticationTypeDetails = testAuthenticationTypeDetails.get();
    assertEquals(authenticationTypeEntity.getName(), authenticationTypeDetails.getName());
    assertEquals(authenticationTypeEntity.getId(), authenticationTypeDetails.getId());
}
Also used : AuthenticationTypeRepository(com.synopsys.integration.alert.database.user.AuthenticationTypeRepository) AuthenticationTypeEntity(com.synopsys.integration.alert.database.user.AuthenticationTypeEntity) AuthenticationTypeDetails(com.synopsys.integration.alert.common.persistence.model.AuthenticationTypeDetails) Test(org.junit.jupiter.api.Test)

Aggregations

AuthenticationTypeRepository (com.synopsys.integration.alert.database.user.AuthenticationTypeRepository)3 Test (org.junit.jupiter.api.Test)3 AuthenticationTypeDetails (com.synopsys.integration.alert.common.persistence.model.AuthenticationTypeDetails)2 AuthenticationTypeEntity (com.synopsys.integration.alert.database.user.AuthenticationTypeEntity)1