@Test public void systemLabelTest() throws InvalidJobException { String artifactName = "art1.zip"; List<Label> labels = new ArrayList<>(); labels.add(new Label(MANTIS_ARTIFACT_LABEL.label, "art0.zip")); JobDefinition jobDefinition = generateJobDefinition("systemLabelTest", labels, artifactName,"1.0"); JobDefinition updatedJobDefn = LabelManager.insertSystemLabels(jobDefinition, true); assertEquals(3, updatedJobDefn.getLabels().size()); for(Label l : updatedJobDefn.getLabels()) { if(l.getName().equals(MANTIS_ARTIFACT_LABEL.label)) { assertEquals(artifactName, l.getValue()); } else if (l.getName().equals(MANTIS_IS_RESUBMIT_LABEL.label)){ assertEquals("true", l.getValue()); } else { assertEquals("1.0", l.getValue()); } } }
static JobDefinition insertSystemLabels(JobDefinition resolvedJobDefn, boolean autoResubmit) { JobDefinition updatedJobDefn = resolvedJobDefn; if(autoResubmit) { updatedJobDefn = insertAutoResubmitLabel(resolvedJobDefn); } String artifactName = updatedJobDefn.getArtifactName(); String version = updatedJobDefn.getVersion(); List<Label> labels = updatedJobDefn.getLabels(); List<Label> updatedLabels = labels.stream() .filter(label -> !(label.getName().equals(SystemLabels.MANTIS_ARTIFACT_LABEL.label))) .filter(label -> !label.getName().equals(SystemLabels.MANTIS_VERSION_LABEL.label)) .collect(Collectors.toList()); updatedLabels.add(new Label(SystemLabels.MANTIS_ARTIFACT_LABEL.label, artifactName)); updatedLabels.add(new Label(SystemLabels.MANTIS_VERSION_LABEL.label, version)); try { updatedJobDefn = new JobDefinition.Builder().from(updatedJobDefn) .withLabels(updatedLabels).build(); return updatedJobDefn; } catch (InvalidJobException e) { logger.error(e.getMessage()); return resolvedJobDefn; } }
LabelManager { static JobDefinition insertSystemLabels(JobDefinition resolvedJobDefn, boolean autoResubmit) { JobDefinition updatedJobDefn = resolvedJobDefn; if(autoResubmit) { updatedJobDefn = insertAutoResubmitLabel(resolvedJobDefn); } String artifactName = updatedJobDefn.getArtifactName(); String version = updatedJobDefn.getVersion(); List<Label> labels = updatedJobDefn.getLabels(); List<Label> updatedLabels = labels.stream() .filter(label -> !(label.getName().equals(SystemLabels.MANTIS_ARTIFACT_LABEL.label))) .filter(label -> !label.getName().equals(SystemLabels.MANTIS_VERSION_LABEL.label)) .collect(Collectors.toList()); updatedLabels.add(new Label(SystemLabels.MANTIS_ARTIFACT_LABEL.label, artifactName)); updatedLabels.add(new Label(SystemLabels.MANTIS_VERSION_LABEL.label, version)); try { updatedJobDefn = new JobDefinition.Builder().from(updatedJobDefn) .withLabels(updatedLabels).build(); return updatedJobDefn; } catch (InvalidJobException e) { logger.error(e.getMessage()); return resolvedJobDefn; } } }
LabelManager { static JobDefinition insertSystemLabels(JobDefinition resolvedJobDefn, boolean autoResubmit) { JobDefinition updatedJobDefn = resolvedJobDefn; if(autoResubmit) { updatedJobDefn = insertAutoResubmitLabel(resolvedJobDefn); } String artifactName = updatedJobDefn.getArtifactName(); String version = updatedJobDefn.getVersion(); List<Label> labels = updatedJobDefn.getLabels(); List<Label> updatedLabels = labels.stream() .filter(label -> !(label.getName().equals(SystemLabels.MANTIS_ARTIFACT_LABEL.label))) .filter(label -> !label.getName().equals(SystemLabels.MANTIS_VERSION_LABEL.label)) .collect(Collectors.toList()); updatedLabels.add(new Label(SystemLabels.MANTIS_ARTIFACT_LABEL.label, artifactName)); updatedLabels.add(new Label(SystemLabels.MANTIS_VERSION_LABEL.label, version)); try { updatedJobDefn = new JobDefinition.Builder().from(updatedJobDefn) .withLabels(updatedLabels).build(); return updatedJobDefn; } catch (InvalidJobException e) { logger.error(e.getMessage()); return resolvedJobDefn; } }  }
LabelManager { static JobDefinition insertSystemLabels(JobDefinition resolvedJobDefn, boolean autoResubmit) { JobDefinition updatedJobDefn = resolvedJobDefn; if(autoResubmit) { updatedJobDefn = insertAutoResubmitLabel(resolvedJobDefn); } String artifactName = updatedJobDefn.getArtifactName(); String version = updatedJobDefn.getVersion(); List<Label> labels = updatedJobDefn.getLabels(); List<Label> updatedLabels = labels.stream() .filter(label -> !(label.getName().equals(SystemLabels.MANTIS_ARTIFACT_LABEL.label))) .filter(label -> !label.getName().equals(SystemLabels.MANTIS_VERSION_LABEL.label)) .collect(Collectors.toList()); updatedLabels.add(new Label(SystemLabels.MANTIS_ARTIFACT_LABEL.label, artifactName)); updatedLabels.add(new Label(SystemLabels.MANTIS_VERSION_LABEL.label, version)); try { updatedJobDefn = new JobDefinition.Builder().from(updatedJobDefn) .withLabels(updatedLabels).build(); return updatedJobDefn; } catch (InvalidJobException e) { logger.error(e.getMessage()); return resolvedJobDefn; } }   }
LabelManager { static JobDefinition insertSystemLabels(JobDefinition resolvedJobDefn, boolean autoResubmit) { JobDefinition updatedJobDefn = resolvedJobDefn; if(autoResubmit) { updatedJobDefn = insertAutoResubmitLabel(resolvedJobDefn); } String artifactName = updatedJobDefn.getArtifactName(); String version = updatedJobDefn.getVersion(); List<Label> labels = updatedJobDefn.getLabels(); List<Label> updatedLabels = labels.stream() .filter(label -> !(label.getName().equals(SystemLabels.MANTIS_ARTIFACT_LABEL.label))) .filter(label -> !label.getName().equals(SystemLabels.MANTIS_VERSION_LABEL.label)) .collect(Collectors.toList()); updatedLabels.add(new Label(SystemLabels.MANTIS_ARTIFACT_LABEL.label, artifactName)); updatedLabels.add(new Label(SystemLabels.MANTIS_VERSION_LABEL.label, version)); try { updatedJobDefn = new JobDefinition.Builder().from(updatedJobDefn) .withLabels(updatedLabels).build(); return updatedJobDefn; } catch (InvalidJobException e) { logger.error(e.getMessage()); return resolvedJobDefn; } }    }