@Test public void insertArtifactLabelTest() throws InvalidJobException { String artifactName = "art.zip"; JobDefinition jobDefinition = generateJobDefinition("insertResubmitLabelTest", new ArrayList<>(), artifactName, "1.0"); JobDefinition updatedJobDefn = LabelManager.insertSystemLabels(jobDefinition, false); assertEquals(2, updatedJobDefn.getLabels().size()); List<Label> labels = updatedJobDefn.getLabels().stream().filter( label -> label.getName().equals(MANTIS_ARTIFACT_LABEL.label)) .collect(Collectors.toList()); Label label = labels.get(0); assertEquals(MANTIS_ARTIFACT_LABEL.label, label.getName()); assertEquals(artifactName, label.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; } }    }