use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project amazon-qldb-dmv-sample-java by aws-samples.
the class RegisterDriversLicense method registerNewDriversLicense.
/**
* Register a new driver's license.
*
* @param txn
* The {@link TransactionExecutor} for lambda execute.
* @param govId
* The government ID of the new owner.
* @param license
* The new license to register.
* @param personId
* The unique personId of the new owner.
* @throws IllegalStateException if failed to convert document ID to an IonValue.
*/
public static void registerNewDriversLicense(final TransactionExecutor txn, final String govId, final DriversLicense license, final String personId) {
try {
if (personHadDriversLicense(txn, personId)) {
log.info("Person with government ID '{}' already has a license! No new license added.", govId);
return;
}
final String query = "INSERT INTO DriversLicense ?";
log.info(new IonObjectMapper().writeValueAsIonValue(license).toPrettyString());
final List<IonValue> parameters = Collections.singletonList(Constants.MAPPER.writeValueAsIonValue(license));
txn.execute(query, parameters);
Result result = queryDriversLicenseByPersonId(txn, govId);
if (ScanTable.toIonStructs(result).size() > 0) {
log.info("Problem occurred while inserting new license, please review the results.");
} else {
log.info("Successfully registered new driver.");
}
} catch (IOException ioe) {
throw new IllegalStateException(ioe);
}
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonValueMapperTest method testPojo5WithSexpInArray.
@Test
public void testPojo5WithSexpInArray() throws Exception {
IonObjectMapper mapper = IonObjectMapper.builder(ionF).propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE).disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
String value = "{value:[([blah])], number:\"Random\"}";
TestPojo5 test = mapper.readValue(ionSystem.singleValue(value), TestPojo5.class);
assertNotNull(test);
assertNotNull(test.number);
assertEquals("Random", test.number);
assertNotNull(test.value.get(0));
assertRoundTrip(value, TestPojo5.class);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonValueMapperTest method testPojo4WithSexpInArrayIgnored.
@Test
public void testPojo4WithSexpInArrayIgnored() throws Exception {
IonObjectMapper mapper = IonObjectMapper.builder(ionF).propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE).disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
String value = "{value:[([])], number:\"Random\"}";
TestPojo4 test = mapper.readValue(ionSystem.singleValue(value), TestPojo4.class);
assertNotNull(test);
assertNotNull(test.number);
assertEquals("Random", test.number);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantDeserializerTest method testDeserializationWithTypeInfo01.
/*
**********************************************************************
* Deserialization of actuals with type info
**********************************************************************
*/
@Test
public void testDeserializationWithTypeInfo01() throws Exception {
Instant expected = Instant.ofEpochSecond(123456789L, 183917322);
IonObjectMapper m = newMapperBuilder().enable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\",123456789.183917322]", Temporal.class);
assertTrue("The actual should be an Instant.", actual instanceof Instant);
assertEquals("The value is not correct.", expected, actual);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantDeserializerTest method testDeserializationWithTypeInfo04.
@Test
public void testDeserializationWithTypeInfo04() throws Exception {
Instant expected = Instant.now();
IonObjectMapper m = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.UTC);
Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class);
assertTrue("The actual should be an Instant.", actual instanceof Instant);
assertEquals("The value is not correct.", expected, actual);
}
Aggregations