Example #1
0
  @RandomlyFails
  public void testSaveAterSearch()
      throws MalformedURLException, CoreException, NoSuchMethodException, IllegalAccessException,
          IllegalArgumentException, InvocationTargetException, InterruptedException {
    long ts = System.currentTimeMillis();
    String summary = "somary" + ts;
    BugzillaRepository repository = QueryTestUtil.getRepository();
    String id1 = TestUtil.createIssue(repository, summary);

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

    // create query
    BugzillaQuery q = new BugzillaQuery(repository);

    // get controler and wait until populated with default values
    QueryController c = q.getController();
    ts = System.currentTimeMillis();
    h.waitUntilDone();

    // populate with parameters - summary
    populate(c, summary);

    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);

    // search
    nl.reset();
    h = new LogHandler("refresh finish", LogHandler.Compare.STARTS_WITH);
    search(c); // search button and wait until done
    ts = System.currentTimeMillis();
    h.waitUntilDone();

    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());

    // save
    nl.reset();
    String name = QUERY_NAME + ts;
    h = new LogHandler(" saved", LogHandler.Compare.ENDS_WITH);
    save(c, name); // save button
    h.waitUntilDone();
    assertTrue(q.isSaved());
    // create a new repo instance and check if our query is between them
    repository = QueryTestUtil.getRepository();
    Collection<BugzillaQuery> queries = repository.getQueries();
    boolean bl = false;
    for (BugzillaQuery query : queries) {
      bl = query.getDisplayName().equals(name);
      if (bl) break;
    }
    assertTrue(bl);
  }
Example #2
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());
  }
Example #3
0
  public void testSaveBeforeSearch()
      throws MalformedURLException, CoreException, NoSuchMethodException, IllegalAccessException,
          IllegalArgumentException, InvocationTargetException, 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);

    // create query
    BugzillaQuery q = new BugzillaQuery(QueryTestUtil.getRepository());

    // get controler and wait until populated with default values
    QueryController c = q.getController();
    h.waitUntilDone();

    // populate with parameters - summary
    populate(c, summary);

    TestQueryNotifyListener nl = new TestQueryNotifyListener(q);
    nl.reset();
    QueryListener ql = new QueryListener();
    q.addPropertyChangeListener(ql);

    h = new LogHandler("refresh finish", LogHandler.Compare.STARTS_WITH); // we wan't to check
    // if the refresh is made after save
    save(c, QUERY_NAME + ts); // save button
    h.waitUntilDone();
    assertEquals(1, ql.saved);

    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());
  }
Example #4
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());
  }