-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Language tag specification support - pass language tag to axiom value…
… descriptor on JOPA level.
- Loading branch information
Showing
8 changed files
with
172 additions
and
25 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
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
72 changes: 72 additions & 0 deletions
72
jopa-impl/src/test/java/cz/cvut/kbss/jopa/oom/SingularDataPropertyStrategyTest.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,72 @@ | ||
package cz.cvut.kbss.jopa.oom; | ||
|
||
import cz.cvut.kbss.jopa.environment.OWLClassA; | ||
import cz.cvut.kbss.jopa.environment.utils.Generators; | ||
import cz.cvut.kbss.jopa.environment.utils.MetamodelMocks; | ||
import cz.cvut.kbss.jopa.model.JOPAPersistenceProperties; | ||
import cz.cvut.kbss.jopa.model.descriptors.Descriptor; | ||
import cz.cvut.kbss.jopa.model.descriptors.EntityDescriptor; | ||
import cz.cvut.kbss.jopa.utils.Configuration; | ||
import cz.cvut.kbss.ontodriver.descriptor.AxiomValueDescriptor; | ||
import cz.cvut.kbss.ontodriver.model.Assertion; | ||
import cz.cvut.kbss.ontodriver.model.NamedResource; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import java.net.URI; | ||
import java.util.Collections; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class SingularDataPropertyStrategyTest { | ||
|
||
private static final URI PK = Generators.createIndividualIdentifier(); | ||
|
||
@Mock | ||
private EntityMappingHelper mapperMock; | ||
|
||
private MetamodelMocks mocks; | ||
|
||
private Descriptor descriptor = new EntityDescriptor(); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
MockitoAnnotations.initMocks(this); | ||
final Configuration configuration = new Configuration( | ||
Collections.singletonMap(JOPAPersistenceProperties.LANG, "en")); | ||
when(mapperMock.getConfiguration()).thenReturn(configuration); | ||
this.mocks = new MetamodelMocks(); | ||
} | ||
|
||
@Test | ||
public void buildAxiomsSetsLanguageTagAccordingToDescriptorLanguage() throws Exception { | ||
descriptor.setLanguage("en"); | ||
buildAxiomsAndVerifyLanguageTag(); | ||
} | ||
|
||
private void buildAxiomsAndVerifyLanguageTag() throws Exception { | ||
final SingularDataPropertyStrategy<OWLClassA> strategy = new SingularDataPropertyStrategy<>( | ||
mocks.forOwlClassA().entityType(), mocks.forOwlClassA().stringAttribute(), descriptor, mapperMock); | ||
final OWLClassA a = new OWLClassA(); | ||
a.setUri(PK); | ||
a.setStringAttribute("english"); | ||
|
||
final AxiomValueGatherer builder = new AxiomValueGatherer(NamedResource.create(PK), null); | ||
strategy.buildAxiomValuesFromInstance(a, builder); | ||
final AxiomValueDescriptor valueDescriptor = OOMTestUtils.getAxiomValueDescriptor(builder); | ||
assertEquals(1, valueDescriptor.getAssertions().size()); | ||
final Assertion assertion = valueDescriptor.getAssertions().iterator().next(); | ||
assertTrue(assertion.hasLanguage()); | ||
assertEquals("en", assertion.getLanguage()); | ||
} | ||
|
||
@Test | ||
public void buildAxiomsSetsLanguageTagAccordingToPUConfigurationWhenItIsNotSpecifiedInDescriptor() | ||
throws Exception { | ||
buildAxiomsAndVerifyLanguageTag(); | ||
} | ||
} |