Replace `createMock(Buildable.class)` with `new FakeBuildable()`.
Summary: As promised, I am trying to address my abuse of mocks by replacing them with fakes.
Test Plan: Sandcastle builds.
diff --git a/test/com/facebook/buck/rules/BUCK b/test/com/facebook/buck/rules/BUCK
index 160c7e5..5c72a7e 100644
--- a/test/com/facebook/buck/rules/BUCK
+++ b/test/com/facebook/buck/rules/BUCK
@@ -3,6 +3,7 @@
srcs = [
'BuildRuleParamsFactory.java',
'FakeAbstractBuildRuleBuilderParams.java',
+ 'FakeBuildable.java',
'FakeBuildableContext.java',
'FakeBuildRule.java',
'FakeBuildRuleParams.java',
diff --git a/test/com/facebook/buck/rules/FakeBuildable.java b/test/com/facebook/buck/rules/FakeBuildable.java
new file mode 100644
index 0000000..658a725
--- /dev/null
+++ b/test/com/facebook/buck/rules/FakeBuildable.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2013-present Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.facebook.buck.rules;
+
+import com.facebook.buck.step.Step;
+import com.google.common.collect.ImmutableList;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+public class FakeBuildable extends AbstractBuildable {
+
+ @Nullable
+ private String pathToOutputFile;
+
+ @Override
+ public Iterable<String> getInputsToCompareToOutput() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public List<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext)
+ throws IOException {
+ return ImmutableList.of();
+ }
+
+ @Override
+ @Nullable
+ public String getPathToOutputFile() {
+ return pathToOutputFile;
+ }
+
+ /** @return this */
+ public FakeBuildable setPathToOutputFile(@Nullable String pathToOutputFile) {
+ this.pathToOutputFile = pathToOutputFile;
+ return this;
+ }
+
+}
diff --git a/test/com/facebook/buck/rules/OnDiskBuildInfoTest.java b/test/com/facebook/buck/rules/OnDiskBuildInfoTest.java
index 6c9d0ee..aad3bd6 100644
--- a/test/com/facebook/buck/rules/OnDiskBuildInfoTest.java
+++ b/test/com/facebook/buck/rules/OnDiskBuildInfoTest.java
@@ -42,8 +42,7 @@
"com/example/Foo.class e4fccb7520b7795e632651323c63217c9f59f72a");
expect(projectFilesystem.readLines(Paths.get(pathToOutputFile))).andReturn(lines);
- Buildable buildable = createMock(Buildable.class);
- expect(buildable.getPathToOutputFile()).andReturn(pathToOutputFile);
+ Buildable buildable = new FakeBuildable().setPathToOutputFile(pathToOutputFile);
replayAll();
@@ -75,11 +74,7 @@
new BuildTarget("//java/com/example", "ex"),
projectFilesystem);
- Buildable buildable = createMock(Buildable.class);
- expect(buildable.getPathToOutputFile()).andReturn(null);
-
- replayAll();
-
+ Buildable buildable = new FakeBuildable();
onDiskBuildInfo.getOutputFileContentsByLine(buildable);
}