use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testColumnNotExisting.
@Test
public void testColumnNotExisting() throws Exception {
List<String> testColumns = new ArrayList<String>(Arrays.asList(TEST_COLUMNS));
testColumns.add(4, "Unknown_Column");
String[] columns = testColumns.toArray(new String[testColumns.size()]);
String[] values = { getNextId(), "testColumnNotExisting", "string not null", "char", "i do not exist!", "char not null", "2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747" };
List<String> valuesAsList = new ArrayList<String>(Arrays.asList(values));
valuesAsList.remove(4);
String[] expectedValues = valuesAsList.toArray(new String[valuesAsList.size()]);
writeData(new CsvData(DataEventType.INSERT, values), expectedValues, columns);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testUpdateDetectVersionIgnoreBatch.
@Test
public void testUpdateDetectVersionIgnoreBatch() {
Conflict setting = new Conflict();
setting.setConflictId("unit.test");
setting.setDetectType(DetectConflict.USE_VERSION);
setting.setDetectExpression("integer_value");
setting.setResolveRowOnly(false);
setting.setResolveChangesOnly(false);
setting.setResolveType(ResolveConflict.NEWER_WINS);
writerSettings.setDefaultConflictSetting(setting);
String id = getNextId();
String[] originalValues = massageExpectectedResultsForDialect(new String[] { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2012-03-12 07:00:00.000", "0", "2", "67.89", "-0.0747663" });
CsvData data = new CsvData(DataEventType.INSERT, originalValues);
writeData(data, originalValues);
long before = countRows(TEST_TABLE);
String[] updateShouldNotBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldNotBeApplied[2] = "updated string";
updateShouldNotBeApplied[8] = "1";
CsvData update = new CsvData(DataEventType.UPDATE, massageExpectectedResultsForDialect(updateShouldNotBeApplied));
String newId = getNextId();
CsvData newInsert = new CsvData(DataEventType.INSERT, massageExpectectedResultsForDialect(new String[] { newId, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.0", "2012-03-12 07:00:00.0", "0", "2", "67.89", "-0.0747663" }));
writeData(update, newInsert);
Assert.assertEquals(before, countRows(TEST_TABLE));
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testDeleteExisting.
@Test
public void testDeleteExisting() throws Exception {
String[] values = { getNextId(), "a row to be deleted", "testDeleteExisting", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747" };
massageExpectectedResultsForDialect(values);
writeData(new CsvData(DataEventType.INSERT, values), values);
writeData(new CsvData(DataEventType.DELETE, new String[] { getId() }, null), null);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testTableNotExisting.
@Test
public void testTableNotExisting() throws Exception {
String[] values = { getNextId(), "testTableNotExisting", "This row should load", "char", "char not null", "2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "0", "12.10", "-0.0747" };
Table badTable = buildSourceTable("UnknownTable", TEST_KEYS, TEST_COLUMNS);
writeData(new TableCsvData(badTable, new CsvData(DataEventType.INSERT, values)), new TableCsvData(buildSourceTable(TEST_TABLE, TEST_KEYS, TEST_COLUMNS), new CsvData(DataEventType.INSERT, values)));
massageExpectectedResultsForDialect(values);
assertTestTableEquals(values[0], values);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class CsvDataTest method testGetCsvData.
@Test
public void testGetCsvData() {
final String TEST = "\"This is a test\", laughs Kunal.\n\r";
CsvData data = new CsvData(DataEventType.INSERT, new String[] { TEST });
String rowData = data.getCsvData(CsvData.ROW_DATA);
CsvData newData = new CsvData();
newData.putCsvData(CsvData.ROW_DATA, rowData);
String result = newData.getParsedData(CsvData.ROW_DATA)[0];
assertEquals(TEST, result);
}
Aggregations