use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyPasswordIsMissingAndNotSaved.
@Test
void verifyPasswordIsMissingAndNotSaved() {
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(ID, NAME, URL, USER_NAME, null);
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(1, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals("password", status.getFieldName(), "Validation reported an error for an unexpected field.");
}
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method oldValidateTest.
@Test
public void oldValidateTest() {
ValidationActionResponse validationActionResponse = defaultJobConfigActions.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method oldValidateBadRequestTest.
@Test
public void oldValidateBadRequestTest() {
Mockito.when(mockedJobAccessor.getJobByName(Mockito.anyString())).thenReturn(Optional.of(distributionJobModel));
ValidationActionResponse validationActionResponse = defaultJobConfigActions.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors(), "Expected validation response to have errors");
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateBadRequestTest.
@Test
public void validateBadRequestTest() {
Descriptor descriptorWithValidator = createDescriptor(Optional::empty, () -> Optional.of(jobFieldModel -> Set.of()));
JobConfigActions jobConfigActionsForTest = createJobConfigActions(new DescriptorMap(List.of(descriptorKey), List.of(descriptorWithValidator)), List.of());
Mockito.when(mockedJobAccessor.getJobByName(Mockito.anyString())).thenReturn(Optional.of(distributionJobModel));
ValidationActionResponse validationActionResponse = jobConfigActionsForTest.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors(), "Expected validation response to have errors");
}
use of com.synopsys.integration.alert.common.rest.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method testIntegrationRestExceptionTest.
@Test
public void testIntegrationRestExceptionTest() throws Exception {
fieldModel.setId("testID");
Mockito.when(mockedDescriptorProcessor.retrieveDescriptor(Mockito.any())).thenReturn(Optional.of(descriptor));
Mockito.when(mockedFieldModelProcessor.createCustomMessageFieldModel(Mockito.any())).thenReturn(fieldModel);
Mockito.when(mockedDescriptorProcessor.retrieveTestAction(Mockito.any())).thenReturn(Optional.of(createTestActionWithErrors()));
Mockito.when(mockedConfigurationFieldModelConverter.convertToConfigurationFieldModelMap(Mockito.any())).thenReturn(Map.of(ChannelDescriptor.KEY_PROVIDER_TYPE, configurationFieldModel));
Mockito.when(mockedDescriptorProcessor.retrieveTestAction(Mockito.any(), Mockito.any())).thenReturn(Optional.of(createTestActionWithIntegrationRestException()));
ValidationActionResponse validationActionResponse = defaultJobConfigActions.test(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful(), "Expected response to be successful");
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
Aggregations