Skip to content

Commit 8b28170

Browse files
committed
Test reading the entire LinkML meta-schema.
Now that we have a bundled copy of the entire LinkML meta-schema, we can try reading it as part of the test suite.
1 parent 96b2c02 commit 8b28170

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

ext/src/test/java/org/incenp/linkml/schema/SchemaDocumentTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import java.io.File;
3838
import java.io.IOException;
39+
import java.util.HashMap;
3940

4041
import org.incenp.linkml.schema.model.ClassDefinition;
4142
import org.incenp.linkml.schema.model.Prefix;
@@ -221,4 +222,38 @@ void testFailOnInvalidReferences() {
221222
e.getCause().getMessage());
222223
}
223224
}
225+
226+
@Test
227+
void testReadLinkMLMetaSchema() {
228+
SchemaDocument doc = null;
229+
try {
230+
doc = new SchemaDocument(new File("src/main/resources/schemas/linkml/meta.yaml"));
231+
} catch ( IOException e ) {
232+
Assertions.fail("Unexpected exception", e);
233+
} catch ( InvalidSchemaException e ) {
234+
Assertions.fail("Cannot read LinkML meta-schema", e);
235+
}
236+
237+
Assertions.assertEquals(5, doc.getImports().size());
238+
239+
HashMap<String, SlotDefinition> slots = new HashMap<>();
240+
for ( SlotDefinition sd : doc.getAllSlots() ) {
241+
slots.put(sd.getName(), sd);
242+
}
243+
HashMap<String, ClassDefinition> classes = new HashMap<>();
244+
for ( ClassDefinition cd : doc.getAllClasses() ) {
245+
classes.put(cd.getName(), cd);
246+
}
247+
248+
SlotDefinition annotationSlot = slots.get("annotations");
249+
Assertions.assertNotNull(annotationSlot);
250+
Assertions.assertEquals("extensions", annotationSlot.getIsA().getName());
251+
Assertions.assertEquals("annotatable", annotationSlot.getDomain().getName());
252+
Assertions.assertTrue(annotationSlot.getMultivalued());
253+
254+
ClassDefinition annotatableClass = classes.get("annotatable");
255+
Assertions.assertNotNull(annotatableClass);
256+
Assertions.assertTrue(annotatableClass.getMixin());
257+
Assertions.assertTrue(annotationSlot.getDomain() == annotatableClass);
258+
}
224259
}

0 commit comments

Comments
 (0)