Search in sources :

Example 71 with Json

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

the class SnomedRelationshipApiTest method createIsARelationshipToSelf.

@Test
public void createIsARelationshipToSelf() throws Exception {
    Json requestBody = createRelationshipRequestBody(Concepts.NAMESPACE_ROOT, Concepts.IS_A, Concepts.NAMESPACE_ROOT).with("commitComment", "Created new relationship pointing to itself");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 72 with Json

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

the class SnomedRelationshipApiTest method createRelationshipWithReservedId.

@Test
public void createRelationshipWithReservedId() {
    ISnomedIdentifierService identifierService = getServiceForClass(ISnomedIdentifierService.class);
    String relationshipId = Iterables.getOnlyElement(identifierService.reserve(null, ComponentCategory.RELATIONSHIP, 1));
    Json requestBody = createRelationshipRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT).with("id", relationshipId).with("commitComment", "Created new relationship with reserved identifier");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(201).header("Location", endsWith("/" + relationshipId));
    SctId relationshipSctId = SnomedRequests.identifiers().prepareGet().setComponentId(relationshipId).buildAsync().execute(getBus()).getSync().first().get();
    assertEquals(IdentifierStatus.ASSIGNED.getSerializedName(), relationshipSctId.getStatus());
}
Also used : ISnomedIdentifierService(com.b2international.snowowl.snomed.cis.ISnomedIdentifierService) Json(com.b2international.commons.json.Json) SctId(com.b2international.snowowl.snomed.cis.domain.SctId) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 73 with Json

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

the class SnomedExtensionUpgradeTest method upgrade09DonatedConceptAndDescriptions.

@Test
public void upgrade09DonatedConceptAndDescriptions() {
    // create extension on the latest SI VERSION
    CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
    String extensionModuleId = createModule(extension);
    String extensionFsnTerm = "FSN of concept";
    String extensionPtTerm = "PT of concept";
    String extensionSynonymTerm = "Synonym of extension concept";
    Json fsnRequestBody = Json.object("typeId", Concepts.FULLY_SPECIFIED_NAME, "term", extensionFsnTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
    Json ptRequestBody = Json.object("typeId", Concepts.SYNONYM, "term", extensionPtTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
    Json synonymRequestBody = Json.object("typeId", Concepts.SYNONYM, "term", extensionSynonymTerm, "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(fsnRequestBody, ptRequestBody, synonymRequestBody), "relationships", Json.array(statedIsa, inferredIsa));
    String extensionConceptId = createConcept(extension.getResourceURI(), extensionConceptRequestBody);
    // create new extension version
    createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
    SnomedConcept extensionConcept = getConcept(extension.getResourceURI(), extensionConceptId, "descriptions()", "relationships()");
    String extensionFsnId = getFirstMatchingDescription(extensionConcept, extensionFsnTerm).getId();
    String extensionPtId = getFirstMatchingDescription(extensionConcept, extensionPtTerm).getId();
    String extensionSynonymId = getFirstMatchingDescription(extensionConcept, extensionSynonymTerm).getId();
    String extensionStatedIsaId = getFirstRelationshipId(extensionConcept, Concepts.STATED_RELATIONSHIP);
    String extensionInferredIsaId = getFirstRelationshipId(extensionConcept, Concepts.INFERRED_RELATIONSHIP);
    // simulate donation via concept create and versioning
    // create INT concept with same ID and with same description and relationship IDs
    String intConceptId = createConcept(SnomedContentRule.SNOMEDCT, Json.object("id", extensionConceptId, "moduleId", Concepts.MODULE_SCT_CORE, "descriptions", Json.array(fsnRequestBody.with("id", extensionFsnId), ptRequestBody.with("id", extensionPtId)), "relationships", Json.array(statedIsa, inferredIsa)));
    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 donatedConceptInExtension = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId, "descriptions()", "relationships()");
    // validate components of donated concept on extension branch
    // same ID, different module
    assertNotEquals(donatedConceptInExtension.getModuleId(), extensionConcept.getModuleId());
    SnomedDescription donatedFsn = getFirstMatchingDescription(donatedConceptInExtension, extensionFsnTerm);
    assertEquals(extensionFsnId, donatedFsn.getId());
    assertEquals(Concepts.MODULE_SCT_CORE, donatedFsn.getModuleId());
    SnomedDescription donatedPt = getFirstMatchingDescription(donatedConceptInExtension, extensionPtTerm);
    assertEquals(extensionPtId, donatedPt.getId());
    assertEquals(Concepts.MODULE_SCT_CORE, donatedPt.getModuleId());
    Set<String> descriptionIds = donatedConceptInExtension.getDescriptions().getItems().stream().map(SnomedDescription::getId).collect(Collectors.toSet());
    assertThat(descriptionIds).hasSize(3).contains(extensionSynonymId);
    Set<String> relationshipIds = donatedConceptInExtension.getRelationships().getItems().stream().map(SnomedRelationship::getId).collect(Collectors.toSet());
    assertThat(relationshipIds).hasSize(4).contains(extensionStatedIsaId, extensionInferredIsaId);
}
Also used : SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) 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 74 with Json

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

the class SnomedExportApiTest method exportSnapshotWithBranchRange.

@Test
public void exportSnapshotWithBranchRange() throws Exception {
    final IBranchPath taskBranchPath = BranchPathUtils.createPath(branchPath, "task");
    branching.createBranch(taskBranchPath).statusCode(201);
    final Json exportConfig = Json.object("type", Rf2ReleaseType.SNAPSHOT.name());
    export(RevisionIndex.toRevisionRange(branchPath.getPath(), taskBranchPath.getPath()), exportConfig).then().statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 75 with Json

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

the class CodeSystemApiTest method codesystem24_UpdateBundleId.

@Test
public void codesystem24_UpdateBundleId() {
    final String codeSystemId = "cs24";
    final Map<String, Object> requestBody = prepareCodeSystemCreateRequestBody(codeSystemId);
    assertCodeSystemCreated(requestBody);
    final String bundleId = IDs.base64UUID();
    BundleApiAssert.assertCreate(BundleApiAssert.prepareBundleCreateRequestBody(bundleId)).statusCode(201);
    final Json updateRequestBody = Json.object("bundleId", bundleId);
    assertCodeSystemUpdated(codeSystemId, updateRequestBody);
    assertCodeSystemHasAttributeValue(codeSystemId, "bundleId", bundleId);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) BaseResourceApiTest(com.b2international.snowowl.core.rest.BaseResourceApiTest)

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