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