Search in sources :

Example 11 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 12 with JobIdentifier

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

the class RestfulServiceTest method shouldTranslateLatestToRealStageCounter.

@Test
public void shouldTranslateLatestToRealStageCounter() throws Exception {
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    JobIdentifier jobIdentifier = restfulService.findJob(pipeline.getName(), pipeline.getLabel(), fixture.devStage, JobIdentifier.LATEST, 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)

Example 13 with JobIdentifier

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

the class RestfulServiceTest method shouldTranslateLatestToRealPipelineLabel.

@Test
public void shouldTranslateLatestToRealPipelineLabel() throws Exception {
    fixture.createdPipelineWithAllStagesPassed();
    Pipeline latestPipleine = fixture.createdPipelineWithAllStagesPassed();
    JobIdentifier jobIdentifier = restfulService.findJob(latestPipleine.getName(), JobIdentifier.LATEST, fixture.devStage, JobIdentifier.LATEST, PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
    assertThat(jobIdentifier.getPipelineLabel(), is(latestPipleine.getLabel()));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 14 with JobIdentifier

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

the class RestfulServiceTest method shouldReturnJobWithLabelWhenSpecifyPipelineLabel.

@Test
public void shouldReturnJobWithLabelWhenSpecifyPipelineLabel() throws Exception {
    configHelper.setPipelineLabelTemplate(fixture.pipelineName, "label-${COUNT}");
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    Stage stage = pipeline.getStages().byName(fixture.devStage);
    JobInstance job = stage.getJobInstances().first();
    JobIdentifier result = restfulService.findJob(pipeline.getName(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), job.getId());
    JobIdentifier expect = new JobIdentifier(pipeline, stage, job);
    assertThat(result, is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 15 with JobIdentifier

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

the class JobDetailPresentationModelJMockTest method setUp.

@Before
public void setUp() {
    stubJobInstance = context.mock(JobInstance.class);
    TrackingTool trackingTool = context.mock(TrackingTool.class);
    artifactService = context.mock(ArtifactsService.class);
    jobIdentifier = new JobIdentifier("pipeline", -1, "1", "stageName", "0", "build", 1L);
    context.checking(new Expectations() {

        {
            allowing(stubJobInstance).getName();
            will(returnValue("build"));
            allowing(stubJobInstance).getId();
            will(returnValue(1L));
            allowing(stubJobInstance).getIdentifier();
            will(returnValue(jobIdentifier));
        }
    });
    Stage stage = StageMother.custom("stageName", stubJobInstance);
    Pipeline pipeline = new Pipeline("pipeline", null, stage);
    pipeline.setId(1L);
    trackingTool = new TrackingTool();
    jobDetailPresenter = new JobDetailPresentationModel(stubJobInstance, null, null, pipeline, new Tabs(), trackingTool, artifactService, new Properties(), null);
    testFolder = TestFileUtil.createTempFolder("testFiles");
}
Also used : Expectations(org.jmock.Expectations) ArtifactsService(com.thoughtworks.go.server.service.ArtifactsService) JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) Tabs(com.thoughtworks.go.config.Tabs) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Properties(com.thoughtworks.go.domain.Properties) TrackingTool(com.thoughtworks.go.config.TrackingTool) Pipeline(com.thoughtworks.go.domain.Pipeline) Before(org.junit.Before)

Aggregations

JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)100 Test (org.junit.Test)74 JobInstance (com.thoughtworks.go.domain.JobInstance)17 Pipeline (com.thoughtworks.go.domain.Pipeline)16 File (java.io.File)15 DateTime (org.joda.time.DateTime)12 Stage (com.thoughtworks.go.domain.Stage)9 Before (org.junit.Before)8 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 LogFile (com.thoughtworks.go.server.domain.LogFile)5 IllegalArtifactLocationException (com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)4 Property (com.thoughtworks.go.domain.Property)3 Username (com.thoughtworks.go.server.domain.Username)3 IOException (java.io.IOException)3 Expectations (org.jmock.Expectations)3 RunIf (com.googlecode.junit.ext.RunIf)2 Tabs (com.thoughtworks.go.config.Tabs)2 Properties (com.thoughtworks.go.domain.Properties)2