Search in sources :

Example 1 with TimerOrElementCoder

use of org.apache.beam.runners.dataflow.worker.util.TimerOrElement.TimerOrElementCoder in project beam by apache.

the class TimerOrElementTest method testCoderCanBeDecodedFromCloudObject.

@Test
public void testCoderCanBeDecodedFromCloudObject() {
    CloudObject cloudObject = CloudObject.forClassName("com.google.cloud.dataflow.sdk.util.TimerOrElement$TimerOrElementCoder");
    List<CloudObject> component = Collections.singletonList(CloudObjects.asCloudObject(KvCoder.of(VarLongCoder.of(), ByteArrayCoder.of()), /*sdkComponents=*/
    null));
    Structs.addList(cloudObject, PropertyNames.COMPONENT_ENCODINGS, component);
    Coder<?> decoded = CloudObjects.coderFromCloudObject(cloudObject);
    assertThat(decoded, instanceOf(TimerOrElementCoder.class));
    TimerOrElementCoder<?> decodedCoder = (TimerOrElementCoder<?>) decoded;
    assertThat(decodedCoder.getKeyCoder(), equalTo(VarLongCoder.of()));
    assertThat(decodedCoder.getElementCoder(), equalTo(ByteArrayCoder.of()));
}
Also used : TimerOrElementCoder(org.apache.beam.runners.dataflow.worker.util.TimerOrElement.TimerOrElementCoder) CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) Test(org.junit.Test)

Aggregations

CloudObject (org.apache.beam.runners.dataflow.util.CloudObject)1 TimerOrElementCoder (org.apache.beam.runners.dataflow.worker.util.TimerOrElement.TimerOrElementCoder)1 Test (org.junit.Test)1