Search in sources :

Example 1 with BusinessObjectRecordedErrorException

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();
        }
    }
}
Also used : HashMap(java.util.HashMap) BasicColumnFunction(net.geoprism.data.importer.BasicColumnFunction) BusinessObjectImportConfiguration(net.geoprism.registry.etl.upload.BusinessObjectImportConfiguration) BusinessObject(net.geoprism.registry.model.BusinessObject) BusinessObjectImporter(net.geoprism.registry.etl.upload.BusinessObjectImporter) DuplicateDataException(com.runwaysdk.dataaccess.DuplicateDataException) BusinessObjectRecordedErrorException(net.geoprism.registry.etl.upload.BusinessObjectRecordedErrorException) NullImportProgressListener(net.geoprism.registry.etl.NullImportProgressListener) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.JSONObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) BusinessObject(net.geoprism.registry.model.BusinessObject) MapFeatureRow(net.geoprism.registry.excel.MapFeatureRow) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

JsonObject (com.google.gson.JsonObject)1 DuplicateDataException (com.runwaysdk.dataaccess.DuplicateDataException)1 Request (com.runwaysdk.session.Request)1 HashMap (java.util.HashMap)1 BasicColumnFunction (net.geoprism.data.importer.BasicColumnFunction)1 NullImportProgressListener (net.geoprism.registry.etl.NullImportProgressListener)1 BusinessObjectImportConfiguration (net.geoprism.registry.etl.upload.BusinessObjectImportConfiguration)1 BusinessObjectImporter (net.geoprism.registry.etl.upload.BusinessObjectImporter)1 BusinessObjectRecordedErrorException (net.geoprism.registry.etl.upload.BusinessObjectRecordedErrorException)1 MapFeatureRow (net.geoprism.registry.excel.MapFeatureRow)1 BusinessObject (net.geoprism.registry.model.BusinessObject)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1