Skip to content

Commit

Permalink
Avoid fully qualified class names, when there is an existing (static)…
Browse files Browse the repository at this point in the history
… import

Fixing build
  • Loading branch information
coheigea committed May 31, 2018
1 parent a0d1ad1 commit f620e9c
Show file tree
Hide file tree
Showing 66 changed files with 206 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public static void createJar(File dir, File jarFile) throws IOException {
}
}

final java.nio.file.Path root = dir.toPath();
final Path root = dir.toPath();
Files.walkFileTree(root, new java.nio.file.SimpleFileVisitor<Path>() {
String relativePath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected Launcher<?> getApexLauncher() {
@Override
public AppHandle launchApp(StreamingApplication application,
Configuration configuration, AttributeMap launchParameters)
throws org.apache.apex.api.Launcher.LauncherException {
throws Launcher.LauncherException {
EmbeddedAppLauncher<?> embeddedLauncher = Launcher.getLauncher(LaunchMode.EMBEDDED);
DAG dag = embeddedLauncher.getDAG();
application.populateDAG(dag, new Configuration(false));
Expand All @@ -107,7 +107,7 @@ public boolean isFinished() {
return true;
}
@Override
public void shutdown(org.apache.apex.api.Launcher.ShutdownMode arg0) {
public void shutdown(Launcher.ShutdownMode arg0) {
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void toAndFromProto() throws Exception {
Coder<?> decodedCoder =
CoderTranslation.fromProto(
coderProto, RehydratedComponents.forComponents(encodedComponents));
assertThat(decodedCoder, Matchers.equalTo(coder));
assertThat(decodedCoder, equalTo(coder));

if (KNOWN_CODERS.contains(coder)) {
for (RunnerApi.Coder encodedCoder : encodedComponents.getCodersMap().values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.values.PCollection.IsBounded;
import org.apache.beam.sdk.values.WindowingStrategy;
import org.hamcrest.Matchers;
import org.joda.time.Duration;
import org.joda.time.Instant;
import org.junit.Test;
Expand Down Expand Up @@ -124,10 +123,10 @@ public void testEncodeDecodeCycle() throws Exception {
PCollectionTranslation.fromProto(protoCollection, pipeline, protoComponents);

// Verify
assertThat(decodedCollection.getCoder(), Matchers.equalTo(testCollection.getCoder()));
assertThat(decodedCollection.getCoder(), equalTo(testCollection.getCoder()));
assertThat(
decodedCollection.getWindowingStrategy(),
Matchers.equalTo(testCollection.getWindowingStrategy().fixDefaults()));
equalTo(testCollection.getWindowingStrategy().fixDefaults()));
assertThat(decodedCollection.isBounded(), equalTo(testCollection.isBounded()));
}

Expand All @@ -143,9 +142,9 @@ public void testEncodeDecodeFields() throws Exception {
protoComponents.getWindowingStrategy(protoCollection.getWindowingStrategyId());
IsBounded decodedIsBounded = PCollectionTranslation.isBounded(protoCollection);

assertThat(decodedCoder, Matchers.equalTo(testCollection.getCoder()));
assertThat(decodedCoder, equalTo(testCollection.getCoder()));
assertThat(
decodedStrategy, Matchers.equalTo(testCollection.getWindowingStrategy().fixDefaults()));
decodedStrategy, equalTo(testCollection.getWindowingStrategy().fixDefaults()));
assertThat(decodedIsBounded, equalTo(testCollection.isBounded()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.apache.beam.sdk.values.PValue;
import org.apache.beam.sdk.values.TupleTag;
import org.apache.beam.sdk.values.TupleTagList;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -114,9 +113,9 @@ public void testToAndFromProto() throws Exception {
SdkComponents components = SdkComponents.create();
ParDoPayload payload = ParDoTranslation.translateParDo(parDo, p, components);

assertThat(ParDoTranslation.getDoFn(payload), Matchers.equalTo(parDo.getFn()));
assertThat(ParDoTranslation.getDoFn(payload), equalTo(parDo.getFn()));
assertThat(
ParDoTranslation.getMainOutputTag(payload), Matchers.equalTo(parDo.getMainOutputTag()));
ParDoTranslation.getMainOutputTag(payload), equalTo(parDo.getMainOutputTag()));
for (PCollectionView<?> view : parDo.getSideInputs()) {
payload.getSideInputsOrThrow(view.getTagInternal().getId());
}
Expand Down Expand Up @@ -152,14 +151,14 @@ public void toAndFromTransformProto() throws Exception {
view.getPCollection(),
protoTransform,
rehydratedComponents);
assertThat(restoredView.getTagInternal(), Matchers.equalTo(view.getTagInternal()));
assertThat(restoredView.getTagInternal(), equalTo(view.getTagInternal()));
assertThat(restoredView.getViewFn(), instanceOf(view.getViewFn().getClass()));
assertThat(
restoredView.getWindowMappingFn(), instanceOf(view.getWindowMappingFn().getClass()));
assertThat(
restoredView.getWindowingStrategyInternal(),
Matchers.equalTo(view.getWindowingStrategyInternal().fixDefaults()));
assertThat(restoredView.getCoderInternal(), Matchers.equalTo(view.getCoderInternal()));
equalTo(view.getWindowingStrategyInternal().fixDefaults()));
assertThat(restoredView.getCoderInternal(), equalTo(view.getCoderInternal()));
}
String mainInputId = sdkComponents.registerPCollection(mainInput);
assertThat(
Expand Down Expand Up @@ -199,7 +198,7 @@ public void testStateSpecToFromProto() throws Exception {
StateSpec<?> deserializedStateSpec =
ParDoTranslation.fromProto(stateSpecProto, rehydratedComponents);

assertThat(stateSpec, Matchers.equalTo(deserializedStateSpec));
assertThat(stateSpec, equalTo(deserializedStateSpec));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.beam.sdk.io.UnboundedSource;
import org.apache.beam.sdk.io.UnboundedSource.CheckpointMark;
import org.apache.beam.sdk.options.PipelineOptions;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -77,7 +76,7 @@ public void testToFromProtoBounded() throws Exception {
ReadPayload payload = ReadTranslation.toProto(boundedRead, SdkComponents.create());
assertThat(payload.getIsBounded(), equalTo(RunnerApi.IsBounded.Enum.BOUNDED));
BoundedSource<?> deserializedSource = ReadTranslation.boundedSourceFromProto(payload);
assertThat(deserializedSource, Matchers.equalTo(source));
assertThat(deserializedSource, equalTo(source));
}

@Test
Expand All @@ -88,7 +87,7 @@ public void testToFromProtoUnbounded() throws Exception {
ReadPayload payload = ReadTranslation.toProto(unboundedRead, SdkComponents.create());
assertThat(payload.getIsBounded(), equalTo(RunnerApi.IsBounded.Enum.UNBOUNDED));
UnboundedSource<?, ?> deserializedSource = ReadTranslation.unboundedSourceFromProto(payload);
assertThat(deserializedSource, Matchers.equalTo(source));
assertThat(deserializedSource, equalTo(source));
}

private static class TestBoundedSource extends BoundedSource<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public void singletonSucceeds() {

ReplacementOutput replacement = replacements.get(replacementInts);
Map.Entry<TupleTag<?>, PValue> taggedInts = Iterables.getOnlyElement(ints.expand().entrySet());
assertThat(replacement.getOriginal().getTag(), Matchers.equalTo(taggedInts.getKey()));
assertThat(replacement.getOriginal().getTag(), equalTo(taggedInts.getKey()));
assertThat(replacement.getOriginal().getValue(), equalTo(taggedInts.getValue()));
assertThat(replacement.getReplacement().getValue(), Matchers.equalTo(replacementInts));
assertThat(replacement.getReplacement().getValue(), equalTo(replacementInts));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.values.WindowingStrategy;
import org.apache.beam.sdk.values.WindowingStrategy.AccumulationMode;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -78,7 +77,7 @@ public void registerCoderEqualsNotSame() throws IOException {
KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of())));
Coder<?> otherCoder =
KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of())));
assertThat(coder, Matchers.equalTo(otherCoder));
assertThat(coder, equalTo(otherCoder));
String id = components.registerCoder(coder);
String otherId = components.registerCoder(otherCoder);
assertThat(otherId, not(equalTo(id)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.beam.sdk.values.PBegin;
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.values.TimestampedValue;
import org.hamcrest.Matchers;
import org.joda.time.Duration;
import org.joda.time.Instant;
import org.junit.Test;
Expand Down Expand Up @@ -103,7 +102,7 @@ private static <T> void verifyTestStreamEncoding(
// This reverse direction is only valid for Java-based coders
assertThat(
protoComponents.getCoder(payload.getCoderId()),
Matchers.equalTo(testStream.getValueCoder()));
equalTo(testStream.getValueCoder()));

assertThat(payload.getEventsList().size(), equalTo(testStream.getEvents().size()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.beam.sdk.transforms.windowing.WindowFn;
import org.apache.beam.sdk.values.WindowingStrategy;
import org.apache.beam.sdk.values.WindowingStrategy.AccumulationMode;
import org.hamcrest.Matchers;
import org.joda.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -113,7 +112,7 @@ public void testToProtoAndBackWithComponents() throws Exception {

assertThat(
WindowingStrategyTranslation.fromProto(proto, protoComponents).fixDefaults(),
Matchers.equalTo(windowingStrategy.fixDefaults()));
equalTo(windowingStrategy.fixDefaults()));

protoComponents.getCoder(
components.registerCoder(windowingStrategy.getWindowFn().windowCoder()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ public void testOnlyOneOnTimePane() throws Exception {
List<WindowedValue<Integer>> output = tester.extractOutput();
assertEquals(2, output.size());

assertThat(output.get(0), WindowMatchers.isWindowedValue(equalTo(value1)));
assertThat(output.get(1), WindowMatchers.isWindowedValue(equalTo(value1 + value2)));
assertThat(output.get(0), isWindowedValue(equalTo(value1)));
assertThat(output.get(1), isWindowedValue(equalTo(value1 + value2)));

assertThat(
output.get(0),
Expand Down Expand Up @@ -692,7 +692,7 @@ public void testOnElementCombiningWithContext() throws Exception {
TestOptions options = PipelineOptionsFactory.as(TestOptions.class);
options.setValue(expectedValue);

when(mockSideInputReader.contains(org.mockito.Matchers.any(PCollectionView.class)))
when(mockSideInputReader.contains(any(PCollectionView.class)))
.thenReturn(true);
when(mockSideInputReader.get(any(PCollectionView.class), any(BoundedWindow.class)))
.then(
Expand Down Expand Up @@ -1204,7 +1204,7 @@ public void testPaneInfoAllStatesAfterWatermark() throws Exception {
assertThat(
output,
contains(
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10)));
isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10)));

tester.advanceInputWatermark(new Instant(50));

Expand All @@ -1218,7 +1218,7 @@ public void testPaneInfoAllStatesAfterWatermark() throws Exception {
assertThat(
output,
contains(
WindowMatchers.isSingleWindowedValue(emptyIterable(), 9, 0, 10)));
isSingleWindowedValue(emptyIterable(), 9, 0, 10)));

// We should get the final pane even though it is empty.
tester.advanceInputWatermark(new Instant(150));
Expand All @@ -1230,7 +1230,7 @@ public void testPaneInfoAllStatesAfterWatermark() throws Exception {
assertThat(
output,
contains(
WindowMatchers.isSingleWindowedValue(emptyIterable(), 9, 0, 10)));
isSingleWindowedValue(emptyIterable(), 9, 0, 10)));
}

@Test
Expand All @@ -1255,9 +1255,9 @@ public void noEmptyPanesFinalIfNonEmpty() throws Exception {
List<WindowedValue<Iterable<Integer>>> output = tester.extractOutput();
assertThat(output, contains(
// Trigger with 2 elements
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10),
isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10),
// Trigger for the empty on time pane
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
}

@Test
Expand All @@ -1282,11 +1282,11 @@ public void noEmptyPanesFinalAlways() throws Exception {
List<WindowedValue<Iterable<Integer>>> output = tester.extractOutput();
assertThat(output, contains(
// Trigger with 2 elements
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10),
isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10),
// Trigger for the empty on time pane
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10),
isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10),
// Trigger for the final pane
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
}

/**
Expand Down Expand Up @@ -1361,7 +1361,7 @@ public void testPaneInfoAllStatesAfterWatermarkAccumulating() throws Exception {
assertThat(
output,
contains(
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10)));
isSingleWindowedValue(containsInAnyOrder(1, 2), 1, 0, 10)));

tester.advanceInputWatermark(new Instant(50));

Expand All @@ -1375,7 +1375,7 @@ public void testPaneInfoAllStatesAfterWatermarkAccumulating() throws Exception {
assertThat(
output,
contains(
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));

// We should get the final pane even though it is empty.
tester.advanceInputWatermark(new Instant(150));
Expand All @@ -1387,7 +1387,7 @@ public void testPaneInfoAllStatesAfterWatermarkAccumulating() throws Exception {
assertThat(
output,
contains(
WindowMatchers.isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
isSingleWindowedValue(containsInAnyOrder(1, 2), 9, 0, 10)));
}

@Test
Expand Down Expand Up @@ -1896,8 +1896,8 @@ public void testEmptyOnTimeFromOrFinally() throws Exception {
List<WindowedValue<Integer>> output = tester.extractOutput();
assertEquals(2, output.size());

assertThat(output.get(0), WindowMatchers.isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), WindowMatchers.isSingleWindowedValue(4, 9, 0, 10));
assertThat(output.get(0), isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), isSingleWindowedValue(4, 9, 0, 10));

assertThat(
output.get(0),
Expand Down Expand Up @@ -1953,8 +1953,8 @@ public void testEmptyOnTimeWithOnTimeBehaviorFireIfNonEmpty() throws Exception {
List<WindowedValue<Integer>> output = tester.extractOutput();
assertEquals(2, output.size());

assertThat(output.get(0), WindowMatchers.isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), WindowMatchers.isSingleWindowedValue(4, 9, 0, 10));
assertThat(output.get(0), isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), isSingleWindowedValue(4, 9, 0, 10));

assertThat(
output.get(0),
Expand Down Expand Up @@ -2053,8 +2053,8 @@ public void testEmptyOnTimeWithOnTimeBehaviorFireIfNonEmptyAndLateData() throws
List<WindowedValue<Integer>> output = tester.extractOutput();
assertEquals(2, output.size());

assertThat(output.get(0), WindowMatchers.isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), WindowMatchers.isSingleWindowedValue(5, 9, 0, 10));
assertThat(output.get(0), isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), isSingleWindowedValue(5, 9, 0, 10));

assertThat(
output.get(0),
Expand Down Expand Up @@ -2130,10 +2130,10 @@ public void testProcessingTime() throws Exception {
List<WindowedValue<Integer>> output = tester.extractOutput();
assertEquals(4, output.size());

assertThat(output.get(0), WindowMatchers.isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), WindowMatchers.isSingleWindowedValue(6, 4, 0, 10));
assertThat(output.get(2), WindowMatchers.isSingleWindowedValue(11, 9, 0, 10));
assertThat(output.get(3), WindowMatchers.isSingleWindowedValue(12, 9, 0, 10));
assertThat(output.get(0), isSingleWindowedValue(4, 1, 0, 10));
assertThat(output.get(1), isSingleWindowedValue(6, 4, 0, 10));
assertThat(output.get(2), isSingleWindowedValue(11, 9, 0, 10));
assertThat(output.get(3), isSingleWindowedValue(12, 9, 0, 10));

assertThat(
output.get(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.beam.sdk.util.WindowedValue;
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.values.PCollectionView;
import org.hamcrest.Matchers;
import org.joda.time.Instant;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -113,7 +112,7 @@ public void processElementSideInputNotReady() {
Iterable<WindowedValue<Integer>> oneWindowPushback =
runner.processElementInReadyWindows(oneWindow);
assertThat(oneWindowPushback, containsInAnyOrder(oneWindow));
assertThat(underlying.inputElems, Matchers.emptyIterable());
assertThat(underlying.inputElems, emptyIterable());
}

@Test
Expand All @@ -136,7 +135,7 @@ public void processElementSideInputNotReadyMultipleWindows() {
Iterable<WindowedValue<Integer>> multiWindowPushback =
runner.processElementInReadyWindows(multiWindow);
assertThat(multiWindowPushback, equalTo(multiWindow.explodeWindows()));
assertThat(underlying.inputElems, Matchers.emptyIterable());
assertThat(underlying.inputElems, emptyIterable());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testValue() throws Exception {
assertThat(underTest.state(NAMESPACE_1, STRING_VALUE_ADDR), equalTo(value));
assertThat(
underTest.state(NAMESPACE_2, STRING_VALUE_ADDR),
Matchers.not(equalTo(value)));
not(equalTo(value)));

assertThat(value.read(), Matchers.nullValue());
value.write("hello");
Expand Down
Loading

0 comments on commit f620e9c

Please sign in to comment.