Search in sources :

Example 76 with Json

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");
    }
}
Also used : NotFoundException(com.b2international.commons.exceptions.NotFoundException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) BaseResourceApiTest(com.b2international.snowowl.core.rest.BaseResourceApiTest)

Example 77 with Json

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");
    }
}
Also used : NotFoundException(com.b2international.commons.exceptions.NotFoundException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) BaseResourceApiTest(com.b2international.snowowl.core.rest.BaseResourceApiTest)

Example 78 with Json

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")));
}
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)

Example 79 with Json

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")));
}
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)

Example 80 with Json

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);
}
Also used : List(java.util.List) Json(com.b2international.commons.json.Json) Map(java.util.Map) Maps.newHashMap(com.google.common.collect.Maps.newHashMap)

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