Search in sources :

Example 81 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateInstancesBuiltFromCurrentPipeline.

@Test
public void shouldPopulateInstancesBuiltFromCurrentPipeline() {
    /*
            g1 -> P -> P2  -->  P4
                        \      /
                         + P3 +
        */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
    Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
    Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
    Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
    valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
    valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
    GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
    u.checkinInOrder(g1, "g_1");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    String p_1 = u.runAndPass(p, "g_1");
    String p2_1 = u.runAndPass(p2, p_1);
    String p3_1 = u.runAndPass(p3, p2_1);
    String p4_1 = u.runAndPass(p4, p2_1, p3_1);
    downstreamInstancePopulator.apply(valueStreamMap);
    assertInstances(nodep2, "p2", 1);
    assertInstances(nodep3, "p3", 1);
    assertInstances(nodep4, "p4", 1);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 82 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines.

@Test
public void shouldPopulateMultipleInstancesBuiltFromDifferentUpstreamPipelines() {
    /*
            g1 -> P -> P2 -> P4 --> P5
                     \    /
                       P3
        */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
    Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
    Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p");
    Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
    valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
    Node nodep5 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p5", "p5"), "p4");
    valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
    GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
    u.checkinInOrder(g1, "g_1");
    u.checkinInOrder(g1, "g_2");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    ScheduleTestUtil.AddedPipeline p5 = u.saveConfigWith("p5", u.m(p4));
    String p_1 = u.runAndPass(p, "g_1");
    String p_2 = u.runAndPass(p, "g_2");
    String p2_1 = u.runAndPass(p2, p_1);
    String p2_2 = u.runAndPass(p2, p_1);
    String p2_3 = u.runAndPass(p2, p_2);
    String p3_1 = u.runAndPass(p3, p_1);
    String p3_2 = u.runAndPass(p3, p_1);
    String p4_1 = u.runAndPass(p4, p2_1, p3_1);
    String p4_2 = u.runAndPass(p4, p2_2, p3_1);
    String p4_3 = u.runAndPass(p4, p2_3, p3_2);
    String p5_1 = u.runAndPass(p5, p4_1);
    String p5_2 = u.runAndPass(p5, p4_2);
    String p5_3 = u.runAndPass(p5, p4_3);
    downstreamInstancePopulator.apply(valueStreamMap);
    assertInstances(nodep2, "p2", 1, 2);
    assertInstances(nodep3, "p3", 1, 2);
    assertInstances(nodep4, "p4", 1, 2, 3);
    assertInstances(nodep5, "p5", 1, 2, 3);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 83 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateMultipleInstancesBuiltFromUpstreamRevisions.

@Test
public void shouldPopulateMultipleInstancesBuiltFromUpstreamRevisions() {
    /*
            g1 -> P -> P2  -->  P4 --> P5
                        \      /
                         + P3 +
        */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", new PipelineRevision("p", 1, "13.1.1"));
    Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
    Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
    Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
    valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
    valueStreamMap.addUpstreamMaterialNode(new SCMDependencyNode("g1", "g1", "git"), new CaseInsensitiveString("git"), "p", new MaterialRevision(null));
    GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
    u.checkinInOrder(g1, "g_1");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    String p_1 = u.runAndPass(p, "g_1");
    String p2_1 = u.runAndPass(p2, p_1);
    String p2_2 = u.runAndPass(p2, p_1);
    String p3_1 = u.runAndPass(p3, p2_2);
    String p4_1 = u.runAndPass(p4, p2_1, p3_1);
    String p4_2 = u.runAndPass(p4, p2_2, p3_1);
    downstreamInstancePopulator.apply(valueStreamMap);
    assertInstances(nodep2, "p2", 1, 2);
    assertInstances(nodep3, "p3", 1);
    assertInstances(nodep4, "p4", 1, 2);
}
Also used : ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 84 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class RoleRepresenter method fromJSON.

// private static void addLinks(Role model, JsonWriter jsonWriter) {
// jsonWriter.addDocLink(Routes.Roles.DOC);
// jsonWriter.self(Routes.Roles.name(model.getName().toString()));
// jsonWriter.find(Routes.Roles.find());
// }
// public static Map toJSON(Role role, RequestContext requestContext) {
// if (role == null) return null;
// 
// JsonWriter jsonWriter = new JsonWriter(requestContext);
// 
// addLinks(role, jsonWriter);
// 
// jsonWriter.add("name", role.getName().toString());
// jsonWriter.add("type", getRoleType(role));
// if (role.hasErrors()) {
// jsonWriter.add("errors", new ErrorGetter(Collections.singletonMap("authConfigId", "auth_config_id"))
// .apply(role, requestContext));
// }
// if (role instanceof RoleConfig) {
// jsonWriter.add("attributes", GoCDRoleConfigRepresenter.toJSON((RoleConfig) role, requestContext));
// } else if (role instanceof PluginRoleConfig) {
// jsonWriter.add("attributes", PluginRoleConfigRepresenter.toJSON((PluginRoleConfig) role, requestContext));
// }
// return jsonWriter.getAsMap();
// }
public static Role fromJSON(JsonReader jsonReader) {
    Role model;
    String type = jsonReader.optString("type").orElse("");
    if ("gocd".equals(type)) {
        model = GoCDRoleConfigRepresenter.fromJSON(jsonReader.readJsonObject("attributes"));
    } else if ("plugin".equals(type)) {
        model = PluginRoleConfigRepresenter.fromJSON(jsonReader.readJsonObject("attributes"));
    } else {
        throw new JsonParseException("Invalid role type '%s'. It has to be one of 'gocd' or 'plugin'");
    }
    model.setName(new CaseInsensitiveString(jsonReader.optString("name").orElse(null)));
    return model;
}
Also used : Role(com.thoughtworks.go.config.Role) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) JsonParseException(com.google.gson.JsonParseException) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 85 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class StageInstanceModels method updateFutureStagesFrom.

public void updateFutureStagesFrom(PipelineConfig pipelineConfig) {
    StageInstanceModel lastStage = this.last();
    StageConfig nextStage = lastStage == null ? pipelineConfig.getFirstStageConfig() : pipelineConfig.nextStage(new CaseInsensitiveString(lastStage.getName()));
    while (nextStage != null && !this.hasStage(str(nextStage.name()))) {
        this.addFutureStage(str(nextStage.name()), !nextStage.requiresApproval());
        nextStage = pipelineConfig.nextStage(nextStage.name());
    }
}
Also used : StageConfig(com.thoughtworks.go.config.StageConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)392 Test (org.junit.Test)277 Username (com.thoughtworks.go.server.domain.Username)80 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)65 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)57 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)50 Modification (com.thoughtworks.go.domain.materials.Modification)44 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Before (org.junit.Before)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 HashMap (java.util.HashMap)26 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ArrayList (java.util.ArrayList)19 Pipeline (com.thoughtworks.go.domain.Pipeline)18