use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberParameterizedTest method testRestorationOfEffectiveTimeOnMutablePropertyChange.
@Test
public void testRestorationOfEffectiveTimeOnMutablePropertyChange() {
// XXX skip simple type refsets
Assume.assumeFalse(SnomedRefSetType.SIMPLE.equals(refSetType));
final String shortName = getOrCreateCodeSystem();
// create the previous revision of the member
final Pair<String, String> member = createRefSetMember();
final String memberId = member.getA();
final String referencedComponentId = member.getB();
final LocalDate effectiveTime = getNextAvailableEffectiveDate(shortName);
createVersion(shortName, effectiveTime).statusCode(201);
// update properties
final Json updateRequest = getUpdateProperties(referencedComponentId).with("commitComment", "Updated reference set member");
updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
// Updating a member's properties should unset the effective time
final ValidatableResponse updateResponse = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", equalTo(null));
// check updated properties
for (Entry<String, Object> updateProperty : getUpdateProperties(referencedComponentId).entrySet()) {
updateResponse.body(updateProperty.getKey(), equalTo(updateProperty.getValue()));
}
// revert back to original values
final Json revertUpdateRequest = getValidProperties(refSetType, referencedComponentId).with("commitComment", "Reverted previous update of reference set member");
updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, revertUpdateRequest, false).statusCode(204);
// Getting the member back to its originally released state should restore the effective time
ValidatableResponse revertResponse = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", equalTo(effectiveTime.format(DateTimeFormatter.BASIC_ISO_DATE)));
for (Entry<String, Object> validProperty : getValidProperties(refSetType, referencedComponentId).entrySet()) {
revertResponse.body(validProperty.getKey(), equalTo(validProperty.getValue()));
}
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRelationshipApiTest method createRelationship.
@Test
public void createRelationship() {
Json requestBody = createRelationshipRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT).with("commitComment", "Created new relationship");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(201);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRelationshipApiTest method deleteInactiveRelationship.
private void deleteInactiveRelationship(String typeId) {
String sourceId = createNewConcept(branchPath);
String relationshipId = createNewRelationship(branchPath, sourceId, typeId, Concepts.NAMESPACE_ROOT);
Json requestBody = Json.object("active", false, "commitComment", "Inactivated relationship");
updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, requestBody).statusCode(204);
deleteComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, false).statusCode(204);
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(404);
/*
* Source concept should still exist at this point (the deletion plan should not
* consider removing it with the relationship).
*/
getComponent(branchPath, SnomedComponentType.CONCEPT, sourceId).statusCode(200);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRelationshipApiTest method changeRelationshipModifier.
@Test
public void changeRelationshipModifier() {
String relationshipId = createNewRelationship(branchPath);
Json requestBody = Json.object("modifierId", Concepts.UNIVERSAL_RESTRICTION_MODIFIER, "commitComment", "Updated relationship modifier");
updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, requestBody).statusCode(204);
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("modifierId", equalTo(Concepts.UNIVERSAL_RESTRICTION_MODIFIER));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRelationshipApiTest method restoreEffectiveTimeOnReleasedRelationship.
@Test
public void restoreEffectiveTimeOnReleasedRelationship() throws Exception {
final String relationshipId = createNewRelationship(branchPath);
final String shortName = "SNOMEDCT-REL-1";
createCodeSystem(branchPath, shortName).statusCode(201);
final LocalDate effectiveDate = getNextAvailableEffectiveDate(shortName);
createVersion(shortName, "v1", effectiveDate).statusCode(201);
// After versioning, the relationship should be released and have an effective time set on it
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(true)).body("released", equalTo(true)).body("effectiveTime", equalTo(effectiveDate.format(DateTimeFormatter.BASIC_ISO_DATE)));
Json inactivationRequestBody = Json.object("active", false, "commitComment", "Inactivated relationship");
updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, inactivationRequestBody).statusCode(204);
// An inactivation should unset the effective time field
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(false)).body("released", equalTo(true)).body("effectiveTime", nullValue());
Json reactivationRequestBody = Json.object("active", true, "commitComment", "Inactivated relationships");
updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, reactivationRequestBody).statusCode(204);
// Getting the relationship back to its originally released state should restore the effective time
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(true)).body("released", equalTo(true)).body("effectiveTime", equalTo(effectiveDate.format(DateTimeFormatter.BASIC_ISO_DATE)));
}
Aggregations