Copilot commented on code in PR #370:
URL:
https://github.com/apache/jackrabbit-filevault/pull/370#discussion_r2024797204
##########
vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/PackageTypeValidatorTest.java:
##########
@@ -118,6 +118,14 @@ public void testContentPackageType() {
Mockito.when(properties.getPackageType()).thenReturn(PackageType.CONTENT);
MatcherAssert.assertThat(validator.validate(properties),
AnyValidationViolationMessageMatcher.noValidationViolationMessageInCollection());
Mockito.when(parentContainerProperties.getPackageType()).thenReturn(PackageType.CONTENT);
+
+ // with filters outside mutable areas
+ DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+ try (InputStream input =
this.getClass().getResourceAsStream("/filter-with-mutable-and-immutable-roots.xml"))
{
+ filter.load(input);
+ }
+ ValidationExecutorTest.assertViolation(validator.validate(filter), new
ValidationMessage(ValidationMessageSeverity.ERROR,
String.format(PackageTypeValidator.MESSAGE_FILTER_CONTAINS_IMMUTABLE_ROOTS,
PackageType.CONTENT, "/apps/test")));
+
// validate sub packages of type Content
PackageTypeValidator subPackageValidator = new
PackageTypeValidator(filter, ValidationMessageSeverity.ERROR,
ValidationMessageSeverity.WARN, ValidationMessageSeverity.INFO, false, false,
false, false, PackageType.CONTENT,
PackageTypeValidatorFactory.DEFAULT_JCR_INSTALLER_NODE_PATH_REGEX,
PackageTypeValidatorFactory.DEFAULT_JCR_INSTALLER_ADDITIONAL_FILE_NODE_PATH_REGEX,
PackageTypeValidatorFactory.DEFAULT_IMMUTABLE_ROOT_NODE_NAMES,
parentContainerContext);
MatcherAssert.assertThat(subPackageValidator.validate(properties),
AnyValidationViolationMessageMatcher.noValidationViolationMessageInCollection());
Review Comment:
[nitpick] Consider creating a new instance of DefaultWorkspaceFilter for
each test scenario to avoid potential state contamination across test blocks.
```suggestion
try (InputStream input =
this.getClass().getResourceAsStream("/filter-with-mutable-and-immutable-roots.xml"))
{
DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
filter.load(input);
ValidationExecutorTest.assertViolation(validator.validate(filter), new
ValidationMessage(ValidationMessageSeverity.ERROR,
String.format(PackageTypeValidator.MESSAGE_FILTER_CONTAINS_IMMUTABLE_ROOTS,
PackageType.CONTENT, "/apps/test")));
// validate sub packages of type Content
PackageTypeValidator subPackageValidator = new
PackageTypeValidator(filter, ValidationMessageSeverity.ERROR,
ValidationMessageSeverity.WARN, ValidationMessageSeverity.INFO, false, false,
false, false, PackageType.CONTENT,
PackageTypeValidatorFactory.DEFAULT_JCR_INSTALLER_NODE_PATH_REGEX,
PackageTypeValidatorFactory.DEFAULT_JCR_INSTALLER_ADDITIONAL_FILE_NODE_PATH_REGEX,
PackageTypeValidatorFactory.DEFAULT_IMMUTABLE_ROOT_NODE_NAMES,
parentContainerContext);
MatcherAssert.assertThat(subPackageValidator.validate(properties),
AnyValidationViolationMessageMatcher.noValidationViolationMessageInCollection());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]