use of com.b2international.snowowl.snomed.core.domain.InactivationProperties in project snow-owl by b2ihealthcare.
the class SnomedConceptInactivationApiTest method reactivateConceptWithActiveParentAndInboundRelationship.
@Test
public void reactivateConceptWithActiveParentAndInboundRelationship() throws Exception {
// Create two concepts, one that will be inactivated
String conceptWithReferenceToInactivatedConcept = createNewConcept(branchPath);
String conceptToInactivate = createNewConcept(branchPath);
// and an inbound relationship to the inactivated concept
String inboundStatedRelationshipId = createNewRelationship(branchPath, conceptWithReferenceToInactivatedConcept, Concepts.PART_OF, conceptToInactivate, Concepts.STATED_RELATIONSHIP);
// and an outbound inferred relationships, which will be reactivated along with the concept
String outboundInferredRelationshipId = createNewRelationship(branchPath, conceptToInactivate, Concepts.IS_A, Concepts.ROOT_CONCEPT, Concepts.INFERRED_RELATIONSHIP);
// Inactivate the concept with the relationship is pointing to
final InactivationProperties inactivationProperties = new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, conceptWithReferenceToInactivatedConcept)));
Map<String, Object> inactivationBody = Json.object("active", false, "inactivationProperties", inactivationProperties, "commitComment", "Inactivated concept");
updateConcept(conceptToInactivate, inactivationBody);
assertGetConcept(conceptToInactivate, "inactivationProperties()").statusCode(200).body("active", equalTo(false)).body("inactivationProperties.inactivationIndicatorId", equalTo(Concepts.DUPLICATE)).body("inactivationProperties.associationTargets.referenceSetId", hasItem(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION)).body("inactivationProperties.associationTargets.targetComponentId", hasItem(conceptWithReferenceToInactivatedConcept));
// Verify that the inbound relationship is inactive
assertGetRelationship(inboundStatedRelationshipId).statusCode(200).body("active", equalTo(false));
// Reactivate the concept
reactivateConcept(branchPath, conceptToInactivate);
// verify that the inferred outbound relationship is active again
assertGetRelationship(outboundInferredRelationshipId).statusCode(200).body("active", equalTo(true));
// Verify that the concept is active again, it has two active descriptions, no association targets, no indicator
assertGetConcept(conceptToInactivate, "inactivationProperties()").statusCode(200).body("active", equalTo(true)).body("parentIds", // verify the the inferred and stated hierarchy is back and valid
equalTo(List.of(Concepts.ROOT_CONCEPT))).body("statedParentIds", equalTo(List.of(Concepts.ROOT_CONCEPT))).body("ancestorIds", equalTo(List.of(IComponent.ROOT_ID))).body("statedAncestorIds", equalTo(List.of(IComponent.ROOT_ID))).body("inactivationProperties.inactivationIndicator", nullValue()).body("inactivationProperties.associationTargets", equalTo(List.of()));
// Verify that the inbound relationship is still inactive, meaning that manual reactivation is required
assertGetRelationship(inboundStatedRelationshipId).statusCode(200).body("active", equalTo(false));
}
use of com.b2international.snowowl.snomed.core.domain.InactivationProperties in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method inactivateWithIndicatorAndAssociationTarget.
@Test
public void inactivateWithIndicatorAndAssociationTarget() {
String descriptionToInactivate = createNewDescription(branchPath);
String associationTarget = createNewDescription(branchPath);
assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, associationTarget))));
}
Aggregations