Search in sources :

Example 31 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class PackageMaterialTest method shouldPopulateEnvironmentContext.

@Test
public void shouldPopulateEnvironmentContext() {
    PackageMaterial material = new PackageMaterial();
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "tw-dev", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1"), ConfigurationPropertyMother.create("repo-secure", true, "value")));
    material.setPackageDefinition(PackageDefinitionMother.create("p-id", "go-agent", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2"), ConfigurationPropertyMother.create("pkg-secure", true, "value")), repository));
    material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
    Modifications modifications = new Modifications(new Modification(null, null, null, new Date(), "revision-123"));
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
    assertThat(environmentVariableContext.getProperty("GO_REPO_TW_DEV_GO_AGENT_K1"), is("v1"));
    assertThat(environmentVariableContext.getProperty("GO_REPO_TW_DEV_GO_AGENT_REPO_SECURE"), is("value"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_REPO_TW_DEV_GO_AGENT_REPO_SECURE"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
    assertThat(environmentVariableContext.getProperty("GO_PACKAGE_TW_DEV_GO_AGENT_K2"), is("v2"));
    assertThat(environmentVariableContext.getProperty("GO_PACKAGE_TW_DEV_GO_AGENT_PKG_SECURE"), is("value"));
    assertThat(environmentVariableContext.getPropertyForDisplay("GO_PACKAGE_TW_DEV_GO_AGENT_PKG_SECURE"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
    assertThat(environmentVariableContext.getProperty("GO_PACKAGE_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 32 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class DependencyMaterialTest method shouldParseMaterialRevisionWithPipelineLabel.

@Test
public void shouldParseMaterialRevisionWithPipelineLabel() {
    ArrayList<Modification> mods = new ArrayList<>();
    Modification mod = new Modification(new Date(), "pipelineName/123/stageName/2", "pipeline-label-123", null);
    mods.add(mod);
    DependencyMaterialRevision revision = (DependencyMaterialRevision) new Modifications(mods).latestRevision(dependencyMaterial);
    assertThat(revision.getRevision(), is("pipelineName/123/stageName/2"));
    assertThat(revision.getPipelineLabel(), is("pipeline-label-123"));
    assertThat(revision.getPipelineCounter(), is(123));
    assertThat(revision.getPipelineName(), is("pipelineName"));
    assertThat(revision.getStageName(), is("stageName"));
    assertThat(revision.getStageCounter(), is(2));
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 33 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class GitMaterialShallowCloneTest method updateToANewRevisionShouldNotResultInUnshallowing.

@Test
public void updateToANewRevisionShouldNotResultInUnshallowing() throws IOException {
    GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
    material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(REVISION_4, REVISION_4, 1), context());
    assertThat(localRepoFor(material).isShallow(), is(true));
    List<Modification> modifications = repo.addFileAndPush("newfile", "add new file");
    StringRevision newRevision = new StringRevision(modifications.get(0).getRevision());
    material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(newRevision, newRevision, 1), context());
    assertThat(new File(workingDir, "newfile").exists(), is(true));
    assertThat(localRepoFor(material).isShallow(), is(true));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.Test)

Example 34 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class P4OutputParserTest method shouldRetrieveModificationFromDescription.

@Test
public void shouldRetrieveModificationFromDescription() throws Exception {
    String output = "Change 2 by cce123user@connect4_10.18.2.31 on 2008/08/19 15:04:43\n" + "\n" + "\tAdded config file\n" + "\n" + "Affected files ...\n" + "\n" + "... //depot/cruise-config.xml#1 add\n" + "... //depot/README.txt#2 edit\n" + "... //depot/cruise-output/log.xml#1 delete\n" + "";
    Modification mod = parser.modificationFromDescription(output, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    assertThat(mod.getRevision(), is("2"));
    assertThat(mod.getUserName(), is("cce123user@connect4_10.18.2.31"));
    assertThat(mod.getModifiedTime(), is(DESCRIPTION_FORMAT.parse("2008/08/19 15:04:43")));
    assertThat(mod.getComment(), is("Added config file"));
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(3));
    assertThat(files.get(0).getAction(), is(ModifiedAction.added));
    assertThat(files.get(0).getFileName(), is("cruise-config.xml"));
    assertThat(files.get(1).getAction(), is(ModifiedAction.modified));
    assertThat(files.get(2).getAction(), is(ModifiedAction.deleted));
    assertThat(files.get(2).getFileName(), is("cruise-output/log.xml"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 35 with Modification

use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.

the class P4OutputParserTest method shouldParseCorrectlyWhenCommentIsEmpty.

@Test
public void shouldParseCorrectlyWhenCommentIsEmpty() throws P4OutputParseException {
    String description = "Change 102 by godev@blrstdcrspair03 on 2013/06/04 12:00:35\n" + "\n" + "\n" + "Affected files ...\n" + "\n" + "... //another_depot/1.txt#6 edit";
    Modification modification = parser.modificationFromDescription(description, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    assertThat(modification.getComment(), is(""));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

Modification (com.thoughtworks.go.domain.materials.Modification)246 Test (org.junit.Test)176 Date (java.util.Date)76 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)65 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)40 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)38 ArrayList (java.util.ArrayList)35 File (java.io.File)25 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)21 Modifications (com.thoughtworks.go.domain.materials.Modifications)21 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Material (com.thoughtworks.go.domain.materials.Material)20 Username (com.thoughtworks.go.server.domain.Username)17 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)16 HashMap (java.util.HashMap)16 StringContains.containsString (org.hamcrest.core.StringContains.containsString)15 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)14 Stage (com.thoughtworks.go.domain.Stage)13 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)13