use of com.synopsys.integration.alert.common.rest.model.JobIdsRequestModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateJobsByIdForbiddenTest.
@Test
public void validateJobsByIdForbiddenTest() {
JobIdsRequestModel jobIdsRequestModel = new JobIdsRequestModel(List.of(jobId));
Mockito.when(mockedAuthorizationManager.anyReadPermission(Mockito.any())).thenReturn(false);
ActionResponse<List<JobFieldStatuses>> actionResponse = defaultJobConfigActions.validateJobsById(jobIdsRequestModel);
assertTrue(actionResponse.isError());
assertEquals(HttpStatus.FORBIDDEN, actionResponse.getHttpStatus());
assertFalse(actionResponse.hasContent());
}
use of com.synopsys.integration.alert.common.rest.model.JobIdsRequestModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateJobsByIdEmptyListTest.
@Test
public void validateJobsByIdEmptyListTest() {
JobIdsRequestModel jobIdsRequestModel = new JobIdsRequestModel(List.of());
Mockito.when(mockedAuthorizationManager.anyReadPermission(Mockito.any())).thenReturn(true);
ActionResponse<List<JobFieldStatuses>> actionResponse = defaultJobConfigActions.validateJobsById(jobIdsRequestModel);
assertTrue(actionResponse.isSuccessful());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertTrue(actionResponse.hasContent());
}
use of com.synopsys.integration.alert.common.rest.model.JobIdsRequestModel in project hub-alert by blackducksoftware.
the class JobConfigControllerTestIT method testGetValidationResultsForJobs.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testGetValidationResultsForJobs() throws Exception {
final String urlPath = REQUEST_URL + "/validateJobsById";
DistributionJobModel distributionJobModel = createAndSaveMockDistributionJob(-1L);
JobIdsRequestModel jobIdsRequestModel = new JobIdsRequestModel(List.of(distributionJobModel.getJobId()));
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf()).content(gson.toJson(jobIdsRequestModel)).contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.common.rest.model.JobIdsRequestModel in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateJobsByIdTest.
@Test
public void validateJobsByIdTest() throws Exception {
JobIdsRequestModel jobIdsRequestModel = new JobIdsRequestModel(List.of(jobId));
Mockito.when(mockedAuthorizationManager.anyReadPermission(Mockito.any())).thenReturn(true);
Mockito.when(mockedConfigurationFieldModelConverter.convertToFieldModel(Mockito.any())).thenReturn(fieldModel);
Mockito.when(mockedFieldModelProcessor.performAfterReadAction(Mockito.eq(fieldModel))).thenReturn(fieldModel);
ActionResponse<List<JobFieldStatuses>> actionResponse = defaultJobConfigActions.validateJobsById(jobIdsRequestModel);
assertTrue(actionResponse.isSuccessful());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertTrue(actionResponse.hasContent());
}
Aggregations