use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class TestInformationTest method equalsFalseWhenStatusSameNameSameAndJobIdentifiersHaveDifferentNamesButSameLength.
@Test
public void equalsFalseWhenStatusSameNameSameAndJobIdentifiersHaveDifferentNamesButSameLength() {
TestInformation info1 = new TestInformation("test", TestStatus.Error);
info1.addJob(new JobIdentifier(null, 1, null, null, null, "job1"));
info1.addJob(new JobIdentifier(null, 2, null, null, null, "job"));
TestInformation info2 = new TestInformation("test", TestStatus.Error);
info2.addJob(new JobIdentifier(null, 3, null, null, null, "job1"));
info2.addJob(new JobIdentifier(null, 4, null, null, null, "job33"));
assertThat(info1, not(info2));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class TestSuiteTest method shouldRemoveTestsThatHaveSameContext.
@Test
public void shouldRemoveTestsThatHaveSameContext() {
testSuite.addTest("testB", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
testSuite.addTest("testA", TestStatus.Error, new JobIdentifier("", -1, "", "", "", "job-1"));
TestSuite testSuite1 = new TestSuite("another-suite");
testSuite1.addTest("testA", TestStatus.Error, new JobIdentifier("", 23, "", "", "", "job-1"));
testSuite.removeDuplicateTestEntries(testSuite1);
List<TestInformation> list = testSuite.tests();
assertThat(list.size(), is(1));
assertThat(list.get(0).getName(), is("testB"));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ArtifactsControllerTest method testConsoleOutShouldReturnErrorWhenJobHasBeenCompletedAndLogsNotFound.
@Test
public void testConsoleOutShouldReturnErrorWhenJobHasBeenCompletedAndLogsNotFound() throws Exception {
JobIdentifier jobIdentifier = new JobIdentifier("pipeline", 10, "label-10", "stage", "2", "build", 103l);
when(restfulService.findJob("pipeline", "10", "stage", "2", "build")).thenReturn(jobIdentifier);
when(jobInstanceDao.isJobCompleted(jobIdentifier)).thenReturn(true);
when(consoleService.doesLogExist(jobIdentifier)).thenReturn(false);
ModelAndView view = artifactsController.consoleout("pipeline", "10", "stage", "build", "2", 1L);
assertThat(view.getView().getContentType(), is(RESPONSE_CHARSET));
assertThat(view.getView(), is(instanceOf((ResponseCodeView.class))));
assertThat(((ResponseCodeView) view.getView()).getContent(), containsString("Console log for Build [pipeline/10/stage/2/build/103] is unavailable as it may have been purged by Go or deleted externally"));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ArtifactsControllerTest method shouldUpdateLastConsoleActivityOnConsoleLogPut.
@Test
public void shouldUpdateLastConsoleActivityOnConsoleLogPut() throws Exception {
String content = "Testing:";
request.setContent(content.getBytes());
JobIdentifier jobIdentifier = new JobIdentifier("pipeline", 10, "label-10", "stage", "2", "build", 103l);
when(restfulService.findJob("pipeline", "10", "stage", "2", "build", 103l)).thenReturn(jobIdentifier);
String path = "cruise-output/console.log";
File artifactFile = new File("junk");
when(consoleService.consoleLogFile(jobIdentifier)).thenReturn(artifactFile);
when(consoleService.updateConsoleLog(eq(artifactFile), any(InputStream.class))).thenReturn(true);
assertThat(((ResponseCodeView) artifactsController.putArtifact("pipeline", "10", "stage", "2", "build", 103l, path, "agent-id", request).getView()).getStatusCode(), is(HttpServletResponse.SC_OK));
verify(consoleActivityMonitor).consoleUpdatedFor(jobIdentifier);
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class RestfulService method findJob.
/**
* buildId should only be given when caller is absolutely sure about the job instance
* (makes sense in agent-uploading artifacts/properties scenario because agent won't run a job if its copied over(it only executes real jobs)) -JJ
*/
public JobIdentifier findJob(String pipelineName, String counterOrLabel, String stageName, String stageCounter, String buildName, Long buildId) {
JobConfigIdentifier jobConfig = goConfigService.translateToActualCase(new JobConfigIdentifier(pipelineName, stageName, buildName));
Pipeline pipeline = pipelineService.findPipelineByCounterOrLabel(jobConfig.getPipelineName(), counterOrLabel);
stageCounter = StringUtils.isEmpty(stageCounter) ? JobIdentifier.LATEST : stageCounter;
StageIdentifier stageIdentifier = translateStageCounter(pipeline.getIdentifier(), jobConfig.getStageName(), stageCounter);
JobIdentifier jobId;
if (buildId == null) {
jobId = jobResolverService.actualJobIdentifier(new JobIdentifier(stageIdentifier, jobConfig.getJobName()));
} else {
jobId = new JobIdentifier(stageIdentifier, jobConfig.getJobName(), buildId);
}
if (jobId == null) {
// fix for #5739
throw new JobNotFoundException(pipelineName, stageName, buildName);
}
return jobId;
}
Aggregations