|
39 | 39 | import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; |
40 | 40 | import com.github.tomakehurst.wiremock.core.WireMockConfiguration; |
41 | 41 | import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; |
| 42 | +import com.google.common.io.ByteSink; |
42 | 43 | import com.google.edwmigration.dumper.application.dumper.ConnectorArguments; |
43 | 44 | import com.google.edwmigration.dumper.application.dumper.task.MemoryByteSink; |
44 | 45 | import com.google.edwmigration.dumper.application.dumper.task.TaskRunContext; |
|
53 | 54 | import java.time.format.DateTimeFormatter; |
54 | 55 | import java.util.Arrays; |
55 | 56 | import java.util.Date; |
| 57 | +import javax.annotation.Nonnull; |
56 | 58 | import org.apache.oozie.client.AuthOozieClient; |
57 | 59 | import org.apache.oozie.client.WorkflowJob; |
58 | 60 | import org.apache.oozie.client.XOozieClient; |
@@ -128,7 +130,7 @@ public void doRun_requestBatchesUntilFullDateRangeFetched_ok() throws Exception |
128 | 130 | task.doRun(context, sink, new OozieHandle(oozieClient)); |
129 | 131 |
|
130 | 132 | // Assert |
131 | | - String actual = sink.getContent(); |
| 133 | + String actual = getContent(sink); |
132 | 134 | String expected = readFileAsString("/oozie/expected-jobs-all-in-range-byenddate.csv"); |
133 | 135 | assertEquals(expected, actual); |
134 | 136 | } |
@@ -188,7 +190,7 @@ public void doRun_requestBatchesFilterOnClient_ok() throws Exception { |
188 | 190 | task.doRun(context, sink, new OozieHandle(oozieClient)); |
189 | 191 |
|
190 | 192 | // Assert |
191 | | - String actual = sink.getContent(); |
| 193 | + String actual = getContent(sink); |
192 | 194 | String expected = |
193 | 195 | readFileAsString("/oozie/expected-jobs-filtered-by-range-sorted-byenddate.csv"); |
194 | 196 | assertEquals(expected, actual); |
@@ -237,7 +239,7 @@ public void doRun_requestBatchesFilterOnClient_nullDate_success() throws Excepti |
237 | 239 | task.doRun(context, sink, new OozieHandle(oozieClient)); |
238 | 240 |
|
239 | 241 | // Assert |
240 | | - String actual = sink.getContent(); |
| 242 | + String actual = getContent(sink); |
241 | 243 | String expected = readFileAsString("/oozie/expected-jobs-one-job-from-template.csv"); |
242 | 244 | assertEquals(expected, actual); |
243 | 245 | } |
@@ -329,7 +331,7 @@ private void testWithBatchSize(int batchSize) throws Exception { |
329 | 331 | task.doRun(context, sink, new OozieHandle(oozieClient)); |
330 | 332 |
|
331 | 333 | // Assert |
332 | | - String actual = sink.getContent(); |
| 334 | + String actual = getContent(sink); |
333 | 335 | String expected = readFileAsString("/oozie/expected-jobs.csv"); |
334 | 336 | assertEquals(expected, actual); |
335 | 337 | } |
@@ -440,6 +442,10 @@ private String readFileAsString(String fileName) throws IOException, URISyntaxEx |
440 | 442 | return new String(Files.readAllBytes(Paths.get(this.getClass().getResource(fileName).toURI()))); |
441 | 443 | } |
442 | 444 |
|
| 445 | + private static String getContent(@Nonnull ByteSink sink) throws IOException { |
| 446 | + return sink.openStream().toString(); |
| 447 | + } |
| 448 | + |
443 | 449 | private static String toISO(ZonedDateTime dateTime) { |
444 | 450 | return ISO8601_UTC_FORMAT.format(dateTime.toInstant()); |
445 | 451 | } |
|
0 commit comments