Search in sources :

Example 86 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberParameterizedTest method rejectInvalidProperties.

@Test
public void rejectInvalidProperties() throws Exception {
    // Simple type reference sets can't be tested with this method
    Assume.assumeFalse(SnomedRefSetType.SIMPLE.equals(refSetType));
    String refSetId = getOrCreateRefSet(branchPath, refSetType);
    String componentId = createNewComponent(branchPath, getFirstAllowedReferencedComponentType(refSetType));
    Json requestBody = createRefSetMemberRequestBody(refSetId, componentId).with(getInvalidProperties()).with("commitComment", "Created new reference set member with invalid additional properties");
    createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 87 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberParameterizedTest method acceptValidUpdate.

@Test
public void acceptValidUpdate() throws Exception {
    // Simple type reference sets can't be tested with this method
    Assume.assumeFalse(SnomedRefSetType.SIMPLE.equals(refSetType));
    final Pair<String, String> member = createRefSetMember();
    final String memberId = member.getA();
    final String referencedComponentId = member.getB();
    Json updateRequest = Json.object().with(getUpdateProperties(referencedComponentId)).with("commitComment", "Updated reference set member");
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
    ValidatableResponse response = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200);
    for (Entry<String, Object> validProperty : getUpdateProperties(referencedComponentId).entrySet()) {
        response.body(validProperty.getKey(), equalTo(validProperty.getValue()));
    }
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 88 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberParameterizedTest method rejectNonExistentComponentId.

@Test
public void rejectNonExistentComponentId() throws Exception {
    String refSetId = createNewRefSet(branchPath, refSetType);
    String referencedComponentId = reserveComponentId(null, getFirstAllowedReferencedComponentCategory(refSetType));
    Json requestBody = createRefSetMemberRequestBody(refSetId, referencedComponentId).with(getValidProperties(refSetType, referencedComponentId)).with("commitComment", "Created new reference set member with non-existent referencedComponentId");
    createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 89 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberParameterizedTest method inactivateMember.

@Test
public void inactivateMember() throws Exception {
    final Pair<String, String> member = createRefSetMember();
    final String memberId = member.getA();
    Json updateRequest = Json.object("active", false, "moduleId", Concepts.MODULE_ROOT, "commitComment", "Inactivated reference set member and changed module");
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).body("active", equalTo(false)).body("moduleId", equalTo(Concepts.MODULE_ROOT));
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 90 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberParameterizedTest method createRefSetMember.

/**
 * Creates a member for the first applicable matching referenced component and returns the memberId and the referencedComponentId in a Pair.
 */
private Pair<String, String> createRefSetMember() {
    String referencedComponentId = getFirstMatchingComponent(branchPath, getFirstAllowedReferencedComponentType(refSetType));
    String refSetId = getOrCreateRefSet(branchPath, refSetType);
    Json requestBody = createRefSetMemberRequestBody(refSetId, referencedComponentId).with(getValidProperties(refSetType, referencedComponentId)).with("commitComment", "Created new reference set member");
    ValidatableResponse response = createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(201);
    return Pair.of(lastPathSegment(response.extract().header("Location")), referencedComponentId);
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) Json(com.b2international.commons.json.Json)

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