use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method testWithProviderWarningsTest.
@Test
void testWithProviderWarningsTest() 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(createTestActionWithErrors()));
ValidationActionResponse validationActionResponse = defaultJobConfigActions.test(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful(), "Expected response to be successful");
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent(), "Expected response to have content");
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors(), "Expected response to have error content");
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method testTest.
@Test
void testTest() throws Exception {
JobConfigActions jobConfigActionsForTest = new JobConfigActions(mockedAuthorizationManager, mockedDescriptorAccessor, mockedConfigurationModelConfigurationAccessor, mockedJobAccessor, mockedFieldModelProcessor, mockedDescriptorProcessor, mockedConfigurationFieldModelConverter, mockedGlobalConfigExistsValidator, mockedPkixErrorResponseFactory, descriptorMap, (id, list) -> {
}, List.of(createChannelDistributionTestAction()), mockedJobModelExtractor);
fieldModel.setId("testID");
Mockito.when(mockedDescriptorProcessor.retrieveDescriptor(Mockito.any())).thenReturn(Optional.of(descriptor));
Mockito.when(mockedFieldModelProcessor.createCustomMessageFieldModel(Mockito.any())).thenReturn(fieldModel);
ValidationActionResponse validationActionResponse = jobConfigActionsForTest.test(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful(), "Validation response was not successful");
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent(), "Missing content");
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().orElseThrow(() -> new AlertRuntimeException("Missing validation response"));
assertFalse(validationResponseModel.hasErrors(), "Validation response had errors");
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method testBadRequestTest.
@Test
void testBadRequestTest() {
fieldModel.setId("testID");
ValidationActionResponse validationActionResponse = defaultJobConfigActions.test(jobFieldModel);
assertTrue(validationActionResponse.isError());
assertEquals(HttpStatus.BAD_REQUEST, 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 testExceptionTest.
@Test
void testExceptionTest() throws Exception {
Mockito.when(mockedDescriptorProcessor.retrieveDescriptor(Mockito.any())).thenReturn(Optional.of(descriptor));
Mockito.doThrow(new NullPointerException("RuntimeException 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 JiraServerInstallPluginAction method createBadRequestIntegrationException.
private ActionResponse<ValidationResponseModel> createBadRequestIntegrationException(IntegrationException error) {
logger.error("There was an issue connecting to Jira server", error);
ValidationResponseModel validationResponseModel = ValidationResponseModel.generalError("The following error occurred when connecting to Jira server: " + error.getMessage());
return new ActionResponse<>(HttpStatus.BAD_REQUEST, validationResponseModel);
}
Aggregations