-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement #54] Minor code cleanup, add some tests.
- Loading branch information
Showing
5 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...kbss/jsonld/serialization/serializer/context/ContextBuildingIndividualSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cz.cvut.kbss.jsonld.serialization.serializer.context; | ||
|
||
import cz.cvut.kbss.jopa.vocabulary.OWL; | ||
import cz.cvut.kbss.jsonld.ConfigParam; | ||
import cz.cvut.kbss.jsonld.Configuration; | ||
import cz.cvut.kbss.jsonld.environment.Generator; | ||
import cz.cvut.kbss.jsonld.environment.Vocabulary; | ||
import cz.cvut.kbss.jsonld.environment.model.OwlPropertyType; | ||
import cz.cvut.kbss.jsonld.serialization.context.DummyJsonLdContext; | ||
import cz.cvut.kbss.jsonld.serialization.model.JsonNode; | ||
import cz.cvut.kbss.jsonld.serialization.model.StringLiteralNode; | ||
import cz.cvut.kbss.jsonld.serialization.traversal.SerializationContext; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.URI; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class ContextBuildingIndividualSerializerTest { | ||
|
||
private final ContextBuildingIndividualSerializer sut = new ContextBuildingIndividualSerializer(); | ||
|
||
@Test | ||
void serializeSerializesUriValueAsStringWhenSerializationWithExtendedTermDefinitionInContextIsEnabled() { | ||
final URI individual = Generator.generateUri(); | ||
final SerializationContext<URI> ctx = | ||
new SerializationContext<>(Vocabulary.ORIGIN, individual, DummyJsonLdContext.INSTANCE); | ||
final Configuration config = new Configuration(); | ||
config.set(ConfigParam.SERIALIZE_INDIVIDUALS_USING_EXPANDED_DEFINITION, Boolean.TRUE.toString()); | ||
|
||
sut.configure(config); | ||
final JsonNode result = sut.serialize(individual, ctx); | ||
assertInstanceOf(StringLiteralNode.class, result); | ||
final StringLiteralNode node = (StringLiteralNode) result; | ||
assertEquals(individual.toString(), node.getValue()); | ||
} | ||
|
||
@Test | ||
void serializeSerializesEnumValueMappedToIndividualAsStringWhenSerializationWithExtendedTermDefinitionInContextIsEnabled() { | ||
final OwlPropertyType value = OwlPropertyType.OBJECT_PROPERTY; | ||
final SerializationContext<OwlPropertyType> ctx = | ||
new SerializationContext<>(Vocabulary.HAS_PROPERTY_TYPE, value, DummyJsonLdContext.INSTANCE); | ||
final Configuration config = new Configuration(); | ||
config.set(ConfigParam.SERIALIZE_INDIVIDUALS_USING_EXPANDED_DEFINITION, Boolean.TRUE.toString()); | ||
|
||
sut.configure(config); | ||
final JsonNode result = sut.serialize(value, ctx); | ||
assertInstanceOf(StringLiteralNode.class, result); | ||
final StringLiteralNode node = (StringLiteralNode) result; | ||
assertEquals(OWL.OBJECT_PROPERTY, node.getValue()); | ||
} | ||
} |