Skip to content

Commit

Permalink
Merge branch '2.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 25, 2023
2 parents f4e1567 + 922784d commit 52d5dfa
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstractions.
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
<version>1.2.12</version>
<scope>test</scope>
</dependency>
<!-- For validating more complex comparisons -->
Expand Down
4 changes: 2 additions & 2 deletions ion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ SomeType otherValue = mapper.readValue(data, SomeType.class);

### java.time JSR 310

With version 2.12 (to be released in September 2020), there will be optional support for
Version 2.12 (released on November 28, 2020) added support for
(de)serializing some `java.time` classes directly from/to Ion timestamp values.
To enable it, you need to registed module `IonJavaTimeModule` like so:
To enable it, you need to register module `IonJavaTimeModule` like so:

```java
IonObjectMapper mapper = IonObjectMapper.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ValueDeserializer<T> createContextual(DeserializationContext ctxt, BeanPr

final JsonFormat.Value format = findFormatOverrides(ctxt, property, handledType());
if (format != null) {
return new IonTimestampInstantDeserializer<T>(this,
return new IonTimestampInstantDeserializer<>(this,
format.getFeature(Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE));
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public void testIonRoot() throws IOException {
Bean bean = m.readValue(root, Bean.class);
assertNotNull(bean);
assertEquals(bean.a, "test");
assertTrue(bean.b == 0.25);
assertEquals(0.25, bean.b, 0.0);
assertArrayEquals(new byte[0], bean.data);
assertEquals(bean.state, true);
assertTrue(bean.state);
assertNotNull(bean.sub);
assertEquals("yellow", bean.sub.getValue());
assertEquals("testSymbol", bean.symbol);
Expand Down Expand Up @@ -217,7 +217,7 @@ private void _testRoundTrip(Bean bean, RoundTrippers rt, IonObjectMapper m) thro

assertNotNull(result);
assertEquals(bean.a, result.a);
assertTrue(bean.b == result.b);
assertEquals(bean.b, result.b, 0.0);
assertArrayEquals(bean.data, result.data);
assertEquals(bean.state, result.state);
if (bean.sub == null)
Expand All @@ -233,6 +233,6 @@ private void _testRoundTrip(Bean bean, RoundTrippers rt, IonObjectMapper m) thro
assertEquals(bean.enumVal, result.enumVal);
assertEquals(bean.bigDec, result.bigDec);
assertEquals(bean.bigInt, result.bigInt);
assertTrue(bean.f == result.f);
assertEquals(bean.f, result.f, 0.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class IonGeneratorTest {
"}";

static {
final Map<String, String> map = new HashMap<String, String>();
final Map<String, String> map = new HashMap<>();
map.put("a", "A");
map.put("b", "B");
map.put("c", "C");
Expand Down Expand Up @@ -77,7 +77,7 @@ public void setUp() throws Exception {
@Test
public void testSimpleWrite() throws Exception {
joiGenerator.writeBoolean(true);
assertThat(output.get(0), is((IonValue)ionSystem.newBool(true)));
assertThat(output.get(0), is(ionSystem.newBool(true)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testGetNumberTypeAndValue() throws Exception {
IonParser decimalParser = ionFactory.createParser(EMPTY_READ_CTXT, ionDecimal);
Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, decimalParser.nextToken());
Assert.assertEquals(JsonParser.NumberType.BIG_DECIMAL, decimalParser.getNumberType());
Assert.assertTrue(new BigDecimal("" + decimalValue).compareTo((BigDecimal)decimalParser.getNumberValue()) == 0);
Assert.assertEquals(0, new BigDecimal("" + decimalValue).compareTo((BigDecimal) decimalParser.getNumberValue()));

Double floatValue = Double.MAX_VALUE;
IonValue ionFloat = ion.newFloat(floatValue);
Expand All @@ -84,7 +84,7 @@ public void testGetNumberTypeAndValue() throws Exception {
IonParser bigDecimalParser = ionFactory.createParser(EMPTY_READ_CTXT, ionBigDecimal);
Assert.assertEquals(JsonToken.VALUE_NUMBER_FLOAT, bigDecimalParser.nextToken());
Assert.assertEquals(JsonParser.NumberType.BIG_DECIMAL, bigDecimalParser.getNumberType());
Assert.assertTrue(bigDecimalValue.compareTo((BigDecimal)bigDecimalParser.getNumberValue()) == 0);
Assert.assertEquals(0, bigDecimalValue.compareTo((BigDecimal) bigDecimalParser.getNumberValue()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void _writeSimple(JsonGenerator gen) throws IOException
gen.writeStartObject();
gen.writeStringProperty("a", "value");
gen.writeNumberProperty("b", 42);
((IonGenerator)gen).writeName("c");
gen.writeName("c");
((IonGenerator)gen).writeNull(IonType.INT);
gen.writeEndObject();
gen.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ public void testSelectivePolymorphism() throws IOException {
// to be chosen (and we expect that first id to be the most narrow type, ChildBeanSub).
Bean deserialized = mapper.readValue(serialized, Bean.class);

assertTrue(deserialized.child.getClass().equals(ChildBeanSub.class));
assertEquals(deserialized.child.getClass(), ChildBeanSub.class);
assertEquals(((ChildBeanSub) original.child).extraField, ((ChildBeanSub) deserialized.child).extraField);

// second, try deserializing with the wider type (ChildBean). We're losing data (extraField)
preferredTypeId = getClass().getCanonicalName() + "$ChildBean";
deserialized = mapper.readValue(serialized, Bean.class);

assertTrue(deserialized.child.getClass().equals(ChildBean.class));
assertEquals(deserialized.child.getClass(), ChildBean.class);
assertEquals(original.child.someField, deserialized.child.someField);

// third, try deserializing into an Object. The child node should deserialize, but immediately fail mapping.
Expand Down Expand Up @@ -445,7 +445,7 @@ class MultipleClassNameIdResolver extends ClassNameIdResolver implements Multipl
@Override
public String[] idsFromValue(Object value) {
List<String> ids = new ArrayList<String>();
List<String> ids = new ArrayList<>();
Class<?> cls = value.getClass();
while (null != cls) {
ids.add(super.idFromValueAndType(value, cls));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void verifyException(Throwable e, String match)
{
String msg = e.getMessage();
String lmsg = (msg == null) ? "" : msg.toLowerCase();
if (lmsg.indexOf(match.toLowerCase()) < 0) {
if (!lmsg.contains(match.toLowerCase())) {
fail("Expected an exception with a substrings ("+match+"): got one with message \""+msg+"\"");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class IonValueDeserializerTest {
private static class Data<T> {
Expand Down Expand Up @@ -208,7 +209,7 @@ public void testWithMissingProperty() throws IOException
String input2 = "{required:{}}";
MyBean deserializedBean2 = ionObjectMapper.readValue(input2, MyBean.class);
assertEquals(ionSystem.newEmptyStruct(), deserializedBean2.required);
assertEquals(null, deserializedBean2.optional);
assertNull(deserializedBean2.optional);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

Expand Down Expand Up @@ -138,7 +139,7 @@ public void testPojo1() throws Exception {
TestPojo1 t = ionValueMapper.readValue(ionSystem.singleValue(value), TestPojo1.class);
assertEquals("yes", t.myString);
assertEquals("yes", t.mySymbol);
assertEquals(false, t.doesThisWork);
assertFalse(t.doesThisWork);
assertEquals(5, t.iHaveSomeOtherName);
assertEquals(ReturnCode.Success, t.imAnEnum);
assertEquals(Timestamp.valueOf("2010-01-01T06:00:00Z"), t.someTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void verifyException(Throwable e, String match)
{
String msg = e.getMessage();
String lmsg = (msg == null) ? "" : msg.toLowerCase();
if (lmsg.indexOf(match.toLowerCase()) < 0) {
if (!lmsg.contains(match.toLowerCase())) {
fail("Expected an exception with a substrings ("+match+"): got one with message \""+msg+"\"");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ private static void assertCorrectlyTypedAndFormed(final Subclass expectedSubclas
assertEquals(expectedSubclass, (Subclass) actualBaseclass);
}
private static void assertEquals(Subclass expected, Subclass actual) {
Assert.assertEquals(expected.someString, ((Subclass) actual).someString);
Assert.assertEquals(expected.anInt, ((Subclass) actual).anInt);
Assert.assertEquals(expected.someString, actual.someString);
Assert.assertEquals(expected.anInt, actual.anInt);
}

private static void assertEqualIonValues(IonValue expected, IonValue actual) {
Expand Down

0 comments on commit 52d5dfa

Please sign in to comment.