InstanceDescriptor { public LoadState isLoaded() { boolean unknownFound = false; for (Map.Entry<FieldSpecification<? super T, ?>, LoadState> e : loadState.entrySet()) { if (e.getKey().getFetchType() == FetchType.LAZY) { continue; } if (e.getValue() == LoadState.NOT_LOADED) { return LoadState.NOT_LOADED; } else if (e.getValue() == LoadState.UNKNOWN) { unknownFound = true; } } return unknownFound ? LoadState.UNKNOWN : LoadState.LOADED; } InstanceDescriptor(T instance, EntityType<T> et);   InstanceDescriptor(T instance, InstanceDescriptor<T> other); LoadState isLoaded(); LoadState isLoaded(FieldSpecification<?, ?> attribute); Object getInstance(); void setLoaded(FieldSpecification<? super T, ?> fs, LoadState state); @Override String toString();  }
@Test void constructorInitializesAllDataPropertyAttributesAsNotLoaded() { final OWLClassM instance = new OWLClassM(); final InstanceDescriptor<OWLClassM> sut = new InstanceDescriptor<>(instance, metamodelMocks.forOwlClassM().entityType()); metamodelMocks.forOwlClassM().entityType().getAttributes() .forEach(fs -> assertEquals(LoadState.NOT_LOADED, sut.isLoaded(fs))); }
@Test void constructorSetsIdentifierAsLoaded() { final OWLClassM instance = new OWLClassM(); final InstanceDescriptor<OWLClassM> sut = new InstanceDescriptor<>(instance, metamodelMocks.forOwlClassM().entityType()); assertEquals(LoadState.LOADED, sut.isLoaded(metamodelMocks.forOwlClassM().identifier())); }