@Test(expected = IllegalArgumentException.class) @Category(NeedsRunner.class) public void testComplexCastFail() throws Exception { Schema inputSchema = pipeline.getSchemaRegistry().getSchema(All1.class); Schema outputSchema = pipeline.getSchemaRegistry().getSchema(All2.class); Cast.widening(outputSchema).verifyCompatibility(inputSchema); }
@Test(expected = IllegalArgumentException.class) @Category(NeedsRunner.class) public void testWeakedNullableFail() throws Exception { Schema inputSchema = pipeline.getSchemaRegistry().getSchema(Nullable1.class); Schema outputSchema = pipeline.getSchemaRegistry().getSchema(Nullable2.class); Cast.widening(outputSchema).verifyCompatibility(inputSchema); }
@Test(expected = IllegalArgumentException.class) @Category(NeedsRunner.class) public void testIgnoreNullableFail() throws Exception { // ignoring nullable is opposite of weakening Schema inputSchema = pipeline.getSchemaRegistry().getSchema(Nullable2.class); Schema outputSchema = pipeline.getSchemaRegistry().getSchema(Nullable1.class); Cast.widening(outputSchema).verifyCompatibility(inputSchema); }
@Test @Category(NeedsRunner.class) public void testProjection() throws Exception { Schema outputSchema = pipeline.getSchemaRegistry().getSchema(Projection2.class); PCollection<Projection2> pojos = pipeline .apply(Create.of(new Projection1())) .apply(Cast.widening(outputSchema)) .apply(Convert.to(Projection2.class)); PAssert.that(pojos).containsInAnyOrder(new Projection2()); pipeline.run(); }
@Test @Category(NeedsRunner.class) public void testTypeWiden() throws Exception { Schema outputSchema = pipeline.getSchemaRegistry().getSchema(TypeWiden2.class); PCollection<TypeWiden2> pojos = pipeline .apply(Create.of(new TypeWiden1())) .apply(Cast.widening(outputSchema)) .apply(Convert.to(TypeWiden2.class)); PAssert.that(pojos).containsInAnyOrder(new TypeWiden2()); pipeline.run(); }