use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class CodeSystemApiTest method codesystem15_CreateWithDedicatedBranchPath.
@Test
public void codesystem15_CreateWithDedicatedBranchPath() {
final String codeSystemId = "cs10";
final String expectedBranchPath = Branch.get(Branch.MAIN_PATH, codeSystemId);
try {
RepositoryRequests.branching().prepareGet(expectedBranchPath).build(TOOLING_ID).execute(Services.bus()).getSync();
fail("Branch " + expectedBranchPath + " already exists");
} catch (NotFoundException expected) {
// Branch does not exist, continue
}
final Json requestBody = prepareCodeSystemCreateRequestBody(codeSystemId).without("branchPath");
assertCodeSystemCreated(requestBody);
assertCodeSystemGet(codeSystemId).statusCode(200);
try {
// Check if the branch has been created
RepositoryRequests.branching().prepareGet(expectedBranchPath).build(TOOLING_ID).execute(Services.bus()).getSync();
} catch (NotFoundException e) {
fail("Branch " + expectedBranchPath + " did not get created as part of code system creation");
}
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class CodeSystemApiTest method codesystem16_CreateWithExtensionOf.
@Test
public void codesystem16_CreateWithExtensionOf() {
final String parentCodeSystemId = "cs11";
final Json parentRequestBody = prepareCodeSystemCreateRequestBody(parentCodeSystemId);
assertCodeSystemCreated(parentRequestBody);
assertCodeSystemGet(parentCodeSystemId).statusCode(200);
final Json versionRequestBody = prepareVersionCreateRequestBody(CodeSystem.uri(parentCodeSystemId), "v1", "2020-04-15");
assertVersionCreated(versionRequestBody).statusCode(201);
final String codeSystemId = "cs12";
final Json requestBody = prepareCodeSystemCreateRequestBody(codeSystemId).without("branchPath").with("extensionOf", CodeSystem.uri("cs11/v1"));
assertCodeSystemCreated(requestBody);
final String expectedBranchPath = Branch.get(Branch.MAIN_PATH, "cs11", "v1", codeSystemId);
try {
// Check if the branch has been created
RepositoryRequests.branching().prepareGet(expectedBranchPath).build(TOOLING_ID).execute(Services.bus()).getSync();
} catch (NotFoundException e) {
fail("Branch " + expectedBranchPath + " did not get created as part of code system creation");
}
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class CodeSystemApiTest method codesystem18_UpdateSettings.
// TODO add other property update tests as well
@Test
public void codesystem18_UpdateSettings() {
final String codeSystemId = "cs5";
final Json requestBody = prepareCodeSystemCreateRequestBody(codeSystemId).with("settings", Map.of(SnomedTerminologyComponentConstants.CODESYSTEM_NAMESPACE_CONFIG_KEY, "1000198", SnomedTerminologyComponentConstants.CODESYSTEM_MODULES_CONFIG_KEY, List.of("1234567891000198103", "9876543211000198107"), "locked", true));
assertCodeSystemCreate(requestBody).statusCode(201);
final Json updateRequestBody = Json.object("settings", Json.object(SnomedTerminologyComponentConstants.CODESYSTEM_NAMESPACE_CONFIG_KEY, "1000197").with("locked", null));
assertCodeSystemUpdated(codeSystemId, updateRequestBody);
assertCodeSystemGet(codeSystemId).statusCode(200).and().body("settings." + SnomedTerminologyComponentConstants.CODESYSTEM_NAMESPACE_CONFIG_KEY, equalTo("1000197")).and().body("settings." + SnomedTerminologyComponentConstants.CODESYSTEM_MODULES_CONFIG_KEY, equalTo(List.of("1234567891000198103", "9876543211000198107"))).and().body("settings", not(hasKey("locked")));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class CodeSystemApiTest method codesystem14_CreateWithSettings.
// TODO add other searches here
@Test
public void codesystem14_CreateWithSettings() throws Exception {
final String codeSystemId = "cs6";
final Json body = prepareCodeSystemCreateRequestBody(codeSystemId).with(Json.object("settings", Json.object(SnomedTerminologyComponentConstants.CODESYSTEM_NAMESPACE_CONFIG_KEY, "1000198", SnomedTerminologyComponentConstants.CODESYSTEM_MODULES_CONFIG_KEY, List.of("123456781000198103", "876543211000198107"), CodeSystem.CommonSettings.LOCALES, List.of("en-us", "en-gb"))));
assertCodeSystemCreate(body).statusCode(201);
assertCodeSystemGet(codeSystemId).statusCode(200).body("settings." + SnomedTerminologyComponentConstants.CODESYSTEM_NAMESPACE_CONFIG_KEY, equalTo("1000198")).body("settings." + SnomedTerminologyComponentConstants.CODESYSTEM_MODULES_CONFIG_KEY, equalTo(List.of("123456781000198103", "876543211000198107"))).body("settings." + CodeSystem.CommonSettings.LOCALES, equalTo(List.of("en-us", "en-gb")));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRestFixtures method reactivateConcept.
@SuppressWarnings("unchecked")
public static void reactivateConcept(IBranchPath branch, String conceptId) {
final Map<String, Object> concept = getComponent(branch, SnomedComponentType.CONCEPT, conceptId, "descriptions()", "relationships()").statusCode(200).extract().as(Map.class);
final Json reactivationRequest = Json.assign(concept).without("inactivationIndicator").without("associationTargets").with("active", true).with("commitComment", "Reactivated concept");
// reactivate all relationships as well
final Map<String, Object> relationships = (Map<String, Object>) reactivationRequest.get("relationships");
final List<Map<String, Object>> relationshipItems = (List<Map<String, Object>>) relationships.get("items");
relationshipItems.forEach(relationship -> {
relationship.put("active", true);
});
updateComponent(branch, SnomedComponentType.CONCEPT, conceptId, reactivationRequest).statusCode(204);
}
Aggregations