use of com.mercedesbenz.sechub.domain.schedule.ScheduleJobStatus in project sechub by mercedes-benz.
the class SchedulerRestControllerRestDocTest method restDoc_userChecksJobState.
@Test
@UseCaseRestDoc(useCase = UseCaseUserChecksJobStatus.class)
public void restDoc_userChecksJobState() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildGetJobStatusUrl(PROJECT_ID.pathElement(), JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserChecksJobStatus.class;
ScheduleSecHubJob job = new ScheduleSecHubJob() {
public UUID getUUID() {
return randomUUID;
}
};
job.setExecutionResult(ExecutionResult.OK);
job.setStarted(LocalDateTime.now().minusMinutes(15));
job.setEnded(LocalDateTime.now());
job.setExecutionState(ExecutionState.ENDED);
job.setOwner("CREATOR1");
job.setTrafficLight(TrafficLight.GREEN);
ScheduleJobStatus status = new ScheduleJobStatus(job);
when(mockedScheduleJobStatusService.getJobStatus(PROJECT1_ID, randomUUID)).thenReturn(status);
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint, PROJECT1_ID, randomUUID).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().json("{jobUUID:" + randomUUID.toString() + ", result:OK, state:ENDED, trafficLight:GREEN}")).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.JOB_STATUS.getSchema()).and().document(pathParameters(parameterWithName("projectId").description("The id of the project where sechub job was started for"), parameterWithName("jobUUID").description(DESCRIPTION_JOB_UUID)), responseFields(fieldWithPath(ScheduleJobStatus.PROPERTY_JOBUUID).description("The job uuid"), fieldWithPath(ScheduleJobStatus.PROPERTY_CREATED).description("Creation timestamp of job"), fieldWithPath(ScheduleJobStatus.PROPERTY_STARTED).description("Start timestamp of job execution"), fieldWithPath(ScheduleJobStatus.PROPERTY_ENDED).description("End timestamp of job execution"), fieldWithPath(ScheduleJobStatus.PROPERTY_OWNER).description("Owner / initiator of job"), fieldWithPath(ScheduleJobStatus.PROPERTY_STATE).description("State of job"), fieldWithPath(ScheduleJobStatus.PROPERTY_RESULT).description("Result of job"), fieldWithPath(ScheduleJobStatus.PROPERTY_TRAFFICLIGHT).description("Trafficlight of job - but only available when job has been done. Possible states are " + StringUtils.arrayToDelimitedString(TrafficLight.values(), ", ")))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.schedule.ScheduleJobStatus in project sechub by mercedes-benz.
the class SchedulerRestControllerRestDocTest method restDoc_userUploadsBinaries.
@Test
@UseCaseRestDoc(useCase = UseCaseUserUploadsBinaries.class)
public void restDoc_userUploadsBinaries() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildUploadBinariesUrl(PROJECT_ID.pathElement(), JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserUploadsBinaries.class;
ScheduleSecHubJob job = new ScheduleSecHubJob() {
public UUID getUUID() {
return randomUUID;
}
};
job.setExecutionResult(ExecutionResult.OK);
job.setStarted(LocalDateTime.now().minusMinutes(15));
job.setEnded(LocalDateTime.now());
job.setExecutionState(ExecutionState.INITIALIZING);
job.setOwner("CREATOR1");
job.setTrafficLight(TrafficLight.GREEN);
ScheduleJobStatus status = new ScheduleJobStatus(job);
when(mockedScheduleJobStatusService.getJobStatus(PROJECT1_ID, randomUUID)).thenReturn(status);
InputStream inputStreamTo = RestDocTestFileSupport.getTestfileSupport().getInputStreamTo("upload/tarfile_contains_only_test1.txt.tar");
MockMultipartFile file1 = new MockMultipartFile("file", inputStreamTo);
/* execute + test @formatter:off */
this.mockMvc.perform(multipart(apiEndpoint, PROJECT1_ID, randomUUID).file(file1).param("checkSum", "mychecksum")).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).and().document(pathParameters(parameterWithName("projectId").description("The id of the project for which the binaries are uploaded for"), parameterWithName("jobUUID").description(DESCRIPTION_JOB_UUID)), requestParameters(parameterWithName("checkSum").description("A sha256 checksum for file upload validation")), // See: https://github.com/ePages-de/restdocs-api-spec/issues/105
requestParts(partWithName("file").description("The binaries as tarfile to upload"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.schedule.ScheduleJobStatus in project sechub by mercedes-benz.
the class SchedulerRestControllerRestDocTest method restDoc_userUploadsSourceCode.
@Test
@UseCaseRestDoc(useCase = UseCaseUserUploadsSourceCode.class)
public void restDoc_userUploadsSourceCode() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildUploadSourceCodeUrl(PROJECT_ID.pathElement(), JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserUploadsSourceCode.class;
ScheduleSecHubJob job = new ScheduleSecHubJob() {
public UUID getUUID() {
return randomUUID;
}
};
job.setExecutionResult(ExecutionResult.OK);
job.setStarted(LocalDateTime.now().minusMinutes(15));
job.setEnded(LocalDateTime.now());
job.setExecutionState(ExecutionState.INITIALIZING);
job.setOwner("CREATOR1");
job.setTrafficLight(TrafficLight.GREEN);
ScheduleJobStatus status = new ScheduleJobStatus(job);
when(mockedScheduleJobStatusService.getJobStatus(PROJECT1_ID, randomUUID)).thenReturn(status);
InputStream inputStreamTo = RestDocTestFileSupport.getTestfileSupport().getInputStreamTo("upload/zipfile_contains_only_test1.txt.zip");
MockMultipartFile file1 = new MockMultipartFile("file", inputStreamTo);
/* execute + test @formatter:off */
this.mockMvc.perform(multipart(apiEndpoint, PROJECT1_ID, randomUUID).file(file1).param("checkSum", "mychecksum")).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).and().document(pathParameters(parameterWithName("projectId").description("The id of the project where sourcecode shall be uploaded for"), parameterWithName("jobUUID").description(DESCRIPTION_JOB_UUID)), requestParameters(parameterWithName("checkSum").description("A sha256 checksum for file upload validation")), // See: https://github.com/ePages-de/restdocs-api-spec/issues/105
requestParts(partWithName("file").description("The sourcecode as zipfile to upload"))));
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.schedule.ScheduleJobStatus in project sechub by mercedes-benz.
the class SchedulerRestControllerRestDocTest method restDoc_userApprovesJob.
@Test
@UseCaseRestDoc(useCase = UseCaseUserApprovesJob.class)
public void restDoc_userApprovesJob() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildApproveJobUrl(PROJECT_ID.pathElement(), JOB_UUID.pathElement());
Class<? extends Annotation> useCase = UseCaseUserApprovesJob.class;
ScheduleSecHubJob job = new ScheduleSecHubJob() {
public UUID getUUID() {
return randomUUID;
}
};
job.setExecutionResult(ExecutionResult.OK);
job.setStarted(LocalDateTime.now().minusMinutes(15));
job.setEnded(LocalDateTime.now());
job.setExecutionState(ExecutionState.ENDED);
job.setOwner("CREATOR1");
job.setTrafficLight(TrafficLight.GREEN);
ScheduleJobStatus status = new ScheduleJobStatus(job);
when(mockedScheduleJobStatusService.getJobStatus(PROJECT1_ID, randomUUID)).thenReturn(status);
/* execute + test @formatter:off */
this.mockMvc.perform(put(apiEndpoint, PROJECT1_ID, randomUUID).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).and().document(pathParameters(parameterWithName("projectId").description("The id of the project where sechub job shall be approved"), parameterWithName("jobUUID").description(DESCRIPTION_JOB_UUID))));
/* @formatter:on */
}
Aggregations