MergeLimitationsValidator implements DocumentViewXmlValidator { @Override public Collection<ValidationMessage> validate(@NotNull DocViewNode node, @NotNull String nodePath, @NotNull Path filePath, boolean isRoot) { if (!isRoot && !node.props.isEmpty() && rootNodePathsOfMergeRules.contains(nodePath)) { return Collections.singleton(new ValidationMessage(severity, String.format(PACKAGE_NON_ROOT_NODE_MERGED, nodePath))); } return null; } MergeLimitationsValidator(ValidationMessageSeverity severity, WorkspaceFilter filter); @Override Collection<ValidationMessage> done(); @Override Collection<ValidationMessage> validate(@NotNull DocViewNode node, @NotNull String nodePath, @NotNull Path filePath, boolean isRoot);  }
@Test public void testWithAggregateAtWrongLevel() { Map<String, DocViewProperty> props = new HashMap<>(); props.put("prop1", new DocViewProperty("prop1", new String[] { "value1" } , false, PropertyType.STRING)); DocViewNode node = new DocViewNode("somename", "somename", null, props, null, "nt:unstructured"); Collection<ValidationMessage> messages = validator.validate(node, "/apps/test/deep", Paths.get(".content.xml"), false); ValidationExecutorTest.assertViolation(messages, new ValidationMessage(ValidationMessageSeverity.ERROR, String.format(MergeLimitationsValidator.PACKAGE_NON_ROOT_NODE_MERGED, "/apps/test/deep"))); }
@Test public void testWithAggregateAtCorrectLevel() { Map<String, DocViewProperty> props = new HashMap<>(); props.put("prop1", new DocViewProperty("prop1", new String[] { "value1" } , false, PropertyType.STRING)); DocViewNode node = new DocViewNode("somename", "somename", null, props, null, "nt:unstructured"); Collection<ValidationMessage> messages = validator.validate(node, "/apps/test/deep", Paths.get(".content.xml"), true); Assert.assertThat(messages, AnyValidationMessageMatcher.noValidationInCollection()); }