@SuppressWarnings("deprecation") @Test void testValidateSystemPackageNotInRegistry() { Package package_ = when(mock(Package.class).getId()).thenReturn(PACKAGE_SYSTEM + '_' + "myPackage").getMock(); when(package_.getParent()).thenReturn(systemPackage); when(package_.getRootPackage()).thenReturn(systemPackage); when(systemPackageRegistry.containsPackage(package_)).thenReturn(false); Exception exception = assertThrows( MolgenisValidationException.class, () -> packageValidator.validate(package_, ValidationMode.ADD)); assertThat(exception.getMessage()).containsPattern("Modifying system packages is not allowed"); }
public void validate(Package aPackage, ValidationMode validationMode) { validatePackageAllowed(aPackage, validationMode); runAsSystem(() -> validatePackageParent(aPackage)); }
PackageValidator { public void validate(Package aPackage, ValidationMode validationMode) { validatePackageAllowed(aPackage, validationMode); runAsSystem(() -> validatePackageParent(aPackage)); } }
PackageValidator { public void validate(Package aPackage, ValidationMode validationMode) { validatePackageAllowed(aPackage, validationMode); runAsSystem(() -> validatePackageParent(aPackage)); } PackageValidator(SystemPackageRegistry systemPackageRegistry); }
PackageValidator { public void validate(Package aPackage, ValidationMode validationMode) { validatePackageAllowed(aPackage, validationMode); runAsSystem(() -> validatePackageParent(aPackage)); } PackageValidator(SystemPackageRegistry systemPackageRegistry); void validate(Package aPackage, ValidationMode validationMode); }
PackageValidator { public void validate(Package aPackage, ValidationMode validationMode) { validatePackageAllowed(aPackage, validationMode); runAsSystem(() -> validatePackageParent(aPackage)); } PackageValidator(SystemPackageRegistry systemPackageRegistry); void validate(Package aPackage, ValidationMode validationMode);  }