Skip to content

Commit

Permalink
Issue #1155 - updated bulkdata operation unit test
Browse files Browse the repository at this point in the history
Signed-off-by: John T.E. Timm <[email protected]>
  • Loading branch information
JohnTimm committed Jun 1, 2021
1 parent 507d30b commit 7f82d56
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import java.util.List;
import java.util.Map;

import jakarta.json.Json;
import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonGeneratorFactory;

import org.testng.annotations.Test;

import com.ibm.fhir.model.type.Instant;
import com.ibm.fhir.operation.bulkdata.model.PollingLocationResponse.Output;

import jakarta.json.Json;
import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonGeneratorFactory;

/**
* Simple Test for the Rough Response defined in the BulkData Export
*/
Expand All @@ -41,7 +41,7 @@ public void testOuptutSerialization() throws IOException {
PollingLocationResponse.Output output = new PollingLocationResponse.Output("test1", "test2", "3", "test4");
String actual = null;
String expected =
"\n{\n" + " \"type\": \"test1\",\n" + " \"url\": \"test2\",\n" + " \"count\": 3,\n"
"{\n" + " \"type\": \"test1\",\n" + " \"url\": \"test2\",\n" + " \"count\": 3,\n"
+ " \"inputUrl\": \"test4\"\n" + "}";
try (StringWriter writerx = new StringWriter();) {
try (JsonGenerator generator = PRETTY_PRINTING_GENERATOR_FACTORY.createGenerator(writerx);) {
Expand All @@ -59,7 +59,7 @@ public void testOuptutSerialization() throws IOException {
output.setType("OperationOutcome");

expected =
"\n{\n" + " \"type\": \"OperationOutcome\",\n" + " \"url\": \"3\",\n" + " \"count\": 1,\n"
"{\n" + " \"type\": \"OperationOutcome\",\n" + " \"url\": \"3\",\n" + " \"count\": 1,\n"
+ " \"inputUrl\": \"2\"\n" + "}";
try (StringWriter writerx = new StringWriter();) {
try (JsonGenerator generator = PRETTY_PRINTING_GENERATOR_FACTORY.createGenerator(writerx);) {
Expand All @@ -73,7 +73,7 @@ public void testOuptutSerialization() throws IOException {
// Test $export
output.setInputUrl(null);
expected =
"\n" + "{\n" + " \"type\": \"OperationOutcome\",\n" + " \"url\": \"3\",\n"
"{\n" + " \"type\": \"OperationOutcome\",\n" + " \"url\": \"3\",\n"
+ " \"count\": 1\n" + "}";
try (StringWriter writerx = new StringWriter();) {
try (JsonGenerator generator = PRETTY_PRINTING_GENERATOR_FACTORY.createGenerator(writerx);) {
Expand All @@ -87,7 +87,7 @@ public void testOuptutSerialization() throws IOException {
// Test $export
output = new PollingLocationResponse.Output("test1", "test2", "3");
expected =
"\n" + "{\n" + " \"type\": \"test1\",\n" + " \"url\": \"test2\",\n" + " \"count\": 3\n"
"{\n" + " \"type\": \"test1\",\n" + " \"url\": \"test2\",\n" + " \"count\": 3\n"
+ "}";
try (StringWriter writerx = new StringWriter();) {
try (JsonGenerator generator = PRETTY_PRINTING_GENERATOR_FACTORY.createGenerator(writerx);) {
Expand All @@ -102,7 +102,7 @@ public void testOuptutSerialization() throws IOException {

// Empty
output = new PollingLocationResponse.Output(null, null, null);
expected = "\n{\n}";
expected = "{\n}";
try (StringWriter writerx = new StringWriter();) {
try (JsonGenerator generator = PRETTY_PRINTING_GENERATOR_FACTORY.createGenerator(writerx);) {
PollingLocationResponse.Output.Writer.generate(generator, output);
Expand All @@ -116,7 +116,7 @@ public void testOuptutSerialization() throws IOException {
@Test
public void testResponseMetadataJsonEmpty() throws IOException {
PollingLocationResponse metadata = new PollingLocationResponse();
assertEquals(PollingLocationResponse.Writer.generate(metadata), "\n" + "{\n" + "}");
assertEquals(PollingLocationResponse.Writer.generate(metadata), "{\n" + "}");
}

@Test
Expand All @@ -130,7 +130,7 @@ public void testResponseMetadataJsonFull() throws IOException {
assertEquals(
PollingLocationResponse.Writer.generate(metadata)
.replaceFirst(s, ""),
"\n" + "{\n" + " \"transactionTime\": \"\",\n"
"{\n" + " \"transactionTime\": \"\",\n"
+ " \"request\": \"request\",\n" + " \"requiresAccessToken\": false\n" + "}");
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public void testResponseMetadataJsonFullWithOutput() throws IOException {
assertEquals(
PollingLocationResponse.Writer.generate(metadata)
.replaceFirst(s, ""),
"\n" + "{\n" + " \"transactionTime\": \"\",\n"
"{\n" + " \"transactionTime\": \"\",\n"
+ " \"request\": \"request\",\n" + " \"requiresAccessToken\": false,\n"
+ " \"output\": [\n" + " {\n" + " \"type\": \"type\",\n"
+ " \"url\": \"url\",\n" + " \"count\": 1000\n" + " },\n"
Expand Down Expand Up @@ -204,7 +204,7 @@ public void testResponseMetadataJsonFullWithOutputAndError() throws IOException
assertEquals(
PollingLocationResponse.Writer.generate(metadata)
.replaceFirst(s, ""),
"\n" + "{\n" + " \"transactionTime\": \"\",\n"
"{\n" + " \"transactionTime\": \"\",\n"
+ " \"request\": \"request\",\n" + " \"requiresAccessToken\": false,\n"
+ " \"output\": [\n" + " {\n" + " \"type\": \"type\",\n"
+ " \"url\": \"url\",\n" + " \"count\": 1000\n" + " },\n"
Expand Down

0 comments on commit 7f82d56

Please sign in to comment.