Tabnine Logo
MaterialConfigs
Code IndexAdd Tabnine to your IDE (free)

How to use
MaterialConfigs
in
com.thoughtworks.go.config.materials

Best Java code snippets using com.thoughtworks.go.config.materials.MaterialConfigs (Showing top 20 results out of 315)

origin: gocd/gocd

@Test
public void shouldSetPluggableSCMMaterialConfigAttributesForMaterial() {
  String scmId = "scm-id";
  Map<String, String> hashMap = new HashMap<>();
  hashMap.put(PluggableSCMMaterialConfig.SCM_ID, scmId);
  Map<String, Object> attributeMap = new HashMap<>();
  attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, PluggableSCMMaterialConfig.TYPE);
  attributeMap.put(PluggableSCMMaterialConfig.TYPE, hashMap);
  MaterialConfigs materialConfigs = new MaterialConfigs();
  materialConfigs.setConfigAttributes(attributeMap);
  assertThat(materialConfigs.size(), is(1));
  assertThat(((PluggableSCMMaterialConfig) materialConfigs.first()).getScmId(), is(scmId));
}
origin: gocd/gocd

public MaterialConfigs convertToConfigs() {
  MaterialConfigs configs = new MaterialConfigs();
  for (Material material : this) {
    configs.add(material.config());
  }
  return configs;
}
origin: gocd/gocd

public Validatable updatedNode(CruiseConfig cruiseConfig) {
  if (packageMaterialConfig.getPackageDefinition() != null) {
    return cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline)).materialConfigs().get(packageMaterialConfig);
  }
  return packageMaterialConfig;
}
origin: gocd/gocd

public boolean validateTree(PipelineConfigSaveValidationContext validationContext) {
  if (isEmpty()) {
    errors().add("materials", "A pipeline must have at least one material");
  }
  validate(validationContext);
  boolean isValid = errors().isEmpty();
  for (MaterialConfig materialConfig : this) {
    isValid = materialConfig.validateTree(validationContext) && isValid;
  }
  return isValid;
}
origin: gocd/gocd

public void setConfigAttributes(Object attributes) {
  clear();
  if (attributes == null) {
    return;
  }
  Map attributeMap = (Map) attributes;
  String materialType = (String) attributeMap.get(AbstractMaterialConfig.MATERIAL_TYPE);
  if (SvnMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getSvnMaterial(), (Map) attributeMap.get(SvnMaterialConfig.TYPE));
  } else if (HgMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getHgMaterial(), (Map) attributeMap.get(HgMaterialConfig.TYPE));
  } else if (GitMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getGitMaterial(), (Map) attributeMap.get(GitMaterialConfig.TYPE));
  } else if (P4MaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getP4Material(), (Map) attributeMap.get(P4MaterialConfig.TYPE));
  } else if (DependencyMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getDependencyMaterial(), (Map) attributeMap.get(DependencyMaterialConfig.TYPE));
  } else if (TfsMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getTfsMaterial(), (Map) attributeMap.get(TfsMaterialConfig.TYPE));
  } else if (PackageMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getPackageMaterial(), (Map) attributeMap.get(PackageMaterialConfig.TYPE));
  } else if (PluggableSCMMaterialConfig.TYPE.equals(materialType)) {
    addMaterialConfig(getSCMMaterial(), (Map) attributeMap.get(PluggableSCMMaterialConfig.TYPE));
  }
}
origin: gocd/gocd

@Test
public void shouldNotFailIfAllScmMaterialsInAPipelineHaveDifferentFolders() {
  HgMaterialConfig materialOne = new HgMaterialConfig("http://url1", null);
  materialOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder1"));
  HgMaterialConfig materialTwo = new HgMaterialConfig("http://url2", null);
  materialTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder2"));
  CruiseConfig config = GoConfigMother.configWithPipelines("one");
  PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
  pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne, materialTwo));
  pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
  assertThat(pipelineOne.materialConfigs().get(0).errors().isEmpty(), is(true));
  assertThat(pipelineOne.materialConfigs().get(1).errors().isEmpty(), is(true));
}
origin: gocd/gocd

public MaterialConfigs getAllMaterialsByFingerPrint(String fingerprint) {
  if (fingerprintToMaterials == null || fingerprintToMaterials.isEmpty()) {
    primeForMaterialValidations();
  }
  MaterialConfigs matchingMaterials = fingerprintToMaterials.get(fingerprint);
  return matchingMaterials == null ? new MaterialConfigs() : matchingMaterials;
}
origin: gocd/gocd

public static PipelineConfig createManualTriggerPipelineConfig(MaterialConfig materialConfig, String pipelineName, String stageName, String... buildNames) {
  PipelineConfig pipelineConfig = createPipelineConfig(pipelineName, stageName, buildNames);
  pipelineConfig.materialConfigs().clear();
  materialConfig.setName(new CaseInsensitiveString(String.format("%s-%s", pipelineName, materialConfig.getType())));
  materialConfig.setAutoUpdate(false);
  pipelineConfig.materialConfigs().add(materialConfig);
  pipelineConfig.first().setApproval(Approval.manualApproval());
  return pipelineConfig;
}
origin: gocd/gocd

@Test
public void shouldValidateAndUpdatePipelineConfig() {
  PipelineConfig pipeline = new PipelineConfig();
  pipeline.setName("validPipeline");
  pipeline.setMaterialConfigs(new MaterialConfigs(MaterialConfigsMother.gitMaterialConfig(), MaterialConfigsMother.svnMaterialConfig()));
  StageConfig stage1 = getStageConfig("stage1", "s1j1");
  StageConfig stage2 = getStageConfig("stage2", "s2j1");
  pipeline.getStages().add(stage1);
  pipeline.getStages().add(stage2);
  BasicCruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs("group", new Authorization(), pipeline));
  boolean isValid = pipeline.validateTree(PipelineConfigSaveValidationContext.forChain(true, cruiseConfig.getGroups().first().getGroup(), cruiseConfig, pipeline));
  assertThat(isValid, is(true));
  assertThat(pipeline.materialConfigs().errors().isEmpty(), is(true));
  assertThat(pipeline.materialConfigs().get(0).errors().isEmpty(), is(true));
  assertThat(pipeline.materialConfigs().get(1).errors().isEmpty(), is(true));
  assertThat(pipeline.errors().getAll().isEmpty(), is(true));
}
origin: gocd/gocd

@Test
public void shouldAddErrorWhenMatchingPackageIDDoesNotExist(){
  PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("package-name"), "package-id", PackageDefinitionMother.create("package-id"));
  CruiseConfig config = GoConfigMother.configWithPipelines("one");
  PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("one"));
  MaterialConfigs materialConfigs = new MaterialConfigs(packageMaterialConfig);
  pipelineConfig.setMaterialConfigs(materialConfigs);
  materialConfigs.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", config));
  assertThat(pipelineConfig.materialConfigs().get(0).errors().on(packageMaterialConfig.PACKAGE_ID), is("Could not find repository for given package id:[package-id]"));
}
origin: gocd/gocd

@Test
public void shouldSetSvnConfigAttributesForMaterial() {
  MaterialConfigs materialConfigs = new MaterialConfigs();
  Map<String, Object> svnAttrMap = new HashMap<>();
  svnAttrMap.put(SvnMaterialConfig.URL, "foo");
  svnAttrMap.put(SvnMaterialConfig.USERNAME, "bar");
  svnAttrMap.put(SvnMaterialConfig.PASSWORD, "baz");
  svnAttrMap.put(SvnMaterialConfig.CHECK_EXTERNALS, false);
  Map<String, Object> attributeMap = new HashMap<>();
  attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, SvnMaterialConfig.TYPE);
  attributeMap.put(SvnMaterialConfig.TYPE, svnAttrMap);
  materialConfigs.setConfigAttributes(attributeMap);
  assertThat(materialConfigs.first(), is(new SvnMaterialConfig("foo", "bar", "baz", false)));
}
origin: gocd/gocd

@Test
public void shouldAllowModifyingTheAutoUpdateFieldOfMaterials() throws Exception {
  GitMaterialConfig gitMaterial = new GitMaterialConfig("https://url", "master");
  gitMaterial.setAutoUpdate(true);
  GitMaterialConfig modifiedGitMaterial = new GitMaterialConfig("https://url", "master");
  modifiedGitMaterial.setAutoUpdate(false);
  MaterialConfigs configs = new MaterialConfigs();
  configs.add(gitMaterial);
  CruiseConfig config = GoConfigMother.configWithPipelines("one");
  PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
  pipelineOne.setMaterialConfigs(new MaterialConfigs(modifiedGitMaterial));
  configs.validate(ConfigSaveValidationContext.forChain(config));
  assertTrue(gitMaterial.errors().isEmpty());
}
origin: gocd/gocd

@Test
public void shouldCheckSCMMaterialsHaveDestinationCorrectly() {
  HgMaterialConfig materialConfigOne = new HgMaterialConfig("http://url1", null);
  materialConfigOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder"));
  CruiseConfig config = GoConfigMother.configWithPipelines("one");
  PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
  pipelineOne.setMaterialConfigs((new MaterialConfigs(materialConfigOne)));
  assertThat(pipelineOne.materialConfigs().scmMaterialsHaveDestination(), is(true));
  PluggableSCMMaterialConfig materialConfigTwo = new PluggableSCMMaterialConfig(null, SCMMother.create("scm-id"), null, null);
  pipelineOne.materialConfigs().add(materialConfigTwo);
  assertThat(pipelineOne.materialConfigs().scmMaterialsHaveDestination(), is(false));
}
origin: gocd/gocd

@Test
public void shouldFailValidationInNoMaterialPresent(){
  MaterialConfigs materialConfigs = new MaterialConfigs();
  assertThat(materialConfigs.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new PipelineConfig())), is(false));
  assertThat(materialConfigs.errors().firstError(), is("A pipeline must have at least one material"));
}
origin: gocd/gocd

public void addMaterialConfig(MaterialConfig materialConfig) {
  this.materialConfigs.add(materialConfig);
}
origin: gocd/gocd

@Test
public void shouldAllowToDependOnPipelineDefinedInFile_WhenInFile() throws Exception {
  CruiseConfig cruiseConfig = new BasicCruiseConfig();
  PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
  PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
  goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
  pipeline1.setOrigin(new FileConfigOrigin());
  pipeline2.setOrigin(new FileConfigOrigin());
  pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
  assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
  pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
  DependencyMaterialConfig dep = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
  assertThat(dep.errors().isEmpty(), is(true));
}
origin: gocd/gocd

@Test
public void shouldLoadPipelineWithMultipleMaterials() throws Exception {
  String pipelineXmlPartial =
      "<pipeline name=\"pipeline\">\n"
          + "  <materials>\n"
          + "    <svn url=\"/hgrepo1\" dest=\"folder1\" />\n"
          + "    <svn url=\"/hgrepo2\" dest=\"folder2\" />\n"
          + "    <svn url=\"/hgrepo3\" dest=\"folder3\" />\n"
          + "  </materials>\n"
          + "  <stage name=\"mingle\">\n"
          + "    <jobs>\n"
          + "      <job name=\"functional\">\n"
          + "        <artifacts>\n"
          + "          <log src=\"artifact1.xml\" dest=\"cruise-output\" />\n"
          + "        </artifacts>\n"
          + "      </job>\n"
          + "    </jobs>\n"
          + "  </stage>\n"
          + "</pipeline>\n";
  PipelineConfig pipeline = xmlLoader.fromXmlPartial(pipelineXmlPartial, PipelineConfig.class);
  assertThat(pipeline.materialConfigs().size(), is(3));
  ScmMaterialConfig material = (ScmMaterialConfig) pipeline.materialConfigs().get(0);
  assertThat(material.getFolder(), is("folder1"));
}
origin: gocd/gocd

@Test
public void shouldGetAllMaterialsByFingerPrint() throws Exception {
  CruiseConfig cruiseConfig = new GoConfigMother().cruiseConfigWithPipelineUsingTwoMaterials();
  MaterialConfig expectedMaterial = MaterialConfigsMother.multipleMaterialConfigs().get(1);
  PipelineConfigSaveValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig);
  MaterialConfigs allMaterialsByFingerPrint = context.getAllMaterialsByFingerPrint(expectedMaterial.getFingerprint());
  assertThat(allMaterialsByFingerPrint.size(), is(1));
  assertThat(allMaterialsByFingerPrint.first(), is(expectedMaterial));
}
@Test
origin: gocd/gocd

@Test
public void shouldReturnAllMaterialsMatchingTheFingerprint() {
  CruiseConfig cruiseConfig = new BasicCruiseConfig();
  HgMaterialConfig hg = new HgMaterialConfig("url", null);
  for (int i = 0; i < 10; i++) {
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("pipeline" + i, new MaterialConfigs(hg));
    cruiseConfig.addPipeline("defaultGroup", pipelineConfig);
  }
  ValidationContext context = ConfigSaveValidationContext.forChain(cruiseConfig);
  assertThat(context.getAllMaterialsByFingerPrint(hg.getFingerprint()).size(), is(10));
}
origin: gocd/gocd

@Test
public void shouldNotRunMultipleMaterialsValidationIfPipelineContainsOnlyOneMaterial() {
  CruiseConfig config = GoConfigMother.configWithPipelines("one");
  PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one"));
  SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
  svnMaterialConfig.setFolder(null);
  pipelineOne.setMaterialConfigs(new MaterialConfigs(svnMaterialConfig));
  pipelineOne.materialConfigs().validate(ConfigSaveValidationContext.forChain(config));
  assertThat(svnMaterialConfig.errors().toString(), svnMaterialConfig.errors().getAll().size(), is(0));
}
com.thoughtworks.go.config.materialsMaterialConfigs

Most used methods

  • <init>
  • add
  • get
  • clear
  • first
  • errors
  • findDependencyMaterial
  • forEach
  • size
  • validate
  • getExistingOrDefaultMaterial
  • hasDependencyMaterial
  • getExistingOrDefaultMaterial,
  • hasDependencyMaterial,
  • hasMaterialWithFingerprint,
  • isEmpty,
  • setConfigAttributes,
  • validateTree,
  • addAll,
  • addError,
  • addMaterialConfig,
  • displayNameFor

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • requestLocationUpdates (LocationManager)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Runner (org.openjdk.jmh.runner)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now