Search in sources :

Example 41 with Json

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()));
    }
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) Json(com.b2international.commons.json.Json) LocalDate(java.time.LocalDate) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 42 with Json

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);
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 43 with Json

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);
}
Also used : Json(com.b2international.commons.json.Json)

Example 44 with Json

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));
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 45 with Json

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)));
}
Also used : Json(com.b2international.commons.json.Json) LocalDate(java.time.LocalDate) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Aggregations

Json (com.b2international.commons.json.Json)139 Test (org.junit.Test)134 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)111 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)33 LocalDate (java.time.LocalDate)17 RelationshipValue (com.b2international.snowowl.snomed.core.domain.RelationshipValue)11 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)11 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)11 BaseResourceApiTest (com.b2international.snowowl.core.rest.BaseResourceApiTest)10 SnomedReferenceSetMembers (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)10 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)7 ISnomedIdentifierService (com.b2international.snowowl.snomed.cis.ISnomedIdentifierService)6 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)6 SctId (com.b2international.snowowl.snomed.cis.domain.SctId)4 Pair (com.b2international.commons.Pair)3 ValidatableResponse (io.restassured.response.ValidatableResponse)3 File (java.io.File)3 NotFoundException (com.b2international.commons.exceptions.NotFoundException)2 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)2 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)2