示例#1
0
  public void testRefresh() throws MalformedURLException, CoreException, InterruptedException {
    long ts = System.currentTimeMillis();
    String summary = "somary" + ts;
    String id1 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary);

    LogHandler h = new LogHandler("Finnished populate", LogHandler.Compare.STARTS_WITH);

    String p = MessageFormat.format(PARAMETERS_FORMAT, summary);
    BugzillaQuery q =
        new BugzillaQuery(QUERY_NAME, QueryTestUtil.getRepository(), p, true, false, true);
    ts = System.currentTimeMillis();
    h.waitUntilDone();

    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);

    nl.reset();
    q.refresh();
    Collection<BugzillaIssue> is = q.getIssues();
    assertEquals(1, is.size());
    assertTrue(nl.started);
    assertTrue(nl.finished);
    List<BugzillaIssue> il = nl.getIssues(IssueCache.ISSUE_STATUS_ALL);
    assertEquals(1, il.size());
    BugzillaIssue i = il.get(0);
    assertEquals(summary, i.getSummary());
    assertEquals(id1, i.getID());

    nl.reset();
    q.refresh(p, false);
    assertTrue(nl.started);
    assertTrue(nl.finished);
    il = nl.getIssues(IssueCache.ISSUE_STATUS_ALL);
    assertEquals(1, il.size());
    i = il.get(0);
    assertEquals(summary, i.getSummary());
    assertEquals(id1, i.getID());
    is = q.getIssues();
    assertEquals(1, is.size());
  }
示例#2
0
  public void testGetIssues() throws MalformedURLException, CoreException {
    long ts = System.currentTimeMillis();
    String summary1 = "somary1" + ts;
    String id1 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary1);
    String summary2 = "somary2" + ts;
    String id2 = TestUtil.createIssue(QueryTestUtil.getRepository(), summary2);

    // query for issue1
    String p = MessageFormat.format(PARAMETERS_FORMAT, summary1);
    BugzillaQuery q =
        new BugzillaQuery(QUERY_NAME, QueryTestUtil.getRepository(), p, true, false, true);
    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);

    Collection<BugzillaIssue> bugzillaIssues = q.getIssues();
    assertEquals(0, nl.issues.size());

    nl.reset();
    q.refresh();
    assertTrue(nl.started);
    assertTrue(nl.finished);
    assertEquals(1, nl.getIssues(IssueCache.ISSUE_STATUS_ALL).size());
    assertEquals(1, q.getIssues().size());
    BugzillaIssue i = q.getIssues().iterator().next();
    assertEquals(summary1, i.getSummary());
    assertEquals(id1, i.getID());

    nl.reset();
    q.refresh(p, false);
    assertTrue(nl.started);
    assertTrue(nl.finished);
    assertEquals(1, nl.getIssues(IssueCache.ISSUE_STATUS_ALL).size());
    assertEquals(1, q.getIssues().size());
    i = q.getIssues().iterator().next();
    assertEquals(summary1, i.getSummary());
    assertEquals(id1, i.getID());

    // query for issue1 & issue2
    p = MessageFormat.format(PARAMETERS_FORMAT, ts);
    nl.reset();
    q.refresh(p, false);
    bugzillaIssues = q.getIssues();
    assertTrue(nl.started);
    assertTrue(nl.finished);
    assertEquals(2, nl.getIssues(IssueCache.ISSUE_STATUS_ALL).size());
    assertEquals(2, bugzillaIssues.size());
    List<String> summaries = new ArrayList<String>();
    List<String> ids = new ArrayList<String>();
    for (BugzillaIssue issue : bugzillaIssues) {
      summaries.add(issue.getSummary());
      ids.add(issue.getID());
    }
    assertTrue(summaries.contains(summary1));
    assertTrue(summaries.contains(summary2));
    assertTrue(ids.contains(id1));
    assertTrue(ids.contains(id2));

    //        Collection<Issue> is =
    // BugtrackingUtil.getByIdOrSummary(BugzillaUtil.getQuery(q).getIssues(), "" + ts); // shoud
    // return both issues
    //        assertEquals(2, is.size());
    //        summaries = new ArrayList<String>();
    //        ids = new ArrayList<String>();
    //        for(Issue issue : is) {
    //            summaries.add(issue.getSummary());
    //            ids.add(issue.getID());
    //        }
    //        assertTrue(summaries.contains(summary1));
    //        assertTrue(summaries.contains(summary2));
    //        assertTrue(ids.contains(id1));
    //        assertTrue(ids.contains(id2));
    //
    //        is = BugtrackingUtil.getByIdOrSummary(BugzillaUtil.getQuery(q).getIssues(), summary1);
    // // shoud return 1st issue
    //        assertEquals(1, is.size());
    //        assertEquals(id1, is.iterator().next().getID());
    //        assertEquals(summary1, is.iterator().next().getSummary());
  }