use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberParameterizedTest method rejectNonExistentRefSetId.
@Test
public void rejectNonExistentRefSetId() throws Exception {
String refSetId = reserveComponentId(null, ComponentCategory.CONCEPT);
String referencedComponentId = createReferencedComponent(branchPath, refSetType);
Json requestBody = createRefSetMemberRequestBody(refSetId, referencedComponentId).with(getValidProperties(refSetType, referencedComponentId)).with("commitComment", "Created new reference set member with non-existent refSetId");
createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(400);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedConceptApiTest method reactivateConceptWithExistingOWLAxiom.
@Test
public void reactivateConceptWithExistingOWLAxiom() throws Exception {
final String conceptId = ApplicationContext.getServiceForClass(ISnomedIdentifierService.class).generate(null, ComponentCategory.CONCEPT, 1).iterator().next();
final String owlSubclassOfExpression = String.format("SubClassOf(:%s :%s)", conceptId, Concepts.ROOT_CONCEPT);
final String owlAxiomMemberId = UUID.randomUUID().toString();
// create an inactive concept with an active OWL axiom
Json conceptRequestBody = createConceptRequestBody(Concepts.FULLY_SPECIFIED_NAME).with(Json.object("id", conceptId, "active", false, "members", Json.array(Json.object("id", owlAxiomMemberId, "active", true, "moduleId", Concepts.MODULE_SCT_CORE, "refsetId", Concepts.REFSET_OWL_AXIOM, SnomedRf2Headers.FIELD_OWL_EXPRESSION, owlSubclassOfExpression)), "commitComment", "Created concept with owl axiom reference set member"));
conceptRequestBody = conceptRequestBody.without("relationships");
createConcept(branchPath, conceptRequestBody);
// check the concept before reactivating, parentage info should be empty
SnomedConcept concept = getConcept(conceptId);
// assertThat(concept.getStatedAncestorIdsAsString()).isEmpty();
// assertThat(concept.getStatedParentIdsAsString()).contains(IComponent.ROOT_ID);
// reactivate concept and check stated parentage info
reactivateConcept(branchPath, conceptId);
// it should receive the necessary info to be part of the tree again
concept = getConcept(conceptId);
assertThat(concept.getStatedAncestorIdsAsString()).contains(IComponent.ROOT_ID);
assertThat(concept.getStatedParentIdsAsString()).contains(Concepts.ROOT_CONCEPT);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedConceptApiTest method testUpdateConceptDefinitionStatusWithSubClassOfAxiomMemberShouldChangeToPrimitive.
@Test
public void testUpdateConceptDefinitionStatusWithSubClassOfAxiomMemberShouldChangeToPrimitive() {
final String conceptId = createNewConcept(branchPath);
// Update the definition status on concept
final Map<?, ?> definitionStatusUpdateRequestBody = Json.object("definitionStatusId", Concepts.FULLY_DEFINED, "commitComment", "Changed definition status of concept to fully defined");
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, definitionStatusUpdateRequestBody).statusCode(204);
// Add a reference set member
final SnomedReferenceSetMember newMember = new SnomedReferenceSetMember();
newMember.setId(UUID.randomUUID().toString());
newMember.setActive(true);
newMember.setRefsetId(Concepts.REFSET_OWL_AXIOM);
newMember.setProperties(Json.object(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("SubClassOf(:%s :%s)", conceptId, Concepts.AMBIGUOUS)));
newMember.setType(SnomedRefSetType.OWL_AXIOM);
newMember.setModuleId(Concepts.MODULE_SCT_CORE);
final Json updateRequestBody = Json.object("members", SnomedReferenceSetMembers.of(Json.array(newMember)), "commitComment", "Add new reference set member via concept update");
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, updateRequestBody).statusCode(204);
final SnomedConcept updatedConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "members()").statusCode(200).extract().as(SnomedConcept.class);
assertEquals(1, updatedConcept.getMembers().getTotal());
// Verify that definition status was updated to FULLY DEFINED
assertEquals(Concepts.PRIMITIVE, updatedConcept.getDefinitionStatusId());
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedConceptApiTest method testUpdateConceptDefinitionStatusWithAxiomMembersShouldNotChange.
@Test
public void testUpdateConceptDefinitionStatusWithAxiomMembersShouldNotChange() {
final String conceptId = createNewConcept(branchPath);
// Update the definition status on concept
final Map<?, ?> definitionStatusUpdateRequestBody = Json.object("definitionStatusId", Concepts.FULLY_DEFINED, "commitComment", "Changed definition status of concept to fully defined");
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, definitionStatusUpdateRequestBody).statusCode(204);
// Add a reference set member
final SnomedReferenceSetMember newMember = new SnomedReferenceSetMember();
newMember.setId(UUID.randomUUID().toString());
newMember.setActive(true);
newMember.setRefsetId(Concepts.REFSET_OWL_AXIOM);
newMember.setProperties(Json.object(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("EquivalentClasses(:%s ObjectIntersectionOf(:%s :%s))", conceptId, Concepts.AMBIGUOUS, Concepts.NAMESPACE_ROOT)));
newMember.setType(SnomedRefSetType.OWL_AXIOM);
newMember.setModuleId(Concepts.MODULE_SCT_CORE);
final Json updateRequestBody = Json.object("members", SnomedReferenceSetMembers.of(Json.array(newMember)), "definitionStatusId", Concepts.PRIMITIVE, "commitComment", "Add new reference set member via concept update");
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, updateRequestBody).statusCode(204);
final SnomedConcept updatedConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "members()").statusCode(200).extract().as(SnomedConcept.class);
assertEquals(1, updatedConcept.getMembers().getTotal());
// Verify that definition status is still fully defined
assertEquals(Concepts.FULLY_DEFINED, updatedConcept.getDefinitionStatusId());
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedConceptInactivationApiTest method toggleDefinitionStatusAtStatusChange.
@Test
public void toggleDefinitionStatusAtStatusChange() {
String conceptId = createNewConcept(branchPath);
Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, conceptId).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, "EquivalentClasses(:" + conceptId + " :" + Concepts.NAMESPACE_ROOT + ")").with("commitComment", "Created new equivalent class OWL Axiom reference set member");
assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
SnomedReferenceSetMembers members = SnomedComponentRestRequests.searchComponent(branchPath, SnomedComponentType.MEMBER, Map.of("referencedComponentId", conceptId)).extract().as(SnomedReferenceSetMembers.class);
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, Json.object("members", members, "commitComment", "Update concept members")).statusCode(204);
SnomedConcept concept = assertGetConcept(conceptId).statusCode(200).extract().as(SnomedConcept.class);
assertTrue(concept.isActive());
// Active concept is defined after adding equivalent class axioms to it
assertTrue(!concept.isPrimitive());
inactivateConcept(branchPath, conceptId);
concept = assertGetConcept(conceptId).statusCode(200).extract().as(SnomedConcept.class);
assertTrue(!concept.isActive());
// Inactive concept becomes primitive
assertTrue(concept.isPrimitive());
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, Json.object("active", true, "commitComment", "Reactivate concept")).statusCode(204);
concept = assertGetConcept(conceptId).statusCode(200).extract().as(SnomedConcept.class);
assertTrue(concept.isActive());
// Reactivated concept with no active members stays primitive
assertTrue(concept.isPrimitive());
}
Aggregations