use of org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Collections2 in project beam by apache.
the class PipelineOptionsFactoryTest method testDescribe.
@Test
public void testDescribe() {
List<PipelineOptionDescriptor> described = PipelineOptionsFactory.describe(Sets.newHashSet(PipelineOptions.class, TestDescribeOptions.class));
Map<String, PipelineOptionDescriptor> mapped = uniqueIndex(described, input -> input.getName());
assertEquals("no duplicates", described.size(), mapped.size());
Collection<PipelineOptionDescriptor> filtered = Collections2.filter(described, input -> input.getGroup().equals(TestDescribeOptions.class.getName()));
assertEquals(6, filtered.size());
mapped = uniqueIndex(filtered, input -> input.getName());
PipelineOptionDescriptor listDesc = mapped.get("list");
assertThat(listDesc, notNullValue());
assertThat(listDesc.getDescription(), isEmptyString());
assertEquals(PipelineOptionType.Enum.ARRAY, listDesc.getType());
assertThat(listDesc.getDefaultValue(), isEmptyString());
PipelineOptionDescriptor stringDesc = mapped.get("string");
assertThat(stringDesc, notNullValue());
assertThat(stringDesc.getDescription(), isEmptyString());
assertEquals(PipelineOptionType.Enum.STRING, stringDesc.getType());
assertThat(stringDesc.getDefaultValue(), isEmptyString());
PipelineOptionDescriptor integerDesc = mapped.get("integer");
assertThat(integerDesc, notNullValue());
assertEquals("integer property", integerDesc.getDescription());
assertEquals(PipelineOptionType.Enum.INTEGER, integerDesc.getType());
assertThat(integerDesc.getDefaultValue(), isEmptyString());
PipelineOptionDescriptor floatDesc = mapped.get("float");
assertThat(integerDesc, notNullValue());
assertEquals("float number property", floatDesc.getDescription());
assertEquals(PipelineOptionType.Enum.NUMBER, floatDesc.getType());
assertThat(floatDesc.getDefaultValue(), isEmptyString());
PipelineOptionDescriptor booleanSimpleDesc = mapped.get("boolean_simple");
assertThat(booleanSimpleDesc, notNullValue());
assertEquals("simple boolean property", booleanSimpleDesc.getDescription());
assertEquals(PipelineOptionType.Enum.BOOLEAN, booleanSimpleDesc.getType());
assertThat(booleanSimpleDesc.getDefaultValue(), equalTo("true"));
PipelineOptionDescriptor booleanWrapperDesc = mapped.get("boolean_wrapper");
assertThat(booleanWrapperDesc, notNullValue());
assertThat(booleanWrapperDesc.getDescription(), isEmptyString());
assertEquals(PipelineOptionType.Enum.BOOLEAN, booleanWrapperDesc.getType());
assertThat(booleanWrapperDesc.getDefaultValue(), equalTo("false"));
}
Aggregations