Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added StackAPI interface and StackMockAPI alternative
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package net.zomis.duga | ||
|
||
interface StackAPI { | ||
def apiCall(String apiCall, String site, String filter) throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/integration-test/groovy/net/zomis/duga/tasks/qscan/StackMockAPI.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package net.zomis.duga.tasks.qscan | ||
|
||
import net.zomis.duga.StackAPI | ||
|
||
class StackMockAPI implements StackAPI { | ||
|
||
Map results = [:] | ||
|
||
StackMockAPI expect(String apiCall, def result) { | ||
results.put(apiCall, result) | ||
this | ||
} | ||
|
||
@Override | ||
def apiCall(String apiCall, String site, String filter) throws IOException { | ||
def result = results.get(apiCall) | ||
assert result : "No mock result defined for $apiCall. Keys are ${results.keySet()}" | ||
result | ||
} | ||
|
||
} |