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