Search in sources :

Example 1 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class SandBoxRestTest method createCodeSystem.

// @Test
public void createCodeSystem() throws Exception {
    File jsonFilePath = PlatformUtil.toAbsolutePathBundleEntry(this.getClass(), "/src/com/b2international/snowowl/fhir/tests/test_codesystem.json").toFile();
    System.out.println(jsonFilePath);
    CodeSystem codeSystem = objectMapper.readValue(jsonFilePath, CodeSystem.class);
    printPrettyJson(codeSystem);
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(ContentType.JSON).body(codeSystem).when().post("/CodeSystem").then().statusCode(200);
    givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).when().get(CODESYSTEM).prettyPrint();
}
Also used : File(java.io.File) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)

Example 2 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BundleTest method serialize.

@Test
public void serialize() throws JsonProcessingException {
    FhirResource resource = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    String resourceString = objectMapper.writeValueAsString(resource);
    CodeSystem fhirResource = objectMapper.readValue(resourceString, CodeSystem.class);
    assertEquals(null, fhirResource.getId());
    ResourceRequestEntry entry = ResourceRequestEntry.builder().resource(resource).request(BatchRequest.createPostRequest("/url")).build();
    Bundle bundle = Bundle.builder().type(BundleType.BATCH).entry(ImmutableList.of(entry)).build();
    String bundleString = objectMapper.writeValueAsString(bundle);
    Bundle readBundle = objectMapper.readValue(bundleString, Bundle.class);
    assertEquals(null, readBundle.getId());
}
Also used : FhirResource(com.b2international.snowowl.fhir.core.model.FhirResource) Bundle(com.b2international.snowowl.fhir.core.model.Bundle) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class BundleTest method serializeResourceBundle.

@Test
public void serializeResourceBundle() throws Exception {
    CodeSystem codeSystem = CodeSystem.builder("repo/shortName").status(PublicationStatus.ACTIVE).name("Local code system").content(CodeSystemContentMode.COMPLETE).url(new Uri("code system uri")).build();
    ResourceResponseEntry entry = ResourceResponseEntry.builder().fullUrl("full_Url").response(BatchResponse.createOkResponse()).resource(codeSystem).build();
    Bundle bundle = Bundle.builder("bundle_Id?").language("en").total(1).type(BundleType.SEARCHSET).addLink("self", "http://localhost:8080/snowowl/CodeSystem").addEntry(entry).build();
    applyFilter(bundle);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(bundle));
    assertThat(jsonPath.getString("resourceType"), equalTo("Bundle"));
    assertThat(jsonPath.getString("id"), equalTo("bundle_Id?"));
    assertThat(jsonPath.getString("language"), equalTo("en"));
    assertThat(jsonPath.getString("type"), equalTo("searchset"));
    assertThat(jsonPath.getInt("total"), equalTo(1));
    jsonPath.setRoot("link[0]");
    assertThat(jsonPath.getString("relation"), equalTo("self"));
    assertThat(jsonPath.getString("url"), equalTo("http://localhost:8080/snowowl/CodeSystem"));
    jsonPath.setRoot("entry[0]");
    assertThat(jsonPath.getString("fullUrl"), equalTo("full_Url"));
    assertThat(jsonPath.getString("response.status"), equalTo("200"));
    jsonPath.setRoot("entry[0].resource");
    assertThat(jsonPath.getString("resourceType"), equalTo("CodeSystem"));
    assertThat(jsonPath.getString("id"), equalTo("repo/shortName"));
    assertThat(jsonPath.getString("url"), equalTo("code system uri"));
    assertThat(jsonPath.getString("name"), equalTo("Local code system"));
    assertThat(jsonPath.getString("status"), equalTo("active"));
    assertThat(jsonPath.getString("content"), equalTo("complete"));
}
Also used : Bundle(com.b2international.snowowl.fhir.core.model.Bundle) ResourceResponseEntry(com.b2international.snowowl.fhir.core.model.ResourceResponseEntry) JsonPath(io.restassured.path.json.JsonPath) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 4 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class CodeSystemTest method serializeMinimalCodeSystem.

@Test
public void serializeMinimalCodeSystem() throws Exception {
    CodeSystem codeSystem = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    applyFilter(codeSystem);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(codeSystem));
    assertThat(jsonPath.getString("resourceType"), equalTo("CodeSystem"));
    assertThat(jsonPath.getString("status"), equalTo("active"));
    assertThat(jsonPath.getString("content"), equalTo("complete"));
    String expectedJson = "{\"resourceType\":\"CodeSystem\"," + "\"status\":\"active\"," + "\"content\":\"complete\"}";
    assertEquals(expectedJson, objectMapper.writeValueAsString(codeSystem));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 5 with CodeSystem

use of com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem in project snow-owl by b2ihealthcare.

the class CodeSystemTest method deserialize.

@Test
public void deserialize() throws Exception {
    CodeSystem codeSystem = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).date("2021-01-13T08:22:32+00:00").addContact(ContactDetail.builder().name("name").id("id").build()).build();
    CodeSystem readCodeSystem = objectMapper.readValue(objectMapper.writeValueAsString(codeSystem), CodeSystem.class);
    assertEquals(PublicationStatus.ACTIVE.getCode(), readCodeSystem.getStatus());
    assertEquals(CodeSystemContentMode.COMPLETE.getCode(), readCodeSystem.getContent());
    assertEquals(FhirDates.parseDate("2021-01-13T08:22:32+00:00"), readCodeSystem.getDate());
    assertEquals("name", readCodeSystem.getContacts().iterator().next().getName());
}
Also used : CodeSystem(com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)13 Test (org.junit.Test)10 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)9 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)4 FhirResource (com.b2international.snowowl.fhir.core.model.FhirResource)3 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)3 ResourceResponseEntry (com.b2international.snowowl.fhir.core.model.ResourceResponseEntry)3 JsonPath (io.restassured.path.json.JsonPath)3 Concept (com.b2international.snowowl.core.domain.Concept)2 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)2 ServiceProvider (com.b2international.snowowl.core.ServiceProvider)1 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)1 Concepts (com.b2international.snowowl.core.domain.Concepts)1 ConceptSearchRequestBuilder (com.b2international.snowowl.core.request.ConceptSearchRequestBuilder)1 BatchRequest (com.b2international.snowowl.fhir.core.model.BatchRequest)1 Entry (com.b2international.snowowl.fhir.core.model.Entry)1 Link (com.b2international.snowowl.fhir.core.model.Link)1 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)1 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)1 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)1