Example #1
0
  @Test
  public void testGetQueryResult() throws QueryCacheMissException {
    Query q1 = new Query().addWord("hoi");
    Query q2 = new Query().addWord("hoi");
    String result = "my result";
    q1.addResult(result);

    QueryCache qc = new QueryCache();
    qc.addQuery(q1);
    assertEquals(result, qc.getResultForQuery(q1));
    assertEquals(result, qc.getResultForQuery(q2));
  }
Example #2
0
 @Test
 public void testAddDuplicateQuery() throws QueryCacheMissException {
   Query q1 = new Query().addWord("hoi");
   Query q2 = new Query().addWord("hoi");
   String expectedResult = "my result";
   q1.addResult(expectedResult);
   String notExpectedResult = "another result";
   q2.addResult(notExpectedResult);
   QueryCache qc = new QueryCache();
   qc.addQuery(q1);
   qc.addQuery(q2);
   assertEquals(expectedResult, qc.getResultForQuery(q1));
   assertEquals(expectedResult, qc.getResultForQuery(q2));
 }
Example #3
0
 @Test(expected = QueryCacheMissException.class)
 public void testThrowsCacheMiss() throws QueryCacheMissException {
   QueryCache qc = new QueryCache();
   qc.getResultForQuery(new Query().addWord("hoi"));
 }