nastra commented on code in PR #7895:
URL: https://github.com/apache/iceberg/pull/7895#discussion_r1254176431
##########
core/src/test/java/org/apache/iceberg/util/TestJsonUtil.java:
##########
@@ -18,247 +18,202 @@
*/
package org.apache.iceberg.util;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.io.BaseEncoding;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestJsonUtil {
@Test
public void get() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.get("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.get("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing field: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.get("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.get("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing field: x");
- Assertions.assertThat(JsonUtil.get("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")).asText())
+ assertThat(JsonUtil.get("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")).asText())
.isEqualTo("23");
}
@Test
public void getInt() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing int: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: \"23\"");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
23.0}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: 23.0");
- Assertions.assertThat(JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
- .isEqualTo(23);
+ assertThat(JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
23}"))).isEqualTo(23);
}
@Test
public void getIntOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
- Assertions.assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
- .isEqualTo(23);
- Assertions.assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
- .isNull();
+ assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getIntOrNull("x", JsonUtil.mapper().readTree("{\"x\":
23}"))).isEqualTo(23);
+ assertThat(JsonUtil.getIntOrNull("x", JsonUtil.mapper().readTree("{\"x\":
null}"))).isNull();
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: \"23\"");
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: 23.0");
}
@Test
public void getLong() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing long: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: \"23\"");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
23.0}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: 23.0");
- Assertions.assertThat(JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
- .isEqualTo(23);
+ assertThat(JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
23}"))).isEqualTo(23);
}
@Test
public void getLongOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
- Assertions.assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
+ assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getLongOrNull("x", JsonUtil.mapper().readTree("{\"x\":
23}")))
.isEqualTo(23);
- Assertions.assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
- .isNull();
+ assertThat(JsonUtil.getLongOrNull("x", JsonUtil.mapper().readTree("{\"x\":
null}"))).isNull();
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: \"23\"");
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: 23.0");
}
@Test
public void getString() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing string: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getString("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a string value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getString("x", JsonUtil.mapper().readTree("{\"x\":
23}")))
+ assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a string value: x: 23");
- Assertions.assertThat(JsonUtil.getString("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
+ assertThat(JsonUtil.getString("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
.isEqualTo("23");
}
@Test
public void getStringOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
- Assertions.assertThat(
- JsonUtil.getStringOrNull("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isEqualTo("23");
- Assertions.assertThat(
- JsonUtil.getStringOrNull("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
- .isNull();
+ assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}"))).isNull();
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a string value: x: 23");
}
@Test
public void getByteBufferOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{}")))
- .isNull();
- Assertions.assertThat(
- JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
+ assertThat(JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isNull();
byte[] bytes = new byte[] {1, 2, 3, 4};
String base16Str = BaseEncoding.base16().encode(bytes);
String json = String.format("{\"x\": \"%s\"}", base16Str);
ByteBuffer byteBuffer = JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree(json));
- Assertions.assertThat(byteBuffer.array()).isEqualTo(bytes);
+ assertThat(byteBuffer.array()).isEqualTo(bytes);
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse byte buffer from non-text value: x: 23");
}
@Test
public void getBool() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing boolean: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getBool("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a boolean value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getBool("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a boolean value: x: \"23\"");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getBool("x", JsonUtil.mapper().readTree("{\"x\":
\"true\"}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": \"true\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a boolean value: x: \"true\"");
- Assertions.assertThat(JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": true}")))
- .isTrue();
- Assertions.assertThat(JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": false}")))
- .isFalse();
- }
-
- @Test
- public void getIntArrayOrNull() throws JsonProcessingException {
Review Comment:
this also needs to be reverted. In fact, can you please revert all changes
to this file. I believe the only change that this file requires is switching
from `org.junit.Test` to `org.junit.jupiter.api.Test` (everything else just
adds too much visual noise
##########
core/src/test/java/org/apache/iceberg/util/TestJsonUtil.java:
##########
@@ -18,247 +18,202 @@
*/
package org.apache.iceberg.util;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.io.BaseEncoding;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestJsonUtil {
@Test
public void get() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.get("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.get("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing field: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.get("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.get("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing field: x");
- Assertions.assertThat(JsonUtil.get("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")).asText())
+ assertThat(JsonUtil.get("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")).asText())
.isEqualTo("23");
}
@Test
public void getInt() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing int: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: \"23\"");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
23.0}")))
+ assertThatThrownBy(() -> JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: 23.0");
- Assertions.assertThat(JsonUtil.getInt("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
- .isEqualTo(23);
+ assertThat(JsonUtil.getInt("x", JsonUtil.mapper().readTree("{\"x\":
23}"))).isEqualTo(23);
}
@Test
public void getIntOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
- Assertions.assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
- .isEqualTo(23);
- Assertions.assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
- .isNull();
+ assertThat(JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getIntOrNull("x", JsonUtil.mapper().readTree("{\"x\":
23}"))).isEqualTo(23);
+ assertThat(JsonUtil.getIntOrNull("x", JsonUtil.mapper().readTree("{\"x\":
null}"))).isNull();
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: \"23\"");
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getIntOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to an integer value: x: 23.0");
}
@Test
public void getLong() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing long: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: \"23\"");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
23.0}")))
+ assertThatThrownBy(() -> JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: 23.0");
- Assertions.assertThat(JsonUtil.getLong("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
- .isEqualTo(23);
+ assertThat(JsonUtil.getLong("x", JsonUtil.mapper().readTree("{\"x\":
23}"))).isEqualTo(23);
}
@Test
public void getLongOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
- Assertions.assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
+ assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getLongOrNull("x", JsonUtil.mapper().readTree("{\"x\":
23}")))
.isEqualTo(23);
- Assertions.assertThat(JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
- .isNull();
+ assertThat(JsonUtil.getLongOrNull("x", JsonUtil.mapper().readTree("{\"x\":
null}"))).isNull();
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: \"23\"");
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getLongOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23.0}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a long value: x: 23.0");
}
@Test
public void getString() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing string: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getString("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a string value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getString("x", JsonUtil.mapper().readTree("{\"x\":
23}")))
+ assertThatThrownBy(() -> JsonUtil.getString("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a string value: x: 23");
- Assertions.assertThat(JsonUtil.getString("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
+ assertThat(JsonUtil.getString("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
.isEqualTo("23");
}
@Test
public void getStringOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
- Assertions.assertThat(
- JsonUtil.getStringOrNull("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isEqualTo("23");
- Assertions.assertThat(
- JsonUtil.getStringOrNull("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
- .isNull();
+ assertThat(JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}"))).isNull();
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getStringOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a string value: x: 23");
}
@Test
public void getByteBufferOrNull() throws JsonProcessingException {
- Assertions.assertThat(JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{}")))
- .isNull();
- Assertions.assertThat(
- JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
+ assertThat(JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{}"))).isNull();
+ assertThat(JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isNull();
byte[] bytes = new byte[] {1, 2, 3, 4};
String base16Str = BaseEncoding.base16().encode(bytes);
String json = String.format("{\"x\": \"%s\"}", base16Str);
ByteBuffer byteBuffer = JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree(json));
- Assertions.assertThat(byteBuffer.array()).isEqualTo(bytes);
+ assertThat(byteBuffer.array()).isEqualTo(bytes);
- Assertions.assertThatThrownBy(
+ assertThatThrownBy(
() -> JsonUtil.getByteBufferOrNull("x",
JsonUtil.mapper().readTree("{\"x\": 23}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse byte buffer from non-text value: x: 23");
}
@Test
public void getBool() throws JsonProcessingException {
- Assertions.assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse missing boolean: x");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getBool("x", JsonUtil.mapper().readTree("{\"x\":
null}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": null}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a boolean value: x: null");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getBool("x", JsonUtil.mapper().readTree("{\"x\":
\"23\"}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": \"23\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a boolean value: x: \"23\"");
- Assertions.assertThatThrownBy(
- () -> JsonUtil.getBool("x", JsonUtil.mapper().readTree("{\"x\":
\"true\"}")))
+ assertThatThrownBy(() -> JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": \"true\"}")))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Cannot parse to a boolean value: x: \"true\"");
- Assertions.assertThat(JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": true}")))
- .isTrue();
- Assertions.assertThat(JsonUtil.getBool("x",
JsonUtil.mapper().readTree("{\"x\": false}")))
- .isFalse();
- }
-
- @Test
- public void getIntArrayOrNull() throws JsonProcessingException {
Review Comment:
this also needs to be reverted. In fact, can you please revert all changes
to this file. I believe the only change that this file requires is switching
from `org.junit.Test` to `org.junit.jupiter.api.Test` (everything else just
adds too much visual noise)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]