|
76 | 76 | import static org.hamcrest.Matchers.instanceOf;
|
77 | 77 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
78 | 78 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
| 79 | +import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
79 | 80 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
80 | 81 | import static org.junit.jupiter.api.Assertions.assertNull;
|
81 | 82 | import static org.junit.jupiter.api.Assertions.assertSame;
|
@@ -381,7 +382,7 @@ void deserializationSupportsPolymorphismForAttributes() throws Exception {
|
381 | 382 | this.sut = JsonLdDeserializer.createExpandedDeserializer(config);
|
382 | 383 | final JsonArray input = readAndExpand("objectWithSingularPolymorphicReference.json");
|
383 | 384 | final PolymorphicPerson result = sut.deserialize(input, PolymorphicPerson.class);
|
384 |
| - assertTrue(result.friend instanceof Employee); |
| 385 | + assertInstanceOf(Employee.class, result.friend); |
385 | 386 | }
|
386 | 387 |
|
387 | 388 | @OWLClass(iri = Vocabulary.PERSON)
|
@@ -847,4 +848,19 @@ void deserializeSupportsMappingIndividualToEnumConstant() throws Exception {
|
847 | 848 | assertThat(result.getPluralPropertyType(),
|
848 | 849 | hasItems(OwlPropertyType.ANNOTATION_PROPERTY, OwlPropertyType.OBJECT_PROPERTY));
|
849 | 850 | }
|
| 851 | + |
| 852 | + @Test |
| 853 | + void deserializationUsesProvidedTargetTypeWhenNoTypeIsSpecifiedTypeAssumingIsEnabledAndObjectHasOnlyId() throws Exception { |
| 854 | + final Configuration config = new Configuration(); |
| 855 | + config.set(ConfigParam.ASSUME_TARGET_TYPE, Boolean.TRUE.toString()); |
| 856 | + config.set(ConfigParam.SCAN_PACKAGE, "cz.cvut.kbss.jsonld"); |
| 857 | + this.sut = ExpandedJsonLdDeserializer.createExpandedDeserializer(config); |
| 858 | + final JsonArray input = readAndExpand("objectWithSingularReferenceWithIdOnly.json"); |
| 859 | + final Employee result = sut.deserialize(input, Employee.class); |
| 860 | + assertNotNull(result); |
| 861 | + verifyUserAttributes(USERS.get(HALSEY_URI), result); |
| 862 | + assertNotNull(result.getEmployer()); |
| 863 | + assertEquals(TestUtil.UNSC_URI, result.getEmployer().getUri()); |
| 864 | + assertNull(result.getEmployer().getName()); |
| 865 | + } |
850 | 866 | }
|
0 commit comments