Esempio n. 1
0
  public String createCustomFieldTask() throws Exception {
    final TaskMapping taskMappingInit =
        new TaskMapping() {

          @Override
          public String getProduct() {
            return "ManualTest";
          }
        };
    final TaskMapping taskMappingSelect =
        new TaskMapping() {
          @Override
          public String getComponent() {
            return "ManualC2";
          }

          @Override
          public String getSummary() {
            return "test Bug with Custom Fields";
          }

          @Override
          public String getDescription() {
            return "The Description of the test with Custom Fields Bug";
          }
        };

    // create Task
    TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
    RepositoryResponse response = createNewTask(taskDataNew);
    assertNotNull(response);
    assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
    String taskId = response.getTaskId();

    ITask task = getTask(taskId);
    assertNotNull(task);
    TaskData taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
    assertNotNull(taskData);

    TaskMapper mapper = new TaskMapper(taskData);
    TaskAttribute cf_multiselect = mapper.getTaskData().getRoot().getAttribute("cf_multiselect");
    cf_multiselect.setValue("Green");
    response = fixture.submitTask(taskData, priviledgedClient());

    return taskId;
  }
Esempio n. 2
0
  public String createXmlRpcTask() throws Exception {
    final TaskMapping taskMappingInit =
        new TaskMapping() {

          @Override
          public String getProduct() {
            return "TestProduct";
          }
        };
    final TaskMapping taskMappingSelect =
        new TaskMapping() {
          @Override
          public String getComponent() {
            return "TestComponent";
          }

          @Override
          public String getSummary() {
            return "test XMLRPC getBugData";
          }

          @Override
          public String getDescription() {
            return "The Description of the XMLRPC getBugData Bug";
          }
        };
    TaskAttribute flagA = null;
    TaskAttribute flagB = null;
    TaskAttribute flagC = null;
    TaskAttribute flagD = null;
    TaskAttribute stateA = null;
    TaskAttribute stateB = null;
    TaskAttribute stateC = null;
    TaskAttribute stateD = null;

    // create Task
    TaskData taskDataNew = createTaskData(taskMappingInit, taskMappingSelect, null);
    RepositoryResponse response = createNewTask(taskDataNew);

    assertNotNull(response);
    assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
    String taskId = response.getTaskId();

    ITask task = getTask(taskId);
    assertNotNull(task);
    TaskData taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
    assertNotNull(taskData);
    TaskAttribute attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);
    TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);

    /* Test uploading a proper file */
    String fileName = "test-attach-1.txt";
    File attachFile = new File(fileName);
    attachFile.createNewFile();
    attachFile.deleteOnExit();
    BufferedWriter write = new BufferedWriter(new FileWriter(attachFile));
    write.write("test file from " + System.currentTimeMillis());
    write.close();

    FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(attachFile);
    attachment.setContentType("text/plain");
    attachment.setDescription("Description");
    attachment.setName("My Attachment 1");
    try {
      priviledgedClient()
          .postAttachment(
              taskData.getTaskId(),
              attachmentMapper.getComment(),
              attachment,
              attrAttachment,
              new NullProgressMonitor());
    } catch (Exception e) {
      fail("never reach this!");
    }
    taskData = fixture.getTask(taskData.getTaskId(), priviledgedClient());
    assertNotNull(taskData);

    TaskAttribute attachmentAttribute =
        taskData
            .getAttributeMapper()
            .getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT)
            .get(0);
    int flagCount = 0;
    int flagCountUnused = 0;
    TaskAttribute attachmentFlag1 = null;
    TaskAttribute attachmentFlag2 = null;
    for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) {
      if (!attribute.getId().startsWith(BugzillaAttribute.KIND_FLAG)) {
        continue;
      }
      flagCount++;
      if (attribute.getId().startsWith(BugzillaAttribute.KIND_FLAG_TYPE)) {
        flagCountUnused++;
        TaskAttribute stateAttribute =
            taskData.getAttributeMapper().getAssoctiatedAttribute(attribute);
        if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag1")) {
          attachmentFlag1 = attribute;
        }
        if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag2")) {
          attachmentFlag2 = attribute;
        }
      }
    }
    assertEquals(2, flagCount);
    assertEquals(2, flagCountUnused);
    assertNotNull(attachmentFlag1);
    assertNotNull(attachmentFlag2);
    TaskAttribute stateAttribute1 =
        taskData.getAttributeMapper().getAssoctiatedAttribute(attachmentFlag1);
    stateAttribute1.setValue("?");
    TaskAttribute requestee = attachmentFlag1.getAttribute("requestee"); // $NON-NLS-1$
    requestee.setValue("*****@*****.**");
    priviledgedClient().postUpdateAttachment(attachmentAttribute, "update", null);

    task = getTask(taskId);
    assertNotNull(task);
    taskData = fixture.connector().getTaskData(repository(), task.getTaskId(), null);
    assertNotNull(taskData);

    for (TaskAttribute taskAttribute : taskData.getRoot().getAttributes().values()) {
      if (taskAttribute.getId().startsWith(BugzillaAttribute.KIND_FLAG)) {
        TaskAttribute state = taskAttribute.getAttribute("state");
        if (state.getMetaData().getLabel().equals("BugFlag1")) {
          flagA = taskAttribute;
          stateA = state;
        } else if (state.getMetaData().getLabel().equals("BugFlag2")) {
          flagB = taskAttribute;
          stateB = state;
        } else if (state.getMetaData().getLabel().equals("BugFlag3")) {
          flagC = taskAttribute;
          stateC = state;
        } else if (state.getMetaData().getLabel().equals("BugFlag4")) {
          flagD = taskAttribute;
          stateD = state;
        }
      }
    }
    assertNotNull(flagA);
    assertNotNull(flagB);
    assertNotNull(flagC);
    assertNotNull(flagD);
    assertNotNull(stateA);
    assertNotNull(stateB);
    assertNotNull(stateC);
    assertNotNull(stateD);
    if (flagD != null) {
      TaskAttribute requesteeD = flagD.getAttribute("requestee");
      requesteeD.setValue("*****@*****.**");
    }
    if (stateA != null) {
      stateA.setValue("+");
    }
    if (stateB != null) {
      stateB.setValue("?");
    }
    if (stateC != null) {
      stateC.setValue("?");
    }
    if (stateD != null) {
      stateD.setValue("?");
    }

    TaskAttribute cf_freetext = taskData.getRoot().getAttribute("cf_freetext");
    TaskAttribute cf_dropdown = taskData.getRoot().getAttribute("cf_dropdown");
    TaskAttribute cf_largetextbox = taskData.getRoot().getAttribute("cf_largetextbox");
    TaskAttribute cf_multiselect = taskData.getRoot().getAttribute("cf_multiselect");
    TaskAttribute cf_datetime = taskData.getRoot().getAttribute("cf_datetime");
    TaskAttribute cf_bugid = taskData.getRoot().getAttribute("cf_bugid");
    cf_freetext.setValue("Freetext");
    cf_dropdown.setValue("one");
    cf_largetextbox.setValue("large text box");
    cf_multiselect.setValue("Blue");
    cf_datetime.setValue("2012-01-01 00:00:00");
    String cf_bugidValue = taskCfBugIdExists();
    if (cf_bugidValue == null) {
      cf_bugidValue = createCfBugIdTask();
    }
    cf_bugid.setValue(cf_bugidValue);
    response = fixture.submitTask(taskData, priviledgedClient());

    return taskId;
  }
Esempio n. 3
0
 private RepositoryResponse createNewTask(TaskData taskData)
     throws IOException, CoreException, Exception {
   return fixture.submitTask(taskData, priviledgedClient());
 }