### Question:
LabelManager { static JobDefinition insertAutoResubmitLabel(JobDefinition resolvedJobDefn) { List<Label> labels = resolvedJobDefn.getLabels(); boolean alreadyHasResubmitLabel = labels.stream().anyMatch( label -> label.getName().equals(SystemLabels.MANTIS_IS_RESUBMIT_LABEL.label)); if(!alreadyHasResubmitLabel) { List<Label> updatedLabels = new ArrayList<>(labels); updatedLabels.add(new Label(SystemLabels.MANTIS_IS_RESUBMIT_LABEL.label, "true")); try { JobDefinition updatedJobDefn = new JobDefinition.Builder().from(resolvedJobDefn) .withLabels(updatedLabels).build(); logger.debug("Added isResubmit label"); return updatedJobDefn; } catch (InvalidJobException e) { logger.error(e.getMessage()); return resolvedJobDefn; } } else { logger.debug("Job " + resolvedJobDefn.getName() + " already has isResubmit label. Don't add new"); return resolvedJobDefn; } }    }### Answer:
@Test public void insertResubmitLabelTest() throws InvalidJobException { JobDefinition jobDefinition = generateJobDefinition("insertResubmitLabelTest", new ArrayList<>(), "art.zip", "1.0"); JobDefinition updatedJobDefn = LabelManager.insertAutoResubmitLabel(jobDefinition); assertEquals(1, updatedJobDefn.getLabels().size()); Label label = updatedJobDefn.getLabels().get(0); assertEquals(MANTIS_IS_RESUBMIT_LABEL.label, label.getName()); }
@Test public void doNotinsertResubmitLabelIfAlreadyExistsTest() throws InvalidJobException { List<Label> labels = new ArrayList<>(); labels.add(new Label(MANTIS_IS_RESUBMIT_LABEL.label, "true")); JobDefinition jobDefinition = generateJobDefinition("DoNotinsertResubmitLabelIfAlreadyExistsTest", labels, "art.zip", "1.0"); JobDefinition updatedJobDefn = LabelManager.insertAutoResubmitLabel(jobDefinition); assertEquals(1, updatedJobDefn.getLabels().size()); Label label = updatedJobDefn.getLabels().get(0); assertEquals(MANTIS_IS_RESUBMIT_LABEL.label, label.getName()); }