use of net.geoprism.registry.etl.upload.BusinessObjectRecordedErrorException in project geoprism-registry by terraframe.
the class BusinessObjectImporterTest method testImportValueExistingNewOnly.
@Test
@Request
public void testImportValueExistingNewOnly() throws InterruptedException {
BusinessObject object = BusinessObject.newInstance(type);
object.setCode(TEST_CODE);
object.apply();
try {
String value = "Test Text";
String rowAttribute = "Bad";
HashMap<String, Object> row = new HashMap<String, Object>();
row.put(rowAttribute, value);
row.put(BusinessObject.CODE, TEST_CODE);
BusinessObjectImportConfiguration configuration = new BusinessObjectImportConfiguration();
configuration.setImportStrategy(ImportStrategy.NEW_ONLY);
configuration.setType(type);
configuration.setDate(FastTestDataset.DEFAULT_END_TIME_DATE);
configuration.setCopyBlank(false);
configuration.setFunction(attributeType.getName(), new BasicColumnFunction(rowAttribute));
configuration.setFunction(BusinessObject.CODE, new BasicColumnFunction(BusinessObject.CODE));
BusinessObjectImporter importer = new BusinessObjectImporter(configuration, new NullImportProgressListener());
importer.importRow(new MapFeatureRow(row));
Assert.assertTrue(configuration.hasExceptions());
LinkedList<BusinessObjectRecordedErrorException> exceptions = configuration.getExceptions();
Assert.assertEquals(1, exceptions.size());
BusinessObjectRecordedErrorException exception = exceptions.get(0);
Assert.assertTrue(exception.getError() instanceof DuplicateDataException);
} finally {
if (object != null) {
object.delete();
}
}
}
Aggregations