Search in sources :

Example 96 with Json

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

the class CodeSystemApiTest method codesystem17_UpdateTitle.

@Test
public void codesystem17_UpdateTitle() {
    final String codeSystemId = "cs2";
    final Map<String, Object> requestBody = prepareCodeSystemCreateRequestBody(codeSystemId);
    assertCodeSystemCreated(requestBody);
    final Json updateRequestBody = Json.object("title", "updated name");
    assertCodeSystemUpdated(codeSystemId, updateRequestBody);
    assertCodeSystemHasAttributeValue(codeSystemId, "title", "updated name");
}
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 97 with Json

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

the class CodeSystemApiTest method codesystem23_DeleteVersioned.

@Test
public void codesystem23_DeleteVersioned() throws Exception {
    final String codeSystemId = "cs23";
    assertCodeSystemCreated(prepareCodeSystemCreateRequestBody(codeSystemId));
    assertCodeSystemGet(codeSystemId).statusCode(200);
    // version codesystem
    final Json versionRequestBody = prepareVersionCreateRequestBody(CodeSystem.uri(codeSystemId), "v1", LocalDate.now().toString());
    assertVersionCreated(versionRequestBody).statusCode(201);
    // TODO add REST API
    ResourceRequests.prepareDelete(codeSystemId).build(RestExtensions.USER, "Delete " + codeSystemId).execute(Services.bus()).getSync();
    assertCodeSystemGet(codeSystemId).statusCode(404);
    String branch = Branch.get(Branch.MAIN_PATH, codeSystemId);
    assertThat(RepositoryRequests.branching().prepareGet(branch).build(TOOLING_ID).execute(Services.bus()).getSync().isDeleted()).isTrue();
    CodeSystemVersionRestRequests.assertGetVersion(codeSystemId, "v1").statusCode(404);
    // Check if the branch has been created
    String versionBranch = Branch.get(Branch.MAIN_PATH, codeSystemId, "v1");
    assertThat(RepositoryRequests.branching().prepareGet(versionBranch).build(TOOLING_ID).execute(Services.bus()).getSync().isDeleted()).isTrue();
}
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 98 with Json

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

the class CodeSystemApiTest method codesystem21_UpdateExtensionOf.

@Test
public void codesystem21_UpdateExtensionOf() {
    final String parentCodeSystemId = "cs13";
    final Json parentRequestBody = prepareCodeSystemCreateRequestBody(parentCodeSystemId);
    assertCodeSystemCreated(parentRequestBody);
    assertCodeSystemGet(parentCodeSystemId).statusCode(200);
    final Json v3RequestBody = prepareVersionCreateRequestBody(CodeSystem.uri(parentCodeSystemId), "v3", "2020-04-16");
    assertVersionCreated(v3RequestBody).statusCode(201);
    final Json v4RequestBody = prepareVersionCreateRequestBody(CodeSystem.uri(parentCodeSystemId), "v4", "2020-04-17");
    assertVersionCreated(v4RequestBody).statusCode(201);
    final String codeSystemId = "cs14";
    final Json requestBody = prepareCodeSystemCreateRequestBody(codeSystemId).without("branchPath").with("extensionOf", CodeSystem.uri("cs13/v3"));
    assertCodeSystemCreated(requestBody);
    assertCodeSystemUpdated(codeSystemId, Json.object("extensionOf", CodeSystem.uri("cs13/v4")));
    final String expectedBranchPath = Branch.get(Branch.MAIN_PATH, "cs13", "v4", codeSystemId);
    assertCodeSystemHasAttributeValue(codeSystemId, "extensionOf", "codesystems/cs13/v4");
    assertCodeSystemHasAttributeValue(codeSystemId, "branchPath", expectedBranchPath);
}
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 99 with Json

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

the class CodeSystemApiTest method codesystem25_UpdateBundleIdNotExist.

@Test
public void codesystem25_UpdateBundleIdNotExist() {
    final String codeSystemId = "cs25";
    final Map<String, Object> requestBody = prepareCodeSystemCreateRequestBody(codeSystemId);
    assertCodeSystemCreated(requestBody);
    final Json updateRequestBody = Json.object("bundleId", "not-existing-bundle");
    assertCodeSystemNotUpdated(codeSystemId, updateRequestBody);
}
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 100 with Json

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

the class CodeSystemApiTest method codesystem20_UpdateInvalidBranchPath.

@Test
public void codesystem20_UpdateInvalidBranchPath() {
    final String codeSystemId = "cs3";
    final Map<String, Object> requestBody = prepareCodeSystemCreateRequestBody(codeSystemId);
    assertCodeSystemCreated(requestBody);
    final Json updateRequestBody = Json.object("branchPath", "non-existent-branch-path");
    assertCodeSystemUpdatedWithStatus(codeSystemId, updateRequestBody, 400);
}
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