Skip to content

Commit c339a8a

Browse files
committed
[Enhancement #69] Add acceptance test.
1 parent 67eb895 commit c339a8a

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/test/java/cz/cvut/kbss/jsonld/deserialization/expanded/ExpandedJsonLdDeserializerTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import static org.hamcrest.Matchers.instanceOf;
7777
import static org.junit.jupiter.api.Assertions.assertEquals;
7878
import static org.junit.jupiter.api.Assertions.assertFalse;
79+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
7980
import static org.junit.jupiter.api.Assertions.assertNotNull;
8081
import static org.junit.jupiter.api.Assertions.assertNull;
8182
import static org.junit.jupiter.api.Assertions.assertSame;
@@ -381,7 +382,7 @@ void deserializationSupportsPolymorphismForAttributes() throws Exception {
381382
this.sut = JsonLdDeserializer.createExpandedDeserializer(config);
382383
final JsonArray input = readAndExpand("objectWithSingularPolymorphicReference.json");
383384
final PolymorphicPerson result = sut.deserialize(input, PolymorphicPerson.class);
384-
assertTrue(result.friend instanceof Employee);
385+
assertInstanceOf(Employee.class, result.friend);
385386
}
386387

387388
@OWLClass(iri = Vocabulary.PERSON)
@@ -847,4 +848,19 @@ void deserializeSupportsMappingIndividualToEnumConstant() throws Exception {
847848
assertThat(result.getPluralPropertyType(),
848849
hasItems(OwlPropertyType.ANNOTATION_PROPERTY, OwlPropertyType.OBJECT_PROPERTY));
849850
}
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+
}
850866
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"@context": {
3+
"firstName": "http://xmlns.com/foaf/0.1/firstName",
4+
"lastName": "http://xmlns.com/foaf/0.1/lastName",
5+
"accountName": "http://xmlns.com/foaf/0.1/accountName",
6+
"isAdmin": "http://krizik.felk.cvut.cz/ontologies/jb4jsonld/isAdmin"
7+
},
8+
"@id": "http://krizik.felk.cvut.cz/ontologies/jb4jsonld#Catherine+Halsey",
9+
"@type": [
10+
"http://onto.fel.cvut.cz/ontologies/ufo/Person",
11+
"http://krizik.felk.cvut.cz/ontologies/jb4jsonld/Employee",
12+
"http://krizik.felk.cvut.cz/ontologies/jb4jsonld/User",
13+
"http://krizik.felk.cvut.cz/ontologies/jb4jsonld/GenericMember"
14+
],
15+
"isAdmin": true,
16+
"http://krizik.felk.cvut.cz/ontologies/jb4jsonld/isMemberOf": {
17+
"@id": "http://krizik.felk.cvut.cz/ontologies/jb4jsonld#UNSC"
18+
},
19+
"accountName": "[email protected]",
20+
"firstName": "Catherine",
21+
"lastName": "Halsey"
22+
}

0 commit comments

Comments
 (0)