Search in sources :

Example 36 with JobIdentifier

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

the class ArtifactsServiceTest method shouldProvideArtifactRootForAJobOnWindows.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { EnhancedOSChecker.WINDOWS })
public void shouldProvideArtifactRootForAJobOnWindows() throws Exception {
    assumeArtifactsRoot(fakeRoot);
    ArtifactsService artifactsService = new ArtifactsService(resolverService, stageService, artifactsDirHolder, zipUtil, systemService);
    artifactsService.initialize();
    JobIdentifier oldId = new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null);
    when(resolverService.actualJobIdentifier(oldId)).thenReturn(new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null));
    String artifactRoot = artifactsService.findArtifactRoot(oldId);
    assertThat(artifactRoot, is("pipelines\\cruise\\1\\dev\\2\\linux-firefox"));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 37 with JobIdentifier

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

the class ArtifactsServiceTest method shouldUsePipelineLabelAsFolderNameIfNoCounter.

@Test
public void shouldUsePipelineLabelAsFolderNameIfNoCounter() throws IllegalArtifactLocationException, IOException {
    File artifactsRoot = temporaryFolder.newFolder();
    assumeArtifactsRoot(artifactsRoot);
    willCleanUp(artifactsRoot);
    ArtifactsService artifactsService = new ArtifactsService(resolverService, stageService, artifactsDirHolder, zipUtil, systemService);
    artifactsService.initialize();
    File artifact = artifactsService.findArtifact(new JobIdentifier("cruise", -2, "1.1", "dev", "2", "linux-firefox", null), "pkg.zip");
    assertThat(artifact, is(new File(artifactsRoot, "pipelines/cruise/1.1/dev/2/linux-firefox/pkg.zip")));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) File(java.io.File) Test(org.junit.Test)

Example 38 with JobIdentifier

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

the class JobResolverServiceTest method shouldLoadActualIdentifierForGivenJobIdentifier.

@Test
public void shouldLoadActualIdentifierForGivenJobIdentifier() {
    JobIdentifier oldId = new JobIdentifier("pipeline-name", 10, "label-10", "stage-name", "2", "build-name", 17l);
    JobIdentifier idFoundByDao = new JobIdentifier("pipeline-name", 5, "label-5", "stage-name", "1", "build-name", 12l);
    when(jobDao.findOriginalJobIdentifier(oldId.getStageIdentifier(), "build-name")).thenReturn(idFoundByDao);
    JobIdentifier actualId = jobResolverService.actualJobIdentifier(oldId);
    assertThat(actualId, is(idFoundByDao));
}
Also used : JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.Test)

Example 39 with JobIdentifier

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

the class JobStatusJsonPresentationModelTest method shouldEncodeBuildLocator.

@Test
public void shouldEncodeBuildLocator() throws Exception {
    JobInstance instance = JobInstanceMother.completed("job-%", JobResult.Passed);
    instance.setIdentifier(new JobIdentifier("cruise-%", 1, "label-1", "dev-%", "1", "job-%", -1L));
    JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance);
    Map json = presenter.toJsonHash();
    assertThat(JsonUtils.from(json).getString("buildLocator"), is("cruise-%25/1/dev-%25/1/job-%25"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Map(java.util.Map) Test(org.junit.Test)

Example 40 with JobIdentifier

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

the class JobStatusJsonPresentationModelTest method shouldIncludeBuildLocatorForDisplay.

@Test
public void shouldIncludeBuildLocatorForDisplay() throws Exception {
    JobInstance instance = JobInstanceMother.completed("job-%", JobResult.Passed);
    instance.setIdentifier(new JobIdentifier("cruise-%", 1, "label-1", "dev-%", "1", "job-%", -1L));
    JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance);
    Map json = presenter.toJsonHash();
    assertThat(JsonUtils.from(json).getString("buildLocatorForDisplay"), is("cruise-%/label-1/dev-%/1/job-%"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Map(java.util.Map) 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