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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations