@Test void testValidateSystemPackageInvalid() { when(entityType.getId()).thenReturn("entity"); when(entityType.getPackage()).thenReturn(aPackage); when(aPackage.getId()).thenReturn(PACKAGE_SYSTEM); when(systemEntityTypeRegistry.hasSystemEntityType("entity")).thenReturn(false); Exception exception = assertThrows( MolgenisValidationException.class, () -> entityTypeValidator.validatePackage(entityType)); assertThat(exception.getMessage()) .containsPattern("Adding entity \\[entity\\] to system package \\[sys\\] is not allowed"); }
void validatePackage(EntityType entityType) { Package pack = entityType.getPackage(); if (pack != null && isSystemPackage(pack) && !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) { throw new MolgenisValidationException( new ConstraintViolation( format( "Adding entity [%s] to system package [%s] is not allowed", entityType.getId(), pack.getId()))); } }
EntityTypeValidator { void validatePackage(EntityType entityType) { Package pack = entityType.getPackage(); if (pack != null && isSystemPackage(pack) && !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) { throw new MolgenisValidationException( new ConstraintViolation( format( "Adding entity [%s] to system package [%s] is not allowed", entityType.getId(), pack.getId()))); } } }
EntityTypeValidator { void validatePackage(EntityType entityType) { Package pack = entityType.getPackage(); if (pack != null && isSystemPackage(pack) && !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) { throw new MolgenisValidationException( new ConstraintViolation( format( "Adding entity [%s] to system package [%s] is not allowed", entityType.getId(), pack.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); }
EntityTypeValidator { void validatePackage(EntityType entityType) { Package pack = entityType.getPackage(); if (pack != null && isSystemPackage(pack) && !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) { throw new MolgenisValidationException( new ConstraintViolation( format( "Adding entity [%s] to system package [%s] is not allowed", entityType.getId(), pack.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); void validate(EntityType entityType); }
EntityTypeValidator { void validatePackage(EntityType entityType) { Package pack = entityType.getPackage(); if (pack != null && isSystemPackage(pack) && !systemEntityTypeRegistry.hasSystemEntityType(entityType.getId())) { throw new MolgenisValidationException( new ConstraintViolation( format( "Adding entity [%s] to system package [%s] is not allowed", entityType.getId(), pack.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); void validate(EntityType entityType);  }