예제 #1
0
 public String enhanceSearchTaskExists() {
   String taskID = null;
   String queryUrlString =
       repository().getRepositoryUrl()
           + "/buglist.cgi?"
           + "short_desc=test%20EnhanceSearch&resolution=---&query_format=advanced"
           + "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
   RepositoryQuery query =
       new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
   query.setUrl(queryUrlString);
   final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
   TaskDataCollector collector =
       new TaskDataCollector() {
         @Override
         public void accept(TaskData taskData) {
           changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
         }
       };
   connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
   if (changedTaskData.size() > 0) {
     Set<Integer> ks = changedTaskData.keySet();
     SortedSet<Integer> sks = new TreeSet<Integer>(ks);
     taskID = sks.last().toString();
   }
   return taskID;
 }
예제 #2
0
  public ArrayList<String> taskMissingHitsExists() {
    ArrayList<String> taskIDs = new ArrayList<String>();

    String queryUrlString =
        repository().getRepositoryUrl()
            + "/buglist.cgi?"
            + "short_desc=test%20Missing%20Hits&resolution=---&query_format=advanced"
            + "&short_desc_type=casesubstring&component=ManualC2&product=ManualTest";
    RepositoryQuery query =
        new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
    query.setUrl(queryUrlString);
    final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
    TaskDataCollector collector =
        new TaskDataCollector() {
          @Override
          public void accept(TaskData taskData) {
            changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
          }
        };
    connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
    if (changedTaskData.size() > 0) {
      Set<Integer> ks = changedTaskData.keySet();
      SortedSet<Integer> sks = new TreeSet<Integer>(ks);
      for (Integer integer : sks) {
        taskIDs.add("" + integer);
      }
    }
    return taskIDs;
  }
  public void testCommentQuery() throws Exception {
    BugzillaRepositoryConnector connector = BugzillaFixture.current().connector();
    BugzillaAttributeMapper mapper = new BugzillaAttributeMapper(repository, connector);
    TaskData newData =
        new TaskData(
            mapper,
            BugzillaFixture.current().getConnectorKind(),
            BugzillaFixture.current().getRepositoryUrl(),
            "");

    assertTrue(
        connector
            .getTaskDataHandler()
            .initializeTaskData(repository, newData, null, new NullProgressMonitor()));
    newData.getRoot().getMappedAttribute(TaskAttribute.SUMMARY).setValue("testCommentQuery()");
    newData.getRoot().getMappedAttribute(TaskAttribute.PRODUCT).setValue("TestProduct");
    newData.getRoot().getMappedAttribute(TaskAttribute.COMPONENT).setValue("TestComponent");
    newData.getRoot().getMappedAttribute(BugzillaAttribute.VERSION.getKey()).setValue("1");
    newData.getRoot().getMappedAttribute(BugzillaAttribute.OP_SYS.getKey()).setValue("All");
    long timestamp = System.currentTimeMillis();
    newData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION).setValue("" + timestamp);
    RepositoryResponse response = client.postTaskData(newData, new NullProgressMonitor());

    String bugid = response.getTaskId();
    RepositoryQuery query =
        new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "123");
    query.setRepositoryUrl(BugzillaFixture.current().getRepositoryUrl());
    if (BugzillaFixture.current()
            .getBugzillaVersion()
            .compareMajorMinorOnly(BugzillaVersion.BUGZILLA_4_0)
        < 0) {
      query.setUrl("?long_desc_type=allwordssubstr&long_desc=" + timestamp + "&bug_status=NEW&");
    } else {
      query.setUrl(
          "?long_desc_type=allwordssubstr&long_desc=" + timestamp + "&bug_status=CONFIRMED&");
    }

    final Set<TaskData> returnedData = new HashSet<TaskData>();

    TaskDataCollector collector =
        new TaskDataCollector() {

          @Override
          public void accept(TaskData taskData) {
            returnedData.add(taskData);
          }
        };

    client.getSearchHits(query, collector, mapper, new NullProgressMonitor());
    assertEquals(1, returnedData.size());
    assertEquals(bugid, returnedData.iterator().next().getTaskId());
  }