@Test void testValidateLabelAttributeHidden() { when(entityType.getLabelAttribute()).thenReturn(labelAttr); when(labelAttr.isVisible()).thenReturn(false); when(entityType.getId()).thenReturn("entity"); when(labelAttr.getName()).thenReturn("labelAttr"); Exception exception = assertThrows( MolgenisValidationException.class, () -> EntityTypeValidator.validateLabelAttribute(entityType)); assertThat(exception.getMessage()) .containsPattern( "Label attribute \\[labelAttr\\] of EntityType \\[entity\\] must be visible."); }
static void validateLabelAttribute(EntityType entityType) { if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) { throw new MolgenisValidationException( new ConstraintViolation( format( "Label attribute [%s] of EntityType [%s] must be visible.", entityType.getLabelAttribute().getName(), entityType.getId()))); } if (!entityType.isAbstract() && !entityType.getIdAttribute().isVisible() && (entityType.getLabelAttribute() == null)) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] must define a label attribute because the identifier is hidden", entityType.getId()))); } }
EntityTypeValidator { static void validateLabelAttribute(EntityType entityType) { if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) { throw new MolgenisValidationException( new ConstraintViolation( format( "Label attribute [%s] of EntityType [%s] must be visible.", entityType.getLabelAttribute().getName(), entityType.getId()))); } if (!entityType.isAbstract() && !entityType.getIdAttribute().isVisible() && (entityType.getLabelAttribute() == null)) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] must define a label attribute because the identifier is hidden", entityType.getId()))); } } }
EntityTypeValidator { static void validateLabelAttribute(EntityType entityType) { if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) { throw new MolgenisValidationException( new ConstraintViolation( format( "Label attribute [%s] of EntityType [%s] must be visible.", entityType.getLabelAttribute().getName(), entityType.getId()))); } if (!entityType.isAbstract() && !entityType.getIdAttribute().isVisible() && (entityType.getLabelAttribute() == null)) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] must define a label attribute because the identifier is hidden", entityType.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); }
EntityTypeValidator { static void validateLabelAttribute(EntityType entityType) { if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) { throw new MolgenisValidationException( new ConstraintViolation( format( "Label attribute [%s] of EntityType [%s] must be visible.", entityType.getLabelAttribute().getName(), entityType.getId()))); } if (!entityType.isAbstract() && !entityType.getIdAttribute().isVisible() && (entityType.getLabelAttribute() == null)) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] must define a label attribute because the identifier is hidden", entityType.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); void validate(EntityType entityType); }
EntityTypeValidator { static void validateLabelAttribute(EntityType entityType) { if (entityType.getLabelAttribute() != null && !entityType.getLabelAttribute().isVisible()) { throw new MolgenisValidationException( new ConstraintViolation( format( "Label attribute [%s] of EntityType [%s] must be visible.", entityType.getLabelAttribute().getName(), entityType.getId()))); } if (!entityType.isAbstract() && !entityType.getIdAttribute().isVisible() && (entityType.getLabelAttribute() == null)) { throw new MolgenisValidationException( new ConstraintViolation( format( "EntityType [%s] must define a label attribute because the identifier is hidden", entityType.getId()))); } } EntityTypeValidator(DataService dataService, SystemEntityTypeRegistry systemEntityTypeRegistry); void validate(EntityType entityType);  }