Skip to content
This repository was archived by the owner on Nov 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import com.google.cloud.dataflow.sdk.values.TupleTag;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;

import org.hamcrest.Matchers;
Expand Down Expand Up @@ -817,10 +818,10 @@ public void processElement(ProcessContext c) throws Exception {
@Override
public void populateDisplayData(DisplayData.Builder builder) {
builder
.add("foo", "bar")
.add("foo2", DataflowPipelineTranslatorTest.class)
.withLabel("Test Class")
.withLinkUrl("http://www.google.com");
.add("foo", "bar")
.add("foo2", 123)
.withLabel("Test Value")
.withLinkUrl("http://www.google.com");
}
};

Expand All @@ -836,10 +837,12 @@ public void populateDisplayData(DisplayData.Builder builder) {
}
};

ParDo.Bound<Integer, Integer> parDo1 = ParDo.of(fn1);
ParDo.Bound<Integer, Integer> parDo2 = ParDo.of(fn2);
pipeline
.apply(Create.of(1, 2, 3))
.apply(ParDo.of(fn1))
.apply(ParDo.of(fn2));
.apply(parDo1)
.apply(parDo2);

Job job = translator.translate(
pipeline, pipeline.getRunner(), Collections.<DataflowPackage>emptyList()).getJob();
Expand All @@ -856,34 +859,33 @@ public void populateDisplayData(DisplayData.Builder builder) {
Collection<Map<String, String>> fn2displayData =
(Collection<Map<String, String>>) parDo2Properties.get("display_data");

ImmutableList expectedFn1DisplayData = ImmutableList.of(
ImmutableMap.<String, String>builder()
.put("namespace", fn1.getClass().getName())
.put("key", "foo")
.put("type", "STRING")
.put("value", "bar")
.build(),
ImmutableMap.<String, String>builder()
.put("namespace", fn1.getClass().getName())
.put("key", "foo2")
.put("type", "JAVA_CLASS")
.put("value", DataflowPipelineTranslatorTest.class.getName())
.put("shortValue", DataflowPipelineTranslatorTest.class.getSimpleName())
.put("label", "Test Class")
.put("linkUrl", "http://www.google.com")
.build()
ImmutableSet<ImmutableMap<String, String>> expectedFn1DisplayData = ImmutableSet.of(
ImmutableMap.<String, String>builder()
.put("key", "foo")
.put("type", "STRING")
.put("value", "bar")
.put("namespace", fn1.getClass().getName())
.build(),
ImmutableMap.<String, String>builder()
.put("key", "foo2")
.put("type", "INTEGER")
.put("value", "123")
.put("namespace", fn1.getClass().getName())
.put("label", "Test Value")
.put("linkUrl", "http://www.google.com")
.build()
);

ImmutableList expectedFn2DisplayData = ImmutableList.of(
ImmutableMap.<String, String>builder()
.put("namespace", fn2.getClass().getName())
.put("key", "foo3")
.put("type", "STRING")
.put("value", "barge")
.build()
ImmutableSet<ImmutableMap<String, String>> expectedFn2DisplayData = ImmutableSet.of(
ImmutableMap.<String, String>builder()
.put("key", "foo3")
.put("type", "STRING")
.put("value", "barge")
.put("namespace", fn2.getClass().getName())
.build()
);

assertEquals(expectedFn1DisplayData, fn1displayData);
assertEquals(expectedFn2DisplayData, fn2displayData);
assertEquals(expectedFn1DisplayData, ImmutableSet.copyOf(fn1displayData));
assertEquals(expectedFn2DisplayData, ImmutableSet.copyOf(fn2displayData));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -42,6 +44,7 @@
/**
* Tests for {@link EncodabilityEnforcementFactory}.
*/
@RunWith(JUnit4.class)
public class EncodabilityEnforcementFactoryTest {
@Rule public ExpectedException thrown = ExpectedException.none();
private EncodabilityEnforcementFactory factory = EncodabilityEnforcementFactory.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ public void populateDisplayData(Builder builder) {
});
}

@Test
public void testAcceptsNullOptionalValues() {
DisplayData.from(
new HasDisplayData() {
Expand Down