diff options
| author | J08nY | 2017-10-25 18:58:52 +0200 |
|---|---|---|
| committer | J08nY | 2017-10-25 18:58:52 +0200 |
| commit | 69a4116df7b54ddfdaba2f8aa80ecb9e9a2ed9a7 (patch) | |
| tree | b0500700cddf9f228f5e79d74331831429b5b583 /src/cz/crcs/ectester/reader/test/Test.java | |
| parent | cd2a972ee05c88c2a83e7788839bbd657c2cf1c4 (diff) | |
| download | ECTester-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.java | 35 |
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(); } |
