use of com.synopsys.integration.alert.common.action.ValidationActionResponse 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.action.ValidationActionResponse 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.action.ValidationActionResponse 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.action.ValidationActionResponse 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());
}
use of com.synopsys.integration.alert.common.action.ValidationActionResponse in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateTest.
@Test
public void validateTest() {
Descriptor descriptorWithValidator = createDescriptor(Optional::empty, () -> Optional.of(jobFieldModel -> Set.of()));
JobConfigActions jobConfigActionsForTest = createJobConfigActions(new DescriptorMap(List.of(descriptorKey), List.of(descriptorWithValidator)), List.of());
ValidationActionResponse validationActionResponse = jobConfigActionsForTest.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertFalse(validationResponseModel.hasErrors());
}
Aggregations