use of com.blackducksoftware.integration.hub.configuration.HubServerConfigValidator in project hub-alert by blackducksoftware.
the class GlobalHubConfigActionsTest method testValidConfig.
@Test
@Override
public void testValidConfig() throws Exception {
final GlobalHubConfigActions configActions = new GlobalHubConfigActions(null, null, null);
final String url = "https://www.google.com/";
final String user = "User";
final String password = "Password";
HubServerConfigBuilder serverConfigBuilder = new HubServerConfigBuilder();
serverConfigBuilder.setHubUrl(url);
serverConfigBuilder.setUsername(user);
serverConfigBuilder.setUsername(password);
try {
configActions.validateHubConfiguration(serverConfigBuilder);
fail();
} catch (final AlertFieldException e) {
assertNotNull(e);
assertEquals("There were issues with the configuration.", e.getMessage());
assertTrue(!e.getFieldErrors().isEmpty());
}
final HubServerConfigValidator validator = Mockito.mock(HubServerConfigValidator.class);
serverConfigBuilder = Mockito.spy(serverConfigBuilder);
Mockito.when(serverConfigBuilder.createValidator()).thenReturn(validator);
Mockito.when(validator.assertValid()).thenReturn(new ValidationResults());
try {
configActions.validateHubConfiguration(serverConfigBuilder);
} catch (final AlertFieldException e) {
fail();
}
}
Aggregations