@SuppressWarnings("deprecation") @Test void testValidatePackageParentParentIsSelf() { Package aPackage = when(mock(Package.class).getId()).thenReturn("child").getMock(); when(aPackage.getLabel()).thenReturn("Child"); when(aPackage.getParent()).thenReturn(aPackage); Exception exception = assertThrows( MolgenisValidationException.class, () -> packageValidator.validate(aPackage, ValidationMode.ADD)); assertThat(exception.getMessage()) .containsPattern("Package 'Child' with id 'child' parent contains cycles"); }
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);  }