### Question:
EnsureOakIndexJobHandler implements Runnable { @SuppressWarnings("squid:S3776") public Resource update(final @Nonnull Resource ensureDefinition, final @Nonnull Resource oakIndexes, boolean forceReindex) throws RepositoryException, IOException { final ValueMap ensureDefinitionProperties = ensureDefinition.getValueMap(); final Resource oakIndex = oakIndexes.getChild(ensureDefinition.getName()); final Node oakIndexNode = oakIndex.adaptTo(Node.class); final Node ensureDefinitionNode = ensureDefinition.adaptTo(Node.class); if (!this.needsUpdate(ensureDefinition, oakIndex)) { if (ensureDefinitionProperties.get(PN_FORCE_REINDEX, false)) { log.info("Skipping update... Oak Index at [ {} ] is the same as [ {} ] and forceIndex flag is ignored", oakIndex.getPath(), ensureDefinition.getPath()); } else { log.info("Skipping update... Oak Index at [ {} ] is the same as [ {} ]", oakIndex.getPath(), ensureDefinition.getPath()); } return null; } final Iterator<Property> existingOakIndexProperties = copyIterator(oakIndexNode.getProperties()); while(existingOakIndexProperties.hasNext()) { final Property property = existingOakIndexProperties.next(); final String propertyName = property.getName(); if (this.ignoreProperties.contains(propertyName)) { continue; } JcrUtil.setProperty(oakIndexNode, propertyName, null); } final Iterator<Property> addProperties = copyIterator(ensureDefinitionNode.getProperties()); while (addProperties.hasNext()) { final Property property = addProperties.next(); if (this.ignoreProperties.contains(property.getName())) { continue; } if (ArrayUtils.contains(NAME_PROPERTIES, property.getName()) && property.getType() != PropertyType.NAME) { log.warn("{}@{} property should be of type: Name[]", oakIndex.getPath(), property.getName()); } JcrUtil.copy(property, oakIndexNode, property.getName()); } JcrUtil.setProperty(oakIndexNode, JcrConstants.JCR_LAST_MODIFIED_BY, ENSURE_OAK_INDEX_USER_NAME); JcrUtil.setProperty(oakIndexNode, JcrConstants.JCR_LASTMODIFIED, Calendar.getInstance()); Iterator<Resource> children = oakIndex.listChildren(); while (children.hasNext()) { children.next().adaptTo(Node.class).remove(); } children = ensureDefinition.listChildren(); while (children.hasNext()) { final Resource child = children.next(); JcrUtil.copy(child.adaptTo(Node.class), oakIndex.adaptTo(Node.class), child.getName()); } if (forceReindex) { log.info("Updated Oak Index at [ {} ] with configuration [ {} ], triggering reindex", oakIndex.getPath(), ensureDefinition.getPath()); forceRefresh(oakIndex); } else { log.warn("Updated Oak Index at [ {} ] with configuration [ {} ], but no reindex requested!", oakIndex.getPath(), ensureDefinition.getPath()); } return oakIndex; } EnsureOakIndexJobHandler(EnsureOakIndex ensureOakIndex, String oakIndexPath, String ensureDefinitionsPath); @Override @SuppressWarnings("squid:S1141") void run(); void forceRefresh(final @Nonnull Resource oakIndex); Resource create(final @Nonnull Resource ensuredDefinition, final @Nonnull Resource oakIndexes); @SuppressWarnings("squid:S3776") Resource update(final @Nonnull Resource ensureDefinition, final @Nonnull Resource oakIndexes, boolean forceReindex); void disableIndex(@Nonnull Resource oakIndex); void delete(final @Nonnull Resource oakIndex); void validateEnsureDefinition(@Nonnull Resource ensureDefinition);  }### Answer:
@Test public void testUpdate() { context.build().resource(ENSURE_INDEX_PATH, ensureIndexProperties).commit(); context.build().resource(OAK_INDEX_PATH, oakIndexProperties).commit(); handler.run(); Resource indexResource = context.resourceResolver().getResource(OAK_INDEX_PATH); assertNotNull(indexResource); ValueMap vm = indexResource.adaptTo(ValueMap.class); assertNotNull(vm); assertEquals("newProp",vm.get("propertyNames",String.class)); assertEquals("1",vm.get("reindexCount",String.class)); }