Search in sources :

Example 66 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class PropertiesServiceTest method shouldLoadOriginalJobPropertiesForGivenJobIdentifier.

@Test
public void shouldLoadOriginalJobPropertiesForGivenJobIdentifier() {
    Properties props = new Properties(new Property("a", "1"), new Property("b", "2"));
    PropertyDao propertyDao = mock(PropertyDao.class);
    JobResolverService resolver = mock(JobResolverService.class);
    PropertiesService service = new PropertiesService(propertyDao, null, null, resolver);
    JobIdentifier oldId = new JobIdentifier("pipeline-name", 10, "label-10", "stage-name", "3", "job-name", 9l);
    when(propertyDao.list(6l)).thenReturn(props);
    when(resolver.actualJobIdentifier(oldId)).thenReturn(new JobIdentifier("pipeline-name", 7, "label-7", "stage-name", "1", "job-name", 6l));
    assertThat(service.getPropertiesForOriginalJob(oldId), is(props));
}
Also used : PropertyDao(com.thoughtworks.go.server.dao.PropertyDao) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property) Test(org.junit.Test)

Example 67 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class ArtifactsController method consoleout.

/* Other URLs */
@RequestMapping(value = "/**/consoleout.json", method = RequestMethod.GET)
public ModelAndView consoleout(@RequestParam("pipelineName") String pipelineName, @RequestParam("pipelineLabel") String counterOrLabel, @RequestParam("stageName") String stageName, @RequestParam("buildName") String buildName, @RequestParam(value = "stageCounter", required = false) String stageCounter, @RequestParam(value = "startLineNumber", required = false) Integer start) throws Exception {
    int startLine = start == null ? 0 : start;
    try {
        JobIdentifier identifier = restfulService.findJob(pipelineName, counterOrLabel, stageName, stageCounter, buildName);
        ConsoleOut consoleOut = consoleService.getConsoleOut(identifier, startLine);
        return new ModelAndView(new ConsoleOutView(consoleOut.calculateNextStart(), consoleOut.output()));
    } catch (FileNotFoundException e) {
        return new ModelAndView(new ConsoleOutView(0, ""));
    } catch (Exception e) {
        return buildNotFound(pipelineName, counterOrLabel, stageName, stageCounter, buildName);
    }
}
Also used : FileModelAndView(com.thoughtworks.go.server.web.FileModelAndView) ModelAndView(org.springframework.web.servlet.ModelAndView) FileNotFoundException(java.io.FileNotFoundException) ConsoleOut(com.thoughtworks.go.domain.ConsoleOut) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) HeaderConstraint(com.thoughtworks.go.server.security.HeaderConstraint) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) IllegalArtifactLocationException(com.thoughtworks.go.domain.exception.IllegalArtifactLocationException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 68 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class FetchTaskBuilder method createBuilder.

@Override
public Builder createBuilder(BuilderFactory builderFactory, FetchTask task, Pipeline pipeline, UpstreamPipelineResolver resolver) {
    JobIdentifier fetchFrom = resolveTargetJob(task, pipeline, resolver);
    Builder cancelBuilder = builderFactory.builderFor(task.cancelTask(), pipeline, resolver);
    return new FetchArtifactBuilder(task.getConditions(), cancelBuilder, task.describe(), fetchFrom, task.getSrc(), task.getDest(), getHandler(task, pipeline.getName()), getChecksumHandler(task, pipeline.getName()));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier)

Example 69 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class JobStatusCacheTest method jobInstance.

private JobInstance jobInstance(String jobConfigName) {
    JobInstance instance = JobInstanceMother.scheduled(jobConfigName);
    instance.setIdentifier(new JobIdentifier("cruise", 1, "1", "dev", "1", jobConfigName));
    return instance;
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier)

Example 70 with JobIdentifier

use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.

the class RestfulServiceTest method shouldTranslateEmtpyToLatestStageCounter.

@Test
public void shouldTranslateEmtpyToLatestStageCounter() throws Exception {
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    JobIdentifier jobIdentifier = restfulService.findJob(pipeline.getName(), pipeline.getLabel(), fixture.devStage, "", PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
    assertThat(Integer.valueOf(jobIdentifier.getStageCounter()), is(pipeline.getStages().byName(fixture.devStage).getCounter()));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)113 Test (org.junit.Test)85 File (java.io.File)16 JobInstance (com.thoughtworks.go.domain.JobInstance)15 Pipeline (com.thoughtworks.go.domain.Pipeline)13 DateTime (org.joda.time.DateTime)12 Before (org.junit.Before)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 Stage (com.thoughtworks.go.domain.Stage)6 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)5 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)5 AgentMetadata (com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata)5 IOException (java.io.IOException)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Property (com.thoughtworks.go.domain.Property)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 RunIf (com.googlecode.junit.ext.RunIf)2 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)2 HeaderConstraint (com.thoughtworks.go.server.security.HeaderConstraint)2