use of com.google.cloud.teleport.v2.templates.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class ChangeEventConvertorTest method cannotConvertChangeEventWithInvalidFloat64ToShadowMutation.
@Test(expected = ChangeEventConvertorException.class)
public void cannotConvertChangeEventWithInvalidFloat64ToShadowMutation() throws Exception {
Ddl ddl = getTestDdl();
JSONObject changeEvent = getTestChangeEvent("Users2");
changeEvent.put("float64_field", "asdfas");
JsonNode ce = parseChangeEvent(changeEvent.toString());
Mutation mutation = ChangeEventConvertor.changeEventToShadowTableMutationBuilder(ddl, ce, "shadow_").build();
// Expect an Exception to be thrown with Invalid Float64
}
use of com.google.cloud.teleport.v2.templates.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class ChangeEventConvertorTest method cannotConvertChangeEventWithInvalidTimestampToShadowMutation.
@Test(expected = ChangeEventConvertorException.class)
public void cannotConvertChangeEventWithInvalidTimestampToShadowMutation() throws Exception {
Ddl ddl = getTestDdl();
JSONObject changeEvent = getTestChangeEvent("Users2");
changeEvent.put("timestamp_field", "2020-12-asdf");
JsonNode ce = parseChangeEvent(changeEvent.toString());
Mutation mutation = ChangeEventConvertor.changeEventToShadowTableMutationBuilder(ddl, ce, "shadow_").build();
// Expect an Exception to be thrown with Invalid timestamp
}
use of com.google.cloud.teleport.v2.templates.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class ChangeEventConvertorTest method cannotConvertChangeEventWithInvalidInt64ToMutation.
@Test(expected = ChangeEventConvertorException.class)
public void cannotConvertChangeEventWithInvalidInt64ToMutation() throws Exception {
Ddl ddl = getTestDdl();
JSONObject changeEvent = getTestChangeEvent("Users");
changeEvent.put("int64_field", "asdfas");
JsonNode ce = parseChangeEvent(changeEvent.toString());
Mutation mutation = ChangeEventConvertor.changeEventToMutation(ddl, ce);
}
use of com.google.cloud.teleport.v2.templates.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class ChangeEventConvertorTest method cannotConvertValidChangeEventWithNullKeyColumnsToMutation.
@Test(expected = ChangeEventConvertorException.class)
public void cannotConvertValidChangeEventWithNullKeyColumnsToMutation() throws Exception {
Ddl ddl = getTestDdl();
JSONObject changeEvent = new JSONObject();
changeEvent.put("first_name", "A");
changeEvent.put("last_name", JSONObject.NULL);
changeEvent.put(DatastreamConstants.EVENT_TABLE_NAME_KEY, "Users");
JsonNode ce = parseChangeEvent(changeEvent.toString());
Mutation mutation = ChangeEventConvertor.changeEventToMutation(ddl, ce);
}
use of com.google.cloud.teleport.v2.templates.spanner.ddl.Ddl in project DataflowTemplates by GoogleCloudPlatform.
the class ChangeEventConvertorTest method canConvertValidChangeEventToMutation.
@Test
public void canConvertValidChangeEventToMutation() throws Exception {
Ddl ddl = getTestDdl();
JSONObject changeEvent = getTestChangeEvent("Users");
JsonNode ce = parseChangeEvent(changeEvent.toString());
Mutation mutation = ChangeEventConvertor.changeEventToMutation(ddl, ce);
Map<String, Value> actual = mutation.asMap();
Map<String, Value> expected = getExpectedMapForTestChangeEvent();
assertThat(actual, is(expected));
assertEquals(mutation.getTable(), "Users");
assertEquals(mutation.getOperation(), Mutation.Op.INSERT_OR_UPDATE);
}
Aggregations