Search in sources :

Example 1 with ExtractAndSumScore

use of com.google.cloud.dataflow.examples.complete.game.UserScore.ExtractAndSumScore in project DataflowJavaSDK-examples by GoogleCloudPlatform.

the class UserScoreTest method testTeamScoreSums.

/** Tests ExtractAndSumScore("team"). */
@Test
@Category(ValidatesRunner.class)
public void testTeamScoreSums() throws Exception {
    PCollection<String> input = p.apply(Create.of(GAME_EVENTS).withCoder(StringUtf8Coder.of()));
    PCollection<KV<String, Integer>> output = input.apply(ParDo.of(new ParseEventFn())).apply("ExtractTeamScore", new ExtractAndSumScore("team"));
    // Check the team score sums.
    PAssert.that(output).containsInAnyOrder(TEAM_SUMS);
    p.run().waitUntilFinish();
}
Also used : ExtractAndSumScore(com.google.cloud.dataflow.examples.complete.game.UserScore.ExtractAndSumScore) KV(org.apache.beam.sdk.values.KV) ParseEventFn(com.google.cloud.dataflow.examples.complete.game.UserScore.ParseEventFn) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 2 with ExtractAndSumScore

use of com.google.cloud.dataflow.examples.complete.game.UserScore.ExtractAndSumScore in project DataflowJavaSDK-examples by GoogleCloudPlatform.

the class UserScoreTest method testUserScoreSums.

/** Tests ExtractAndSumScore("user"). */
@Test
@Category(ValidatesRunner.class)
public void testUserScoreSums() throws Exception {
    PCollection<String> input = p.apply(Create.of(GAME_EVENTS).withCoder(StringUtf8Coder.of()));
    PCollection<KV<String, Integer>> output = input.apply(ParDo.of(new ParseEventFn())).apply("ExtractUserScore", new ExtractAndSumScore("user"));
    // Check the user score sums.
    PAssert.that(output).containsInAnyOrder(USER_SUMS);
    p.run().waitUntilFinish();
}
Also used : ExtractAndSumScore(com.google.cloud.dataflow.examples.complete.game.UserScore.ExtractAndSumScore) KV(org.apache.beam.sdk.values.KV) ParseEventFn(com.google.cloud.dataflow.examples.complete.game.UserScore.ParseEventFn) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

ExtractAndSumScore (com.google.cloud.dataflow.examples.complete.game.UserScore.ExtractAndSumScore)2 ParseEventFn (com.google.cloud.dataflow.examples.complete.game.UserScore.ParseEventFn)2 KV (org.apache.beam.sdk.values.KV)2 Test (org.junit.Test)2 Category (org.junit.experimental.categories.Category)2