Search in sources :

Example 31 with Json

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

the class SnomedDescriptionApiTest method updateReleasedDescriptionLanguageCode.

@Test
public void updateReleasedDescriptionLanguageCode() throws Exception {
    String descriptionId = createNewDescription(branchPath);
    Json update = Json.object(SnomedRf2Headers.FIELD_LANGUAGE_CODE, "hu", "commitComment", "Update unreleased description languageCode");
    // release component
    createCodeSystemAndVersion(branchPath, "SNOMEDCT-RELDESC-LANGCODE", "v1", LocalDate.parse("2017-03-01"));
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, update).statusCode(400);
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body(SnomedRf2Headers.FIELD_LANGUAGE_CODE, equalTo(SnomedRestFixtures.DEFAULT_LANGUAGE_CODE));
}
Also used : Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 32 with Json

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

the class SnomedDescriptionApiTest method updateAcceptabilityWithMemberReactivation.

@Test
public void updateAcceptabilityWithMemberReactivation() throws Exception {
    changeToAcceptable(branchPath, Concepts.ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_UK);
    String descriptionId = createNewDescription(branchPath, Concepts.ROOT_CONCEPT, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    SnomedReferenceSetMembers members = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class).getMembers();
    // Inactivate the reference set member
    members.forEach(m -> {
        Json requestBody = Json.object("active", false, "commitComment", "Inactivate language reference set member");
        updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, m.getId(), requestBody, false).statusCode(204);
    });
    Json requestBody = Json.object("acceptability", Json.object(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED, Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED), "commitComment", "Reactivated UK, added US acceptability to description");
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
    members = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).body("members.items.refsetId", hasItems(Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.REFSET_LANGUAGE_TYPE_US)).extract().as(SnomedDescription.class).getMembers();
    assertEquals(2, members.getTotal());
    members.forEach(m -> assertEquals("Reference set member should be active", Boolean.TRUE, m.isActive()));
}
Also used : SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 33 with Json

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

the class SnomedDescriptionApiTest method createDescriptionInvalidConcept.

@Test
public void createDescriptionInvalidConcept() {
    Json requestBody = createDescriptionRequestBody("11110000").with("commitComment", "Created new description with invalid conceptId");
    createComponent(branchPath, SnomedComponentType.DESCRIPTION, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 34 with Json

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

the class SnomedRefSetMemberApiTest method deleteReferringMRCMDomainRefsetMember.

@Test
public void deleteReferringMRCMDomainRefsetMember() {
    String newIdentifierConceptId = createNewConcept(branchPath, SnomedRefSetUtil.getParentConceptId(SnomedRefSetType.MRCM_DOMAIN));
    createNewRefSet(branchPath, SnomedRefSetType.MRCM_DOMAIN, newIdentifierConceptId);
    String conceptId = createNewConcept(branchPath);
    Json requestBody = createRefSetMemberRequestBody(newIdentifierConceptId, conceptId).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT, "domainConstraint", SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_CONSTRAINT, "proximalPrimitiveConstraint", SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_PRECOORDINATION, "domainTemplateForPrecoordination", SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_POSTCOORDINATION, "domainTemplateForPostcoordination", "commitComment", "Created new MRCM domain reference set member"));
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200);
    deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(404);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 35 with Json

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

the class SnomedRefSetMemberApiTest method createConcreteDomainMemberInvalidValue.

@Test
public void createConcreteDomainMemberInvalidValue() {
    createConcreteDomainParentConcept(branchPath);
    String refSetId = createConcreteDomainRefSet(branchPath, DataType.INTEGER);
    Json requestBody = createRefSetMemberRequestBody(refSetId, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_TYPE_ID, Concepts.REFSET_ATTRIBUTE, SnomedRf2Headers.FIELD_RELATIONSHIP_GROUP, 0, SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID, Concepts.STATED_RELATIONSHIP, // bad
    SnomedRf2Headers.FIELD_VALUE, // bad
    "five", "commitComment", "Created new reference set member"));
    createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(400);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) 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