diff --git a/wayang-api/wayang-api-scala-java/pom.xml b/wayang-api/wayang-api-scala-java/pom.xml index efc1cd3ee..fb064a12f 100644 --- a/wayang-api/wayang-api-scala-java/pom.xml +++ b/wayang-api/wayang-api-scala-java/pom.xml @@ -33,11 +33,19 @@ org.apache.wayang.api + 2.18.11 1.0.0 + + com.fasterxml.jackson + jackson-bom + ${jackson.version} + pom + import + org.apache.wayang wayang-commons @@ -145,7 +153,7 @@ com.fasterxml.jackson.core jackson-databind - 2.15.4 + ${jackson.version} com.fasterxml.jackson.module diff --git a/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JacksonCompatibilityTest.java b/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JacksonCompatibilityTest.java new file mode 100644 index 000000000..f8ca5d53c --- /dev/null +++ b/wayang-api/wayang-api-scala-java/src/test/java/org/apache/wayang/api/JacksonCompatibilityTest.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.wayang.api; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.module.scala.DefaultScalaModule; +import org.junit.jupiter.api.Test; +import scala.Tuple2; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class JacksonCompatibilityTest { + + @Test + void scalaTupleRoundtrip() throws Exception { + ObjectMapper mapper = new ObjectMapper().registerModule(new DefaultScalaModule()); + Tuple2 value = new Tuple2<>("count", 42); + + String json = mapper.writeValueAsString(value); + Tuple2 restored = mapper.readValue( + json, new TypeReference>() { }); + + assertEquals(value, restored); + } +}