From 5d54af2638a53721b414a41356a93686a9616272 Mon Sep 17 00:00:00 2001 From: RncLsn Date: Tue, 19 May 2015 13:35:52 +0100 Subject: Backup before changes in MyQueryReasoner. --- .../global_tests/CheckAnswersOverDataset.java | 48 ---------------------- 1 file changed, 48 deletions(-) delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java (limited to 'test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java') diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java b/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java deleted file mode 100644 index 424afa2..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java +++ /dev/null @@ -1,48 +0,0 @@ -package uk.ac.ox.cs.pagoda.global_tests; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import org.testng.Assert; -import uk.ac.ox.cs.pagoda.Pagoda; -import uk.ac.ox.cs.pagoda.query.QueryRecord; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Type; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Set; - -/** - * Given an instance of Pagoda, it checks the returned answers. - * */ -public class CheckAnswersOverDataset { - - public static void check(Pagoda pagoda, Path givenAnswers) { - try { -// Utility.setLogLevel(Level.DEBUG); // uncomment for outputting partial results - Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); - new File(computedAnswers.toString()).deleteOnExit(); - - pagoda.run(); - assertSameContent(computedAnswers, givenAnswers); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void assertSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { - BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); - BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); - - Gson gson = QueryRecord.GsonCreator.getInstance(); - - Type cqType = new TypeToken>() {}.getType(); - Set computedAnswers = gson.fromJson(computedReader, cqType); - Set givenAnswers = gson.fromJson(givenReader, cqType); - - Assert.assertEquals(computedAnswers, givenAnswers); - } -} -- cgit v1.2.3