Esempio n. 1
0
  public void testgetQueriesAndHitsForHandle() {
    MockTask hit1 = new MockTask("1");
    MockTask hit2 = new MockTask("2");
    MockTask hit3 = new MockTask("3");

    MockTask hit1twin = new MockTask("1");
    MockTask hit2twin = new MockTask("2");
    MockTask hit3twin = new MockTask("3");

    MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
    MockRepositoryQuery query2 = new MockRepositoryQuery("query2");

    taskList.addQuery(query1);
    taskList.addQuery(query2);
    taskList.addTask(hit1, query1);
    taskList.addTask(hit2, query1);
    taskList.addTask(hit3, query1);

    assertEquals(3, query1.getChildren().size());

    taskList.addTask(hit1twin, query2);
    taskList.addTask(hit2twin, query2);
    taskList.addTask(hit3twin, query2);

    assertEquals(3, query2.getChildren().size());

    Set<AbstractTaskContainer> queriesReturned = hit1.getParentContainers();
    assertNotNull(queriesReturned);
    assertEquals(2, queriesReturned.size());
    assertTrue(queriesReturned.contains(query1));
    assertTrue(queriesReturned.contains(query2));
  }
Esempio n. 2
0
  public void testUpdateQueryHits() {
    MockTask hit1 = new MockTask("1");
    MockTask hit2 = new MockTask("2");
    MockTask hit3 = new MockTask("3");

    MockTask hit1twin = new MockTask("1");
    MockTask hit2twin = new MockTask("2");
    MockTask hit3twin = new MockTask("3");

    MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
    taskList.addQuery(query1);

    taskList.addTask(hit1, query1);
    taskList.addTask(hit2, query1);
    taskList.addTask(hit3, query1);

    taskList.addTask(hit1twin, query1);
    taskList.addTask(hit2twin, query1);
    taskList.addTask(hit3twin, query1);

    assertEquals(3, query1.getChildren().size());
    for (ITask child : query1.getChildren()) {
      taskList.removeFromContainer(query1, child);
    }
    assertEquals(0, query1.getChildren().size());
    taskList.addTask(hit1, query1);
    taskList.addTask(hit2, query1);
    assertEquals(2, query1.getChildren().size());
    hit1.setNotified(true);

    taskList.addTask(hit1twin, query1);
    taskList.addTask(hit2twin, query1);
    taskList.addTask(hit3twin, query1);
    assertEquals(3, query1.getChildren().size());
    assertTrue(query1.getChildren().contains(hit1twin));
    assertTrue(query1.getChildren().contains(hit2twin));
    assertTrue(query1.getChildren().contains(hit3twin));
    for (ITask hit : query1.getChildren()) {
      if (hit.equals(hit1twin)) {
        assertTrue(((AbstractTask) hit).isNotified());
      } else {
        assertFalse(((AbstractTask) hit).isNotified());
      }
    }
  }