examples/dataflow-streaming-benchmark/src/test/java/com/google/cloud/pso/pipeline/StreamingBenchmarkTest.java
/** Tests the {@link MessageGeneratorFn} does not fail when given invalid schema. */
Tests the  MessageGeneratorFn does not fail when given invalid schema.
Tests the MessageGeneratorFn does not fail when given invalid schema .
@Test
  public void testMessageGeneratorInvalidSchema() throws IOException {
    String schema = "{\"name: \"Invalid\"";
    File file = tempFolder.newFile();
    writeToFile(file.getAbsolutePath(), Lists.newArrayList(schema));
     Act
    PCollection<PubsubMessage> results =
        pipeline
            .apply("CreateInput", Create.of(0L))
            .apply("GenerateMessage", ParDo.of(new MessageGeneratorFn(file.getAbsolutePath())));
     Assert
    PAssert.that(results).satisfies(input -> {
      PubsubMessage message = input.iterator().next();
      assertThat(message, is(notNullValue()));
      assertThat(new String(message.getPayload()), is(equalTo(schema)));
      return null;
    });
    pipeline.run();
  }
@ Test public void testMessageGeneratorInvalidSchema ( ) throws IOException { String schema = "{\"name: \"Invalid\"" ; File file = tempFolder . newFile ( ) ; writeToFile ( file . getAbsolutePath ( ) , Lists . newArrayList ( schema ) ) ; PCollection < PubsubMessage > results = pipeline . apply ( "CreateInput" , Create . of ( 0L ) ) . apply ( "GenerateMessage" , ParDo . of ( new MessageGeneratorFn ( file . getAbsolutePath ( ) ) ) ) ; PAssert . that ( results ) . satisfies ( input -> { PubsubMessage message = input . iterator ( ) . next ( ) ; assertThat ( message , is ( notNullValue ( ) ) ) ; assertThat ( new String ( message . getPayload ( ) ) , is ( equalTo ( schema ) ) ) ; return null ; } ) ; pipeline . run ( ) ; }
Tests the {@link MessageGeneratorFn} does not fail when given invalid schema.
Tests the { @link MessageGeneratorFn } does not fail when given invalid schema .
// Arrange // // Act // // Assert //