-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1290 from b2ihealthcare/feature/SO-6106-subproper…
…ty-of-support-9x SO-6106: "Sub...PropertyOf" support for axiom-relationship conversions (9.x)
- Loading branch information
Showing
6 changed files
with
197 additions
and
4 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
66 changes: 66 additions & 0 deletions
66
...om/b2international/snowowl/snomed/datastore/request/SnomedOWLExpressionConverterTest.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,66 @@ | ||
/* | ||
* Copyright 2024 B2i Healthcare Ltd, http://b2ihealthcare.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.b2international.snowowl.snomed.datastore.request; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.List; | ||
|
||
import org.elasticsearch.core.Set; | ||
import org.junit.Test; | ||
|
||
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts; | ||
import com.b2international.snowowl.snomed.datastore.index.entry.SnomedOWLRelationshipDocument; | ||
import com.google.common.collect.Iterables; | ||
|
||
/** | ||
* @since 7.24.3 | ||
*/ | ||
public class SnomedOWLExpressionConverterTest { | ||
|
||
@Test | ||
public void testSubObjectPropertyOf() { | ||
testSubPropertyOf("SubObjectPropertyOf"); | ||
} | ||
|
||
@Test | ||
public void testSubDataPropertyOf() { | ||
testSubPropertyOf("SubDataPropertyOf"); | ||
} | ||
|
||
@Test | ||
public void testSubAnnotationPropertyOf() { | ||
testSubPropertyOf("SubAnnotationPropertyOf"); | ||
} | ||
|
||
private void testSubPropertyOf(String subPropertyOfAxiom) { | ||
SnomedOWLExpressionConverter converter = new SnomedOWLExpressionConverter(() -> Set.of()); | ||
|
||
// XXX: Using nonsensical but valid SCTIDs | ||
SnomedOWLExpressionConverterResult converterResult = converter.toSnomedOWLRelationships( | ||
Concepts.FINDING_SITE, | ||
String.format("%s(:%s :%s)", subPropertyOfAxiom, Concepts.FINDING_SITE, Concepts.AMBIGUOUS)); | ||
|
||
assertNull(converterResult.getGciAxiomRelationships()); | ||
|
||
final List<SnomedOWLRelationshipDocument> relationships = converterResult.getClassAxiomRelationships(); | ||
assertEquals(1, relationships.size()); | ||
|
||
final SnomedOWLRelationshipDocument relationship = Iterables.getOnlyElement(relationships); | ||
assertEquals(Concepts.IS_A, relationship.getTypeId()); | ||
assertEquals(Concepts.AMBIGUOUS, relationship.getDestinationId()); | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
.../b2international/snowowl/snomed/datastore/request/SnomedOWLRelationshipConverterTest.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,106 @@ | ||
/* | ||
* Copyright 2024 B2i Healthcare Ltd, http://b2ihealthcare.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.b2international.snowowl.snomed.datastore.request; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.elasticsearch.core.Set; | ||
import org.junit.Test; | ||
|
||
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts; | ||
import com.b2international.snowowl.snomed.datastore.index.entry.SnomedOWLRelationshipDocument; | ||
|
||
/** | ||
* @since 7.24.3 | ||
*/ | ||
public class SnomedOWLRelationshipConverterTest { | ||
|
||
@Test | ||
public void testSubClassOf() { | ||
testSubPropertyOf( | ||
"SubClassOf", | ||
Set.of(), | ||
Set.of(), | ||
Set.of(), | ||
Concepts.DEVICE | ||
); | ||
} | ||
|
||
@Test | ||
public void testSubObjectPropertyOf() { | ||
testSubPropertyOf( | ||
"SubObjectPropertyOf", | ||
Set.of(Long.parseLong(Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE)), | ||
Set.of(), | ||
Set.of(), | ||
Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE | ||
); | ||
} | ||
|
||
@Test | ||
public void testSubDataPropertyOf() { | ||
testSubPropertyOf( | ||
"SubDataPropertyOf", | ||
Set.of(), | ||
Set.of(Long.parseLong(Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE)), | ||
Set.of(), | ||
Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE | ||
); | ||
} | ||
|
||
@Test | ||
public void testSubAnnotationPropertyOf() { | ||
testSubPropertyOf( | ||
"SubAnnotationPropertyOf", | ||
Set.of(), | ||
Set.of(), | ||
Set.of(Long.parseLong(Concepts.ANNOTATION_ATTRIBUTE)), | ||
Concepts.ANNOTATION_ATTRIBUTE | ||
); | ||
} | ||
|
||
private void testSubPropertyOf( | ||
String subPropertyOfAxiom, | ||
Collection<Long> objectAttributes, | ||
Collection<Long> dataAttributes, | ||
Collection<Long> annotationAttributes, | ||
String destinationId | ||
) { | ||
SnomedOWLRelationshipConverter converter = new SnomedOWLRelationshipConverter( | ||
Set.of(), | ||
objectAttributes, | ||
dataAttributes, | ||
annotationAttributes); | ||
|
||
// XXX: Using nonsensical but valid SCTIDs | ||
final List<SnomedOWLRelationshipDocument> owlRelationships = List.of( | ||
SnomedOWLRelationshipDocument.create(Concepts.IS_A, destinationId, 0) | ||
); | ||
|
||
final String expectedExpression = String.format("%s(:%s :%s)", subPropertyOfAxiom, Concepts.FINDING_SITE, destinationId); | ||
final String actualExpression = converter.fromSnomedOwlRelationships( | ||
false, | ||
true, | ||
Concepts.FINDING_SITE, | ||
owlRelationships | ||
); | ||
|
||
assertEquals(expectedExpression, actualExpression); | ||
} | ||
} |
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