|
6 | 6 | import com.fasterxml.jackson.databind.node.ObjectNode;
|
7 | 7 |
|
8 | 8 | import edu.kit.datamanager.ro_crate.HelpFunctions;
|
| 9 | +import edu.kit.datamanager.ro_crate.entities.AbstractEntity; |
9 | 10 | import edu.kit.datamanager.ro_crate.entities.contextual.ContextualEntity;
|
10 | 11 | import edu.kit.datamanager.ro_crate.entities.data.DataEntity;
|
11 | 12 | import edu.kit.datamanager.ro_crate.objectmapper.MyObjectMapper;
|
@@ -190,4 +191,37 @@ void creationFromUrlAndPairsTest() {
|
190 | 191 | // house is in the context
|
191 | 192 | assertTrue(newContext.checkEntity(data));
|
192 | 193 | }
|
| 194 | + |
| 195 | + @Test |
| 196 | + void testIdType() { |
| 197 | + AbstractEntity validEntity = new DataEntity.DataEntityBuilder() |
| 198 | + .setId("Airline") // this is defined in the context! |
| 199 | + .addType("@id") // this is a JSON-LD feature to refer to the ID ("Airline") as a type |
| 200 | + .addType("@json") // this is a JSON-LD built-in type |
| 201 | + .build(); |
| 202 | + assertTrue(this.context.checkEntity(validEntity)); |
| 203 | + |
| 204 | + AbstractEntity invalidEntity = new DataEntity.DataEntityBuilder() |
| 205 | + .setId("Something which is definitely not in the context") |
| 206 | + .addType("@id") |
| 207 | + .build(); |
| 208 | + assertFalse(this.context.checkEntity(invalidEntity)); |
| 209 | + } |
| 210 | + |
| 211 | + @Test |
| 212 | + void testJsonType() { |
| 213 | + AbstractEntity validEntity = new DataEntity.DataEntityBuilder() |
| 214 | + .addType("@json") // this is a JSON-LD built-in type |
| 215 | + .build(); |
| 216 | + assertTrue(this.context.checkEntity(validEntity)); |
| 217 | + } |
| 218 | + |
| 219 | + @Test |
| 220 | + void testAbsoluteUrlType() { |
| 221 | + AbstractEntity validEntity = new DataEntity.DataEntityBuilder() |
| 222 | + .addType("http://example.org/Person") // this is not in the context! |
| 223 | + .addProperty("http://example.org/Thing", "Some thing") |
| 224 | + .build(); |
| 225 | + assertTrue(this.context.checkEntity(validEntity)); |
| 226 | + } |
193 | 227 | }
|
0 commit comments