Package org.openbravo.service.db

Examples of org.openbravo.service.db.ImportResult


    String xml = getXML(pts);
    xml = xml.replaceAll("</name>", "t</name>");

    setUserContext("1000019");
    setAccess();
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    }

    assertEquals(0, ir.getInsertedObjects().size());
    assertEquals(2, ir.getUpdatedObjects().size());
    for (final Object o : ir.getUpdatedObjects()) {
      assertTrue(o instanceof PaymentTerm || o instanceof PaymentTermLine);
      if (o instanceof PaymentTermLine) {
        final PaymentTermLine ptl = (PaymentTermLine) o;
        assertTrue(ir.getUpdatedObjects().contains(ptl.getPaymentTerms()));
      }
    }
  }
View Full Code Here


    setUserContext("1000019");
    // a payment term line is not deletable, but for this test it should be done anyway
    // force this by being admin
    OBContext.getOBContext().setInAdministratorMode(true);
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    }

    assertEquals(0, ir.getInsertedObjects().size());
    // name of paymentterm has changed
    // overduepaymentrule of paymenttermline is set back to 1
    assertEquals(2, ir.getUpdatedObjects().size());
    for (final Object o : ir.getUpdatedObjects()) {
      assertTrue(o instanceof PaymentTerm || o instanceof PaymentTermLine);
    }
  }
View Full Code Here

    // there is a unique constraint on name
    xml = xml.replaceAll("</name>", "t</name>");

    setUserContext("1000019");
    setAccess();
    final ImportResult ir = DataImportService.getInstance().importDataFromXML(
        OBDal.getInstance().get(Client.class, "1000001"),
        OBDal.getInstance().get(Organization.class, "1000001"), xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    }

    assertEquals(NO_OF_PT + NO_OF_PT_LINE + 1, ir.getInsertedObjects().size());
    for (final Object o : ir.getInsertedObjects()) {
      assertTrue(o instanceof PaymentTermTrl || o instanceof PaymentTerm
          || o instanceof PaymentTermLine);
    }
  }
View Full Code Here

    greeting.setTitle("test");
    final List<Greeting> newGs = new ArrayList<Greeting>();
    newGs.add(greeting);
    final String xml = getXML(newGs);

    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);

    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    } else if (ir.getErrorMessages() != null) {
      fail(ir.getErrorMessages());
    }

    assertEquals(1, ir.getInsertedObjects().size());
    assertTrue(ir.getWarningMessages() == null);
    final BaseOBObject bob = ir.getInsertedObjects().get(0);
    assertEquals(id, bob.getId());
  }
View Full Code Here

    uom.setSymbol("   ");
    newUoms.add(uom);
    final String xml = getXML(newUoms);
    assertTrue(xml.indexOf("<symbol>" + uom.getSymbol() + "</symbol>") != -1);

    final ImportResult ir = DataImportService.getInstance().importDataFromXML(c, o, xml);
    if (ir.getException() != null) {
      ir.getException().printStackTrace(System.err);
      fail(ir.getException().getMessage());
    } else if (ir.hasErrorOccured()) {
      fail(ir.getErrorMessages());
    }

    assertEquals(1, ir.getInsertedObjects().size());
    // there is a warning that the uom is created in org *, that's fine
    assertTrue(ir.getWarningMessages() != null);
    assertTrue(ir.getWarningMessages().indexOf(
        "eventhough it does not belong to the target organization") != -1);
    final BaseOBObject bob = ir.getInsertedObjects().get(0);
    assertEquals(id, bob.getId());

    commitTransaction();

    // now reread the greeting and check that the space is still there
View Full Code Here

TOP

Related Classes of org.openbravo.service.db.ImportResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.