@Test void testValidateEntitiesNotReferencedByIdValidationException() { Attribute attribute = createMockAttribute(AttributeType.MREF, "id0,id1"); initializeDataServiceMock(Stream.of(attribute)); Exception exception = assertThrows( MolgenisValidationException.class, () -> defaultValueReferenceValidator .validateEntitiesNotReferencedById(Stream.of("id1"), entityType) .count()); assertThat(exception.getMessage()) .containsPattern( "'My Entity Type' with id 'id1' is referenced as default value by attribute\\(s\\): 'myAttribute'"); }
@Override public Stream<Object> validateEntitiesNotReferencedById( Stream<Object> entityIdStream, EntityType entityType) { Multimap<String, Attribute> defaultValueMap = getDefaultValueMap(entityType); return entityIdStream.filter( entityId -> { validateEntityNotReferenced(entityId, entityType, defaultValueMap); return true; }); }
DefaultValueReferenceValidatorImpl implements DefaultValueReferenceValidator { @Override public Stream<Object> validateEntitiesNotReferencedById( Stream<Object> entityIdStream, EntityType entityType) { Multimap<String, Attribute> defaultValueMap = getDefaultValueMap(entityType); return entityIdStream.filter( entityId -> { validateEntityNotReferenced(entityId, entityType, defaultValueMap); return true; }); } }
DefaultValueReferenceValidatorImpl implements DefaultValueReferenceValidator { @Override public Stream<Object> validateEntitiesNotReferencedById( Stream<Object> entityIdStream, EntityType entityType) { Multimap<String, Attribute> defaultValueMap = getDefaultValueMap(entityType); return entityIdStream.filter( entityId -> { validateEntityNotReferenced(entityId, entityType, defaultValueMap); return true; }); } DefaultValueReferenceValidatorImpl(DataService dataService); }
DefaultValueReferenceValidatorImpl implements DefaultValueReferenceValidator { @Override public Stream<Object> validateEntitiesNotReferencedById( Stream<Object> entityIdStream, EntityType entityType) { Multimap<String, Attribute> defaultValueMap = getDefaultValueMap(entityType); return entityIdStream.filter( entityId -> { validateEntityNotReferenced(entityId, entityType, defaultValueMap); return true; }); } DefaultValueReferenceValidatorImpl(DataService dataService); @Override void validateEntityNotReferenced(Entity entity); @Override Stream<Entity> validateEntitiesNotReferenced(
      Stream<Entity> entityStream, EntityType entityType); @Override void validateEntityNotReferencedById(Object entityId, EntityType entityType); @Override Stream<Object> validateEntitiesNotReferencedById(
      Stream<Object> entityIdStream, EntityType entityType); @Override void validateEntityTypeNotReferenced(EntityType entityType); }
DefaultValueReferenceValidatorImpl implements DefaultValueReferenceValidator { @Override public Stream<Object> validateEntitiesNotReferencedById( Stream<Object> entityIdStream, EntityType entityType) { Multimap<String, Attribute> defaultValueMap = getDefaultValueMap(entityType); return entityIdStream.filter( entityId -> { validateEntityNotReferenced(entityId, entityType, defaultValueMap); return true; }); } DefaultValueReferenceValidatorImpl(DataService dataService); @Override void validateEntityNotReferenced(Entity entity); @Override Stream<Entity> validateEntitiesNotReferenced(
      Stream<Entity> entityStream, EntityType entityType); @Override void validateEntityNotReferencedById(Object entityId, EntityType entityType); @Override Stream<Object> validateEntitiesNotReferencedById(
      Stream<Object> entityIdStream, EntityType entityType); @Override void validateEntityTypeNotReferenced(EntityType entityType);  }