@Test void testValidateExtendsNonAbstract() { when(entityType.getExtends()).thenReturn(parent); when(parent.isAbstract()).thenReturn(false); when(entityType.getId()).thenReturn("entity"); when(parent.getId()).thenReturn("parent"); Exception exception = assertThrows( MolgenisValidationException.class, () -> EntityTypeValidator.validateExtends(entityType)); assertThat(exception.getMessage()) .containsPattern( "EntityType \\[parent\\] is not abstract; EntityType \\[entity\\] can't extend it"); }
static void validateExtends(EntityType entityType) { EntityType entityTypeExtends = entityType.getExtends(); if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] is not abstract; EntityType [%s] can't extend it", entityTypeExtends.getId(), entityType.getId()))); } }
EntityTypeValidator { static void validateExtends(EntityType entityType) { EntityType entityTypeExtends = entityType.getExtends(); if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] is not abstract; EntityType [%s] can't extend it", entityTypeExtends.getId(), entityType.getId()))); } } }
EntityTypeValidator { static void validateExtends(EntityType entityType) { EntityType entityTypeExtends = entityType.getExtends(); if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] is not abstract; EntityType [%s] can't extend it", entityTypeExtends.getId(), entityType.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); }
EntityTypeValidator { static void validateExtends(EntityType entityType) { EntityType entityTypeExtends = entityType.getExtends(); if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] is not abstract; EntityType [%s] can't extend it", entityTypeExtends.getId(), entityType.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); void validate(EntityType entityType); }
EntityTypeValidator { static void validateExtends(EntityType entityType) { EntityType entityTypeExtends = entityType.getExtends(); if (entityTypeExtends != null && !entityTypeExtends.isAbstract()) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] is not abstract; EntityType [%s] can't extend it", entityTypeExtends.getId(), entityType.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); void validate(EntityType entityType);  }