### Question:
VocabularyEnforcementJob extends AbstractDepositJob { private boolean updateDocumentTerms(PID pid, Element doc) throws JDOMException { boolean result = false; Set<VocabularyHelper> helpers = vocabManager.getRemappingHelpers(pid); if (helpers != null) { for (VocabularyHelper helper : helpers) { result = helper.updateDocumentTerms(doc) || result; } } return result; } VocabularyEnforcementJob();  VocabularyEnforcementJob(String uuid, String depositUUID); @Override void runJob();  }### Answer:
@Test public void rewriteMODSTest() throws Exception { Files.copy(Paths.get("src/test/resources/mods/singleAffiliationMods.xml"), job.getModsPath(rescPid, true)); Set<VocabularyHelper> helpers = new HashSet<>(Arrays.asList(mockHelper)); when(vocabManager.getRemappingHelpers(any(PID.class))).thenReturn(helpers); doAnswer(new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { Element doc = (Element) invocation.getArguments()[0]; doc.addContent(new Element("testElement")); return true; } }).when(mockHelper).updateDocumentTerms(any(Element.class)); job.run(); verify(mockHelper).updateDocumentTerms(any(Element.class)); Document modsDoc = getMODSDocument(rescPid.getUUID()); Element testElement = element("/mods:mods/testElement", modsDoc); assertTrue("Document was not modified", testElement != null); }
@Test public void noRewriteMODSTest() throws Exception { Path path = job.getModsPath(rescPid, true); Files.copy(Paths.get("src/test/resources/mods/singleAffiliationMods.xml"), path); long modified = path.toFile().lastModified(); Set<VocabularyHelper> helpers = new HashSet<>(Arrays.asList(mockHelper)); when(vocabManager.getRemappingHelpers(any(PID.class))).thenReturn(helpers); when(mockHelper.updateDocumentTerms(any(Element.class))).thenReturn(false); Thread.sleep(100L); job.run(); verify(mockHelper).updateDocumentTerms(any(Element.class)); assertTrue("Timestamp on MODS file changed", modified == path.toFile().lastModified()); }