use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validateUsernameWithoutPasswordTest.
@Test
void validateUsernameWithoutPasswordTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel(ID, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, CREATED_AT, LAST_UPDATED, HOST, PORT, USERNAME, null, Boolean.FALSE, NON_PROXY_HOSTS);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(1, validationResponseModel.getErrors().size());
assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_PASSWORD_FIELD_NAME));
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validateHostWithoutPortTest.
@Test
void validateHostWithoutPortTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel(ID, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, CREATED_AT, LAST_UPDATED, HOST, null, USERNAME, PASSWORD, Boolean.TRUE, NON_PROXY_HOSTS);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(1, validationResponseModel.getErrors().size());
assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_PORT_FIELD_NAME));
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method testIntegrationExceptionTest.
@Test
void testIntegrationExceptionTest() throws Exception {
Mockito.when(mockedDescriptorProcessor.retrieveDescriptor(Mockito.any())).thenReturn(Optional.of(descriptor));
Mockito.doThrow(new AlertException("IntegrationException for Alert test")).when(mockedFieldModelProcessor).createCustomMessageFieldModel(Mockito.any());
ValidationActionResponse validationActionResponse = defaultJobConfigActions.test(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateBadRequestWithFieldStatusTest.
@Test
void validateBadRequestWithFieldStatusTest() {
AlertFieldStatus alertFieldStatus = AlertFieldStatus.error("fieldNameTest", "Alert Error Message");
Descriptor mockDescriptor = Mockito.mock(Descriptor.class);
Mockito.when(mockDescriptor.getDistributionValidator()).thenReturn(Optional.of(ignoredJobFieldModel -> Set.of(alertFieldStatus)));
DescriptorMap mockDescriptorMap = Mockito.mock(DescriptorMap.class);
Mockito.when(mockDescriptorMap.getDescriptorKey(Mockito.anyString())).thenReturn(Optional.of(descriptorKey));
Mockito.when(mockDescriptorMap.getDescriptor(descriptorKey)).thenReturn(Optional.of(mockDescriptor));
JobConfigActions testJobConfigActions = new JobConfigActions(mockedAuthorizationManager, null, null, mockedJobAccessor, null, null, null, null, null, mockDescriptorMap, null, List.of(), null);
ValidationActionResponse validationActionResponse = testJobConfigActions.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method testAlertFieldExceptionTest.
@Test
void testAlertFieldExceptionTest() throws Exception {
Mockito.when(mockedDescriptorProcessor.retrieveDescriptor(Mockito.any())).thenReturn(Optional.of(descriptor));
AlertFieldStatus alertFieldStatus = AlertFieldStatus.error("fieldNameTest", "Alert Error Message");
Mockito.doThrow(new AlertFieldException("AlertFieldException for Alert test", List.of(alertFieldStatus))).when(mockedFieldModelProcessor).createCustomMessageFieldModel(Mockito.any());
ValidationActionResponse validationActionResponse = defaultJobConfigActions.test(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
Aggregations