Search in sources :

Example 61 with Json

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

the class SnomedDescriptionApiTest method createDescriptionCaseInsensitive.

@Test
public void createDescriptionCaseInsensitive() {
    Json requestBody = createDescriptionRequestBody(Concepts.ROOT_CONCEPT, Concepts.SYNONYM, Concepts.MODULE_SCT_CORE, SnomedApiTestConstants.UK_ACCEPTABLE_MAP, Concepts.ENTIRE_TERM_CASE_INSENSITIVE).with("commitComment", "Created new description with case insensitive significance");
    String descriptionId = assertCreated(createComponent(branchPath, SnomedComponentType.DESCRIPTION, requestBody));
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ENTIRE_TERM_CASE_INSENSITIVE));
}
Also used : Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 62 with Json

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

the class SnomedDescriptionApiTest method shouldUpdateReleasedDescriptionTerm.

@Test
public void shouldUpdateReleasedDescriptionTerm() throws Exception {
    final String descriptionId = createNewDescription(branchPath);
    final String newTerm = "updatedUnreleasedDescriptionTerm";
    final Json update = Json.object(SnomedRf2Headers.FIELD_TERM, newTerm, "commitComment", "Update unreleased description term");
    // release component
    createCodeSystemAndVersion(branchPath, "SNOMEDCT-RELDESC-TERM", "v1", LocalDate.parse("2017-03-01"));
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, update).statusCode(204);
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body(SnomedRf2Headers.FIELD_TERM, equalTo(newTerm));
}
Also used : Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 63 with Json

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

the class SnomedDescriptionApiTest method updateUnreleasedDescriptionTerm.

@Test
public void updateUnreleasedDescriptionTerm() throws Exception {
    String descriptionId = createNewDescription(branchPath);
    Json update = Json.object(SnomedRf2Headers.FIELD_TERM, "updatedUnreleasedDescriptionTerm", "commitComment", "Update unreleased description term");
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, update).statusCode(204);
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body(SnomedRf2Headers.FIELD_TERM, equalTo("updatedUnreleasedDescriptionTerm"));
}
Also used : Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 64 with Json

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

the class SnomedExtensionUpgradeTest method upgrade11DonatedConceptAndDescriptionsAndRelationshipsWithCrossReference.

@Test
public void upgrade11DonatedConceptAndDescriptionsAndRelationshipsWithCrossReference() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    String extensionModuleId = createModule(extension);
    String extensionFsnTerm1 = "FSN of concept";
    String extensionPtTerm1 = "PT of concept";
    String extensionSynonymTerm1 = "Synonym of extension concept";
    Json fsnRequestBody1 = Json.object("typeId", Concepts.FULLY_SPECIFIED_NAME, "term", extensionFsnTerm1, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
    Json ptRequestBody1 = Json.object("typeId", Concepts.SYNONYM, "term", extensionPtTerm1, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
    Json synonymRequestBody1 = Json.object("typeId", Concepts.SYNONYM, "term", extensionSynonymTerm1, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_ACCEPTABLE_MAP);
    Json statedIsa = Json.object("typeId", Concepts.IS_A, "destinationId", Concepts.ROOT_CONCEPT, "characteristicTypeId", Concepts.STATED_RELATIONSHIP);
    Json inferredIsa = Json.object("typeId", Concepts.IS_A, "destinationId", Concepts.ROOT_CONCEPT, "characteristicTypeId", Concepts.INFERRED_RELATIONSHIP);
    Json extensionConceptRequestBody = Json.object("namespaceId", Concepts.B2I_NAMESPACE, "moduleId", extensionModuleId, "descriptions", Json.array(fsnRequestBody1, ptRequestBody1, synonymRequestBody1), "relationships", Json.array(statedIsa, inferredIsa));
    String extensionConceptId1 = createConcept(extension.getResourceURI(), extensionConceptRequestBody);
    // create another extension concept which references the previous one
    String extensionFsnTerm2 = "FSN of concept 2";
    String extensionPtTerm2 = "PT of concept 2";
    String extensionSynonymTerm2 = "Synonym of extension concept 2";
    Json referenceToExtensionConcept1 = Json.object("typeId", Concepts.PART_OF, "destinationId", extensionConceptId1, "characteristicTypeId", Concepts.ADDITIONAL_RELATIONSHIP);
    String extensionConceptId2 = createConcept(extension.getResourceURI(), extensionConceptRequestBody.with(Json.object("descriptions", Json.array(fsnRequestBody1.with("term", extensionFsnTerm2), ptRequestBody1.with("term", extensionPtTerm2), synonymRequestBody1.with("term", extensionSynonymTerm2)), "relationships", Json.array(statedIsa, inferredIsa, referenceToExtensionConcept1))));
    // create new extension version
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    SnomedConcept extensionConcept1 = getConcept(extension.getResourceURI(), extensionConceptId1, "descriptions()", "relationships()");
    String extensionFsnId1 = getFirstMatchingDescription(extensionConcept1, extensionFsnTerm1).getId();
    String extensionPtId1 = getFirstMatchingDescription(extensionConcept1, extensionPtTerm1).getId();
    String extensionSynonymId1 = getFirstMatchingDescription(extensionConcept1, extensionSynonymTerm1).getId();
    String extensionStatedIsaId1 = getFirstRelationshipId(extensionConcept1, Concepts.STATED_RELATIONSHIP);
    String extensionInferredIsaId1 = getFirstRelationshipId(extensionConcept1, Concepts.INFERRED_RELATIONSHIP);
    SnomedConcept extensionConcept2 = getConcept(extension.getResourceURI(), extensionConceptId2, "descriptions()", "relationships()");
    String extensionFsnId2 = getFirstMatchingDescription(extensionConcept2, extensionFsnTerm2).getId();
    String extensionPtId2 = getFirstMatchingDescription(extensionConcept2, extensionPtTerm2).getId();
    String extensionSynonymId2 = getFirstMatchingDescription(extensionConcept2, extensionSynonymTerm2).getId();
    String extensionStatedIsaId2 = getFirstRelationshipId(extensionConcept2, Concepts.STATED_RELATIONSHIP);
    String extensionInferredIsaId2 = getFirstRelationshipId(extensionConcept2, Concepts.INFERRED_RELATIONSHIP);
    String referenceToExtensionConcept1RelationshipId = getFirstRelationshipId(extensionConcept2, Concepts.ADDITIONAL_RELATIONSHIP);
    // simulate donation via concept create and versioning
    // donate both concepts without the PART OF relationship reference between them
    String intConceptId1 = createConcept(SnomedContentRule.SNOMEDCT, Json.object("id", extensionConceptId1, "moduleId", Concepts.MODULE_SCT_CORE, "descriptions", Json.array(fsnRequestBody1.with("id", extensionFsnId1), ptRequestBody1.with("id", extensionPtId1)), "relationships", Json.array(statedIsa.with("id", extensionStatedIsaId1), inferredIsa.with("id", extensionInferredIsaId1))));
    String intConceptId2 = createConcept(SnomedContentRule.SNOMEDCT, Json.object("id", extensionConceptId2, "moduleId", Concepts.MODULE_SCT_CORE, "descriptions", Json.array(fsnRequestBody1.with("id", extensionFsnId2), ptRequestBody1.with("id", extensionPtId2)), "relationships", Json.array(statedIsa.with("id", extensionStatedIsaId2), inferredIsa.with("id", extensionInferredIsaId2))));
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, effectiveTime.toString()));
    SnomedConcept donatedConceptInExtension1 = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId1, "descriptions()", "relationships()");
    SnomedConcept donatedConceptInExtension2 = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId2, "descriptions()", "relationships()");
    // validate components of donated concepts on extension branch
    // same IDs, different modules
    assertEquals(donatedConceptInExtension1.getId(), extensionConcept1.getId());
    assertNotEquals(donatedConceptInExtension1.getModuleId(), extensionConcept1.getModuleId());
    assertThat(donatedConceptInExtension1.getDescriptions()).extracting(SnomedDescription::getId).containsOnly(extensionFsnId1, extensionPtId1, extensionSynonymId1);
    assertThat(donatedConceptInExtension1.getRelationships()).extracting(SnomedRelationship::getId).containsOnly(extensionStatedIsaId1, extensionInferredIsaId1);
    // check if the other donated extension concept still has the reference relationship
    assertEquals(donatedConceptInExtension2.getId(), extensionConcept2.getId());
    assertNotEquals(donatedConceptInExtension2.getModuleId(), extensionConcept2.getModuleId());
    assertThat(donatedConceptInExtension2.getDescriptions()).extracting(SnomedDescription::getId).containsOnly(extensionFsnId2, extensionPtId2, extensionSynonymId2);
    assertThat(donatedConceptInExtension2.getRelationships()).extracting(SnomedRelationship::getId).containsOnly(extensionStatedIsaId2, extensionInferredIsaId2, referenceToExtensionConcept1RelationshipId);
}
Also used : Json(com.b2international.commons.json.Json) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 65 with Json

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

the class SnomedExtensionUpgradeTest method upgrade07DonatedRelationship.

@Test
public void upgrade07DonatedRelationship() throws Exception {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    String extensionModuleId = createModule(extension);
    Json extensionRelationshipRequest = Json.object("namespaceId", Concepts.B2I_NAMESPACE, "moduleId", extensionModuleId, "sourceId", Concepts.ROOT_CONCEPT, "typeId", Concepts.PART_OF, "destinationId", Concepts.NAMESPACE_ROOT, "characteristicTypeId", Concepts.ADDITIONAL_RELATIONSHIP, "relationshipGroup", 0, "commitComment", "Created new extension relationship");
    String extensionRelationshipId = createRelationship(extension.getResourceURI(), extensionRelationshipRequest);
    // create new extension version
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    // simulate donation of relationship to INT with slightly different props but same ID
    Json donatedRelationshipRequest = Json.assign(extensionRelationshipRequest, Json.object("id", extensionRelationshipId, "moduleId", Concepts.MODULE_SCT_CORE, "characteristicTypeId", Concepts.INFERRED_RELATIONSHIP, "relationshipGroup", 1, "commitComment", "Created new donated INT relationship"));
    String donatedRelationshipId = createRelationship(SnomedContentRule.SNOMEDCT, donatedRelationshipRequest);
    LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
    createVersion(SNOMEDCT, effectiveTime).statusCode(201);
    assertEquals(extensionRelationshipId, donatedRelationshipId);
    // start upgrade to the new available upgrade version
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, effectiveTime.toString()));
    SnomedRelationship donatedRelationshipOnUpgrade = getRelationship(upgradeCodeSystem.getResourceURI(), donatedRelationshipId);
    assertEquals(Concepts.MODULE_SCT_CORE, donatedRelationshipOnUpgrade.getModuleId());
    assertEquals(Concepts.INFERRED_RELATIONSHIP, donatedRelationshipOnUpgrade.getCharacteristicTypeId());
    assertEquals(1, donatedRelationshipOnUpgrade.getRelationshipGroup().intValue());
}
Also used : SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) Json(com.b2international.commons.json.Json) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

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