diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-19 13:35:52 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-19 13:35:52 +0100 |
| commit | 5d54af2638a53721b414a41356a93686a9616272 (patch) | |
| tree | e28c64b1887e7e964661d12d96df5b09abd4d9ee /test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswers.java | |
| parent | c7dbc7c61c7094ea4ec49bd630023f23b92fd9d1 (diff) | |
| download | ACQuA-5d54af2638a53721b414a41356a93686a9616272.tar.gz ACQuA-5d54af2638a53721b414a41356a93686a9616272.zip | |
Backup before changes in MyQueryReasoner.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswers.java')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswers.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswers.java b/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswers.java new file mode 100644 index 0000000..14050ce --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswers.java | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.global_tests; | ||
| 2 | |||
| 3 | import com.google.gson.Gson; | ||
| 4 | import com.google.gson.reflect.TypeToken; | ||
| 5 | import org.testng.Assert; | ||
| 6 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 7 | |||
| 8 | import java.io.BufferedReader; | ||
| 9 | import java.io.IOException; | ||
| 10 | import java.lang.reflect.Type; | ||
| 11 | import java.nio.file.Files; | ||
| 12 | import java.nio.file.Path; | ||
| 13 | import java.util.Set; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * It provides auxiliary methods for checking answers. | ||
| 17 | * */ | ||
| 18 | public class CheckAnswers { | ||
| 19 | |||
| 20 | private CheckAnswers() { | ||
| 21 | } | ||
| 22 | |||
| 23 | public static void assertSameAnswers(Path computedAnswersFile, Path givenAnswersFile) throws IOException { | ||
| 24 | BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); | ||
| 25 | BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); | ||
| 26 | |||
| 27 | Gson gson = QueryRecord.GsonCreator.getInstance(); | ||
| 28 | |||
| 29 | Type cqType = new TypeToken<Set<QueryRecord>>() {}.getType(); | ||
| 30 | Set<QueryRecord> computedAnswers = gson.fromJson(computedReader, cqType); | ||
| 31 | Set<QueryRecord> givenAnswers = gson.fromJson(givenReader, cqType); | ||
| 32 | |||
| 33 | Assert.assertEquals(computedAnswers, givenAnswers); | ||
| 34 | } | ||
| 35 | } | ||
