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