addReadWriteAccess(UOM.class);
final List<UOM> uoms = getList(UOM.class);
// only copy one uom
final UOM prevUom = uoms.get(0);
// a prerequisite, if this fails then the length has changed
assertEquals(3, prevUom.getSymbol().length());
final UOM uom = (UOM) DalUtil.copy(prevUom);
final List<UOM> newUoms = new ArrayList<UOM>();
final String id = "" + System.currentTimeMillis();
uom.setId(id);
uom.setName(id);
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
final UOM newUom = OBDal.getInstance().get(UOM.class, id);
// before testing if it is okay remove it!
OBDal.getInstance().remove(newUom);
commitTransaction();
// ensure that hibernate did not give us the same object twice
assertTrue(uom != newUom);
assertEquals(uom.getSymbol(), newUom.getSymbol());
}