Search in sources :

Example 1 with HL7v2MessagePages

use of org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages in project beam by apache.

the class HL7V2MessagePagesTest method test_EmptyStoreEmptyIterator.

/**
 * Test empty store.
 */
@Test
public void test_EmptyStoreEmptyIterator() throws IOException {
    Mockito.doReturn(new ListMessagesResponse()).when(client).makeSendTimeBoundHL7v2ListRequest("foo", null, null, null, null, null);
    HL7v2MessagePages emptyPages = new HL7v2MessagePages(client, "foo", null, null);
    // In the case that the store is empty we should return a single empty list.
    assertFalse(emptyPages.iterator().hasNext());
}
Also used : ListMessagesResponse(com.google.api.services.healthcare.v1.model.ListMessagesResponse) HL7v2MessagePages(org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages) Test(org.junit.Test)

Example 2 with HL7v2MessagePages

use of org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages in project beam by apache.

the class HL7V2MessagePagesTest method test_NonEmptyExpectedIterator.

/**
 * Test Non-empty with beta store list response store. This tests backwards compatibility with
 * Stores that return the deprecated messages field in list requests.
 */
@Test
public void test_NonEmptyExpectedIterator() throws IOException {
    ListMessagesResponse page0 = new ListMessagesResponse().setHl7V2Messages(Stream.of("foo0", "foo1", "foo2").map(HL7v2IOTestUtil::testMessage).collect(Collectors.toList())).setNextPageToken("page1");
    ListMessagesResponse page1 = new ListMessagesResponse().setHl7V2Messages(Stream.of("foo3", "foo4", "foo5").map(HL7v2IOTestUtil::testMessage).collect(Collectors.toList()));
    Mockito.doReturn(page0).when(client).makeSendTimeBoundHL7v2ListRequest("foo", null, null, null, null, null);
    Mockito.doReturn(page1).when(client).makeSendTimeBoundHL7v2ListRequest("foo", null, null, null, null, "page1");
    HL7v2MessagePages pages = new HL7v2MessagePages(client, "foo", null, null);
    assertTrue(pages.iterator().hasNext());
    Iterator<List<HL7v2Message>> pagesIterator = pages.iterator();
    assertEquals(page0.getHl7V2Messages().stream().map(Message::getName).collect(Collectors.toList()), pagesIterator.next().stream().map(HL7v2Message::getName).collect(Collectors.toList()));
    assertEquals(page1.getHl7V2Messages().stream().map(Message::getName).collect(Collectors.toList()), pagesIterator.next().stream().map(HL7v2Message::getName).collect(Collectors.toList()));
    assertFalse(pagesIterator.hasNext());
}
Also used : ListMessagesResponse(com.google.api.services.healthcare.v1.model.ListMessagesResponse) Message(com.google.api.services.healthcare.v1.model.Message) List(java.util.List) HL7v2MessagePages(org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages) Test(org.junit.Test)

Aggregations

ListMessagesResponse (com.google.api.services.healthcare.v1.model.ListMessagesResponse)2 HL7v2MessagePages (org.apache.beam.sdk.io.gcp.healthcare.HttpHealthcareApiClient.HL7v2MessagePages)2 Test (org.junit.Test)2 Message (com.google.api.services.healthcare.v1.model.Message)1 List (java.util.List)1