use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testInsertDetectTimestampNewerWins.
@Test
public void testInsertDetectTimestampNewerWins() {
Conflict setting = new Conflict();
setting.setConflictId("unit.test");
setting.setDetectType(DetectConflict.USE_TIMESTAMP);
setting.setDetectExpression("time_value");
setting.setResolveRowOnly(true);
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", "47", "67.89", "-0.0747663" });
CsvData data = new CsvData(DataEventType.INSERT, originalValues);
writeData(data, originalValues);
String[] updateShouldNotBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldNotBeApplied[2] = "updated string";
updateShouldNotBeApplied[6] = "2012-03-12 06:00:00.0";
data = new CsvData(DataEventType.INSERT, massageExpectectedResultsForDialect(updateShouldNotBeApplied));
writeData(data, originalValues);
String[] updateShouldBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldBeApplied[2] = "string3";
updateShouldBeApplied[6] = "2012-03-12 08:00:00.000";
data = new CsvData(DataEventType.INSERT, massageExpectectedResultsForDialect(updateShouldBeApplied));
writeData(data, updateShouldBeApplied);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testStringEmpty.
@Test
public void testStringEmpty() throws Exception {
String[] values = new String[TEST_COLUMNS.length];
values[0] = getNextId();
if (!(platform instanceof AseDatabasePlatform)) {
values[1] = values[2] = "";
}
values[3] = values[4] = "";
String[] expectedValues = (String[]) ArrayUtils.clone(values);
if (platform.getDatabaseInfo().isRequiredCharColumnEmptyStringSameAsNull()) {
expectedValues[4] = null;
}
writeData(new CsvData(DataEventType.INSERT, values), expectedValues);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testStringNull.
@Test
public void testStringNull() throws Exception {
String[] values = new String[TEST_COLUMNS.length];
values[0] = getNextId();
String[] expectedValues = (String[]) ArrayUtils.clone(values);
if (platform.getDatabaseInfo().isRequiredCharColumnEmptyStringSameAsNull()) {
expectedValues[4] = AbstractDatabasePlatform.REQUIRED_FIELD_NULL_SUBSTITUTE;
}
writeData(new CsvData(DataEventType.INSERT, values), expectedValues);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testColumnLevelSync.
@Test
public void testColumnLevelSync() throws Exception {
String[] insertValues = new String[TEST_COLUMNS.length];
insertValues[2] = insertValues[4] = "column sync";
insertValues[0] = getNextId();
String[] updateValues = new String[2];
updateValues[0] = insertValues[0];
updateValues[1] = "new value";
writeData(new CsvData(DataEventType.INSERT, insertValues), insertValues);
// update a single column
String[] columns = { "id", "string_value" };
insertValues[1] = updateValues[1];
writeData(new CsvData(DataEventType.UPDATE, new String[] { getId() }, updateValues), insertValues, columns);
// update a single column
columns = new String[] { "id", "char_value" };
insertValues[3] = updateValues[1];
writeData(new CsvData(DataEventType.UPDATE, new String[] { getId() }, updateValues), insertValues, columns);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testDecimalLocale.
@Test
public void testDecimalLocale() throws Exception {
String[] values = new String[TEST_COLUMNS.length];
values[0] = getNextId();
values[10] = "123456,99";
String[] expectedValues = (String[]) ArrayUtils.clone(values);
massageExpectectedResultsForDialect(expectedValues);
if (platform.getDatabaseInfo().isRequiredCharColumnEmptyStringSameAsNull()) {
expectedValues[4] = AbstractDatabasePlatform.REQUIRED_FIELD_NULL_SUBSTITUTE;
}
writeData(new CsvData(DataEventType.INSERT, values), expectedValues);
}
Aggregations