Page 1 of 1

FAQ: как создать новую задачу через SOAP API

PostPosted: Tue Oct 09, 2007 12:15 pm
by admin
Code: Select all
public class TestTask extends TestCase {


   private static DevPack devPack = null;
   private static String sessionId = null;


    public TestTask(String string) {
        super(string);
    }

    public static void main (String[] args) {
            junit.textui.TestRunner.run (suite());
        }
    protected void setUp() {

        try {
            if (devPack == null) {
         devPack = new DevPack("http://localhost:4444/TrackStudio");
      }
           sessionId= authenticate("root", "root");
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (ServiceException e) {
            e.printStackTrace();
        }

    }

    public static Test suite() {
        return new TestSuite(TestTask.class);
    }

   public void testCreate() throws Exception {
      TaskBean task = devPack.getTaskService().findTaskByNumber(sessionId, "2");
      UserBean user = devPack.getUserService().findByLogin(sessionId, "itadmin");
      CategoryBean[] categories = devPack.getCategoryService().getCreatableCategoryList(sessionId, task.getId());
      UserBean[] users = devPack.getAclService().getUserList(sessionId, task.getId());
       Calendar deadline = new GregorianCalendar();
       deadline.set(2007, 12, 28);
       CategoryBean category = categories[0];
       PriorityBean[] priorities = devPack.getWorkflowService().getPriorityList(sessionId, category.getWorkflowId());
       String priorityId = priorities!=null && priorities.length>0 ? priorities[0].getId() : null;
       UserBean handler = user;
       HashMap udf = null;
       String t=null;
       if (categories!=null && categories.length>0){
        t=devPack.getTaskService().createTask(sessionId, category.getId(), "", "Test Suite: create task via SOAP", "Test Suite: create task via SOAP\n description",
                             32.50d, deadline.getTime().getTime(), priorityId,
                             task.getId(), handler.getId(), null, udf);
      }
       assertNotNull(t);
   }



   public static String authenticate(String login, String password) throws RemoteException {
      try {
         sessionId = devPack.getUserService().authenticate(login,password);
      } catch (Exception e) {
         return null;
      }
      return sessionId;
   }
}