Skip to content

Commit

Permalink
Revert code changes in favor of a doc fix
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <widdis@gmail.com>
  • Loading branch information
dbwiddis committed Nov 4, 2022
1 parent 4c85bc9 commit 2145e42
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
1 change: 0 additions & 1 deletion java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ dependencies {

implementation("com.fasterxml.jackson.core", "jackson-core", jacksonVersion)
implementation("com.fasterxml.jackson.core", "jackson-databind", jacksonDatabindVersion)
implementation("com.fasterxml.jackson.datatype", "jackson-datatype-jsr310", jacksonVersion)
testImplementation("com.fasterxml.jackson.datatype", "jackson-datatype-jakarta-jsonp", jacksonVersion)

// For AwsSdk2Transport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.json.spi.JsonProvider;
import jakarta.json.stream.JsonGenerator;
import jakarta.json.stream.JsonParser;
Expand All @@ -62,8 +61,7 @@ public JacksonJsonpMapper(ObjectMapper objectMapper, JsonFactory jsonFactory) {
this.provider = new JacksonJsonProvider(jsonFactory);
this.objectMapper = objectMapper
.configure(SerializationFeature.INDENT_OUTPUT, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.registerModule(new JavaTimeModule());
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}

public JacksonJsonpMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,25 @@
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

public class JsonpMapperTest extends Assert {

String json = "{\"children\":[{\"doubleValue\":3.2,\"intValue\":2}],\"doubleValue\":2.1,\"intValue\":1," +
"\"stringValue\":\"foo\"}";

@Test
public void testJsonb() {
String json = "{\"children\":[{\"doubleValue\":3.2,\"intValue\":2}],\"doubleValue\":2.1," +
"\"instantValue\":\"1970-01-01T00:00:00Z\",\"intValue\":1,\"stringValue\":\"foo\"}";

JsonpMapper mapper = new JsonbJsonpMapper();
testSerialize(mapper, json);
testDeserialize(mapper, json);
}

@Test
public void testJackson() {
String json = "{\"children\":[{\"doubleValue\":3.2,\"intValue\":2}],\"doubleValue\":2.1,\"intValue\":1," +
"\"stringValue\":\"foo\",\"instantValue\":0.0}";

JacksonJsonpMapper mapper = new JacksonJsonpMapper();
testSerialize(mapper, json);
testDeserialize(mapper, json);
Expand All @@ -91,7 +87,7 @@ public void testJacksonCustomMapper() {
JacksonJsonpMapper mapper = new JacksonJsonpMapper(jkMapper);

String json = "{\"children\":[{\"double_value\":3.2,\"int_value\":2}],\"double_value\":2.1,\"int_value\":1," +
"\"string_value\":\"foo\",\"instant_value\":0.0}";
"\"string_value\":\"foo\"}";

testSerialize(mapper, json);
testDeserialize(mapper, json);
Expand All @@ -112,7 +108,6 @@ public void testJacksonCustomJsonFactory() {
.add("doubleValue", "2.1")
.add("intValue", 1)
.add("stringValue", "foo")
.add("instantValue", "1970-01-01T00:00:00Z")
.build();

final Writer writer = new StringWriter();
Expand Down Expand Up @@ -184,7 +179,6 @@ private void testSerialize(JsonpMapper mapper, String expected) {
something.setIntValue(1);
something.setDoubleValue(2.1);
something.setStringValue("foo");
something.setInstantValue(Instant.EPOCH);

SomeClass other = new SomeClass();
other.setIntValue(2);
Expand All @@ -209,7 +203,6 @@ private void testDeserialize(JsonpMapper mapper, String json) {
assertEquals(1, parsed.getIntValue());
assertEquals(2.1, parsed.getDoubleValue(), 0.0);
assertEquals("foo", parsed.getStringValue());
assertEquals(Instant.EPOCH, parsed.getInstantValue());

List<SomeClass> children = parsed.getChildren();
assertEquals(1, children.size());
Expand All @@ -227,7 +220,6 @@ public static class SomeClass {
private double doubleValue;
private int intValue;
private String stringValue;
private Instant instantValue;

public int getIntValue() {
return intValue;
Expand All @@ -249,14 +241,6 @@ public double getDoubleValue() {
return doubleValue;
}

public void setInstantValue(Instant instantValue) {
this.instantValue = instantValue;
}

public Instant getInstantValue() {
return instantValue;
}

public void setDoubleValue(double doubleValue) {
this.doubleValue = doubleValue;
}
Expand Down

0 comments on commit 2145e42

Please sign in to comment.