Search in sources :

Example 1 with FhirResource

use of com.b2international.snowowl.fhir.core.model.FhirResource 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 2 with FhirResource

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

the class BundleTest method buildResourceRequestBundle.

@Test
public void buildResourceRequestBundle() throws Exception {
    CodeSystem codeSystem = CodeSystem.builder().status(PublicationStatus.ACTIVE).content(CodeSystemContentMode.COMPLETE).build();
    ResourceRequestEntry entry = ResourceRequestEntry.builder().request(BatchRequest.createPostRequest("/CodeSystem")).resource(codeSystem).build();
    Bundle bundle = Bundle.builder().language("en").total(1).type(BundleType.BATCH).addEntry(entry).addLink("self", "http://localhost:8080/snowowl/CodeSystem").build();
    assertEquals("en", bundle.getLanguage().getCodeValue());
    assertEquals(1, bundle.getTotal());
    assertEquals(BundleType.BATCH.getCode(), bundle.getType());
    Link link = bundle.getLink().iterator().next();
    assertEquals("self", link.getRelation());
    assertEquals("http://localhost:8080/snowowl/CodeSystem", link.getUrl().getUriValue());
    Entry bundleEntry = bundle.getItems().iterator().next();
    assertTrue(bundleEntry instanceof ResourceRequestEntry);
    ResourceRequestEntry requestEntry = (ResourceRequestEntry) bundleEntry;
    BatchRequest batchRequest = requestEntry.getRequest();
    assertEquals(HttpVerb.POST.getCode(), batchRequest.getMethod());
    assertEquals("/CodeSystem", batchRequest.getUrl().getUriValue());
    FhirResource readCodeSystem = requestEntry.getRequestResource();
    assertTrue(readCodeSystem instanceof CodeSystem);
    String bundleString = objectMapper.writeValueAsString(bundle);
    Bundle readBundle = objectMapper.readValue(bundleString, Bundle.class);
    assertTrue(readBundle.getEntry().iterator().next() instanceof ResourceRequestEntry);
}
Also used : BatchRequest(com.b2international.snowowl.fhir.core.model.BatchRequest) ParametersRequestEntry(com.b2international.snowowl.fhir.core.model.ParametersRequestEntry) ParametersResponseEntry(com.b2international.snowowl.fhir.core.model.ParametersResponseEntry) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) Entry(com.b2international.snowowl.fhir.core.model.Entry) ResourceResponseEntry(com.b2international.snowowl.fhir.core.model.ResourceResponseEntry) OperationOutcomeEntry(com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry) 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) Link(com.b2international.snowowl.fhir.core.model.Link) ResourceRequestEntry(com.b2international.snowowl.fhir.core.model.ResourceRequestEntry) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with FhirResource

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

the class BundleTest method deserializeResourceBundle.

@Test
public void deserializeResourceBundle() 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)

Aggregations

Bundle (com.b2international.snowowl.fhir.core.model.Bundle)3 FhirResource (com.b2international.snowowl.fhir.core.model.FhirResource)3 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)3 CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)3 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)3 Test (org.junit.Test)3 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 ResourceResponseEntry (com.b2international.snowowl.fhir.core.model.ResourceResponseEntry)1