Exemple #1
0
  public void testZUpdate()
      throws RemoteException, UnexpectedErrorFault, InvalidTypeFault, MalformedQueryFault,
          InvalidQueryLocatorFault {
    try {
      ZApi zapi = new ZApi();
      assertTrue("Logged in", zapi.isLoggedIn);

      QueryResult qres =
          zapi.zQuery("Select Id,Description From Product Where Name='JTest Product'");
      ZObject[] zprods = qres.getRecords();
      Product p1 = (Product) zprods[0];
      assertTrue("Found JTest Product", p1.getDescription().equals("JTest Description"));

      p1.setDescription("JTest Description 2");
      SaveResult[] sr = zapi.zUpdate(new ZObject[] {p1});
      if (!sr[0].getSuccess()) {
        System.out.println(sr[0].getErrors()[0].getMessage());
      }
      assertTrue("Updated Product", sr[0].getSuccess());

      QueryResult qres2 =
          zapi.zQuery("Select Id,Description From Product Where Name='JTest Product'");
      ZObject[] zprods2 = qres2.getRecords();
      Product p2 = (Product) zprods2[0];
      assertTrue("Found Updated JTest Product", p2.getDescription().equals("JTest Description 2"));

    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
Exemple #2
0
  public void testZQuery()
      throws RemoteException, UnexpectedErrorFault, InvalidTypeFault, MalformedQueryFault,
          InvalidQueryLocatorFault {
    try {
      ZApi zapi = new ZApi();
      assertTrue("Logged in", zapi.isLoggedIn);

      QueryResult qres =
          zapi.zQuery("Select Id,Name,Description From Product Where Name='JTest Product'");
      ZObject[] zprods = qres.getRecords();
      Product p1 = (Product) zprods[0];

      assertTrue("Found JTest Product", p1.getDescription().equals("JTest Description"));
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
Exemple #3
0
  public void testZDelete()
      throws RemoteException, UnexpectedErrorFault, InvalidTypeFault, MalformedQueryFault,
          InvalidQueryLocatorFault, InvalidValueFault {
    try {
      ZApi zapi = new ZApi();
      assertTrue("Logged in", zapi.isLoggedIn);

      QueryResult qres =
          zapi.zQuery("Select Id,Description From Product Where Name='JTest Product'");
      ZObject[] zprods = qres.getRecords();
      Product p1 = (Product) zprods[0];

      DeleteResult[] delRes = zapi.zDelete(new String[] {p1.getId()}, "Product");
      assertTrue(delRes[0].getSuccess());
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }