aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/reader/test/Test.java
diff options
context:
space:
mode:
authorJ08nY2017-10-25 18:58:52 +0200
committerJ08nY2017-10-25 18:58:52 +0200
commit69a4116df7b54ddfdaba2f8aa80ecb9e9a2ed9a7 (patch)
treeb0500700cddf9f228f5e79d74331831429b5b583 /src/cz/crcs/ectester/reader/test/Test.java
parentcd2a972ee05c88c2a83e7788839bbd657c2cf1c4 (diff)
downloadECTester-69a4116df7b54ddfdaba2f8aa80ecb9e9a2ed9a7.tar.gz
ECTester-69a4116df7b54ddfdaba2f8aa80ecb9e9a2ed9a7.tar.zst
ECTester-69a4116df7b54ddfdaba2f8aa80ecb9e9a2ed9a7.zip
Diffstat (limited to 'src/cz/crcs/ectester/reader/test/Test.java')
-rw-r--r--src/cz/crcs/ectester/reader/test/Test.java35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/cz/crcs/ectester/reader/test/Test.java b/src/cz/crcs/ectester/reader/test/Test.java
index f873c19..1890e94 100644
--- a/src/cz/crcs/ectester/reader/test/Test.java
+++ b/src/cz/crcs/ectester/reader/test/Test.java
@@ -29,8 +29,6 @@ public abstract class Test {
return hasRun;
}
- public abstract boolean ok();
-
public abstract void run() throws CardException;
@@ -49,17 +47,20 @@ public abstract class Test {
*/
public static class Simple extends Test {
private BiFunction<Command, Response, Result> callback;
- private Result expected;
private Command command;
private Response response;
public Simple(Command command, Result expected) {
- this.command = command;
- this.expected = expected;
+ this(command, (cmd, resp) -> {
+ if (expected == Result.ANY)
+ return Result.SUCCESS;
+ Result respResult = resp.successful() ? Result.SUCCESS : Result.FAILURE;
+ return respResult == expected ? Result.SUCCESS : Result.FAILURE;
+ });
}
- public Simple(Command command, Result expected, BiFunction<Command, Response, Result> callback) {
- this(command, expected);
+ public Simple(Command command, BiFunction<Command, Response, Result> callback) {
+ this.command = command;
this.callback = callback;
}
@@ -71,17 +72,11 @@ public abstract class Test {
return response;
}
- public Result getExpected() {
- return expected;
- }
-
- @Override
- public boolean ok() {
- return result == expected || expected == Result.ANY;
- }
-
@Override
public void run() throws CardException {
+ if (hasRun)
+ return;
+
response = command.send();
if (callback != null) {
result = callback.apply(command, response);
@@ -183,12 +178,10 @@ public abstract class Test {
}
@Override
- public boolean ok() {
- return result == Result.SUCCESS;
- }
-
- @Override
public void run() throws CardException {
+ if (hasRun)
+ return;
+
for (Test test : tests) {
test.run();
}