examples/iot-nirvana/pipeline/src/test/java/com/google/cloud/demo/iot/nirvana/pipeline/MessageToTableRowTest.java
/** Test {@link MessageToTableRow.processElement} with multiple temperature messages. */
Test  MessageToTableRow.processElement with multiple temperature messages.
Test MessageToTableRow . processElement with multiple temperature messages .
@Test
  @Category(NeedsRunner.class)
  public void process_multipleTemperatures() throws Exception {
    List<Message> inputMessages = Arrays.asList(MESSAGE_TIRANA, MESSAGE_ORANJESTAD);
    List<TableRow> expectedResult = Arrays.asList(rowTirana, rowOranjestad);
    PCollection<TableRow> results =
        pipeline
            .apply("Create", Create.of(inputMessages))
            .apply("JsonToTableRow", ParDo.of(new MessageToTableRow(PARIS_TIME_ZONE)));
    PAssert.that(results).containsInAnyOrder(expectedResult);
    pipeline.run();
  }
@ Test @ Category ( NeedsRunner . class ) public void process_multipleTemperatures ( ) throws Exception { List < Message > inputMessages = Arrays . asList ( MESSAGE_TIRANA , MESSAGE_ORANJESTAD ) ; List < TableRow > expectedResult = Arrays . asList ( rowTirana , rowOranjestad ) ; PCollection < TableRow > results = pipeline . apply ( "Create" , Create . of ( inputMessages ) ) . apply ( "JsonToTableRow" , ParDo . of ( new MessageToTableRow ( PARIS_TIME_ZONE ) ) ) ; PAssert . that ( results ) . containsInAnyOrder ( expectedResult ) ; pipeline . run ( ) ; }
Test {@link MessageToTableRow.processElement} with multiple temperature messages.
Test { @link MessageToTableRow . processElement } with multiple temperature messages .
// Create test data // Run the test // Check the results