use of com.b2international.snowowl.fhir.core.model.ResourceRequestEntry 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.ResourceRequestEntry 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);
}
use of com.b2international.snowowl.fhir.core.model.ResourceRequestEntry 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());
}
Aggregations