From 4bfd0d122cf44bf51220fb6cbf86d855247a0068 Mon Sep 17 00:00:00 2001 From: Lukas Krecan Date: Wed, 1 Nov 2023 20:36:59 +0100 Subject: [PATCH] Ass spotless --- .../jsonunit/assertj/ExpectedNode.java | 7 +- .../jsonunit/assertj/JsonAssert.java | 68 +- .../jsonunit/assertj/JsonAssertions.java | 10 +- .../jsonunit/assertj/JsonComparator.java | 18 +- .../assertj/JsonComparisonStrategy.java | 3 +- .../jsonunit/assertj/JsonListAssert.java | 23 +- .../jsonunit/assertj/JsonMapAssert.java | 37 +- .../assertj/internal/JsonRepresentation.java | 3 +- .../jsonunit/core/Configuration.java | 143 +- .../jsonunit/core/ConfigurationWhen.java | 8 +- .../javacrumbs/jsonunit/core/Matchers.java | 9 +- .../jsonunit/core/NumberComparator.java | 3 +- .../net/javacrumbs/jsonunit/core/Option.java | 1 - .../core/internal/AbstractNodeFactory.java | 14 +- .../core/internal/ArrayComparison.java | 18 +- .../jsonunit/core/internal/ArrayUtils.java | 4 +- .../core/internal/ComparisonMatrix.java | 77 +- .../jsonunit/core/internal/Context.java | 25 +- .../jsonunit/core/internal/Converter.java | 28 +- .../internal/DefaultNumberComparator.java | 6 +- .../jsonunit/core/internal/Diff.java | 244 ++- .../core/internal/DifferenceContextImpl.java | 4 +- .../core/internal/DifferenceImpl.java | 3 +- .../jsonunit/core/internal/Differences.java | 3 +- .../core/internal/ExceptionFactory.java | 27 +- .../core/internal/ExceptionUtils.java | 11 +- .../core/internal/GenericNodeBuilder.java | 21 +- .../core/internal/GsonNodeFactory.java | 8 +- .../core/internal/HamcrestHandler.java | 21 +- .../core/internal/Jackson2NodeFactory.java | 10 +- .../core/internal/JohnzonNodeFactory.java | 44 +- .../core/internal/JsonOrgNodeFactory.java | 14 +- .../jsonunit/core/internal/JsonSource.java | 2 - .../jsonunit/core/internal/JsonUtils.java | 43 +- .../core/internal/MoshiNodeFactory.java | 7 +- .../jsonunit/core/internal/Node.java | 6 +- .../jsonunit/core/internal/NodeWrapper.java | 4 +- .../jsonunit/core/internal/Path.java | 8 +- .../jsonunit/core/internal/PathMatcher.java | 15 +- .../jsonunit/core/internal/PathOption.java | 4 +- .../core/internal/PathOptionMatcher.java | 6 +- .../jsonunit/core/internal/Utils.java | 3 +- .../internal/matchers/InternalMatcher.java | 62 +- .../jsonunit/core/listener/Difference.java | 7 +- .../core/listener/DifferenceContext.java | 1 - .../core/listener/DifferenceListener.java | 1 - .../jsonunit/core/util/ResourceUtils.java | 6 +- .../jsonunit/core/internal/ConverterTest.java | 22 +- .../core/internal/DifferenceTest.java | 42 +- .../jsonunit/core/internal/JsonUtilsTest.java | 20 +- .../core/internal/NodeFactoryTest.java | 27 +- .../core/internal/PathMatcherTest.java | 3 +- .../jsonunit/fluent/JsonFluentAssert.java | 19 +- .../jsonpath/InternalJsonPathUtils.java | 62 +- .../jsonunit/jsonpath/JsonPathAdapter.java | 19 +- .../jsonpath/InternalJsonPathUtilsTest.java | 8 +- .../spring/AbstractSpringMatcher.java | 8 +- .../spring/AbstractSpringMatchers.java | 11 +- .../spring/JsonUnitRequestMatchers.java | 10 +- .../spring/JsonUnitResultMatchers.java | 16 +- .../net/javacrumbs/jsonunit/spring/Utils.java | 7 +- .../spring/WebTestClientJsonMatcher.java | 20 +- .../jsonunit/spring/testit/ClientTest.java | 46 +- .../jsonunit/spring/testit/MockMvcTest.java | 89 +- .../spring/testit/WebTestClientTest.java | 119 +- .../spring/testit/demo/ExampleController.java | 21 +- .../spring/testit/demo/SpringConfig.java | 4 +- .../jsonunit/ConfigurableJsonMatcher.java | 7 +- .../net/javacrumbs/jsonunit/JsonAssert.java | 18 +- .../net/javacrumbs/jsonunit/JsonMatchers.java | 44 +- pom.xml | 11 + .../test/base/AbstractAssertJTest.java | 1334 ++++++++++------- .../test/base/AbstractJsonAssertTest.java | 690 +++++---- .../base/AbstractJsonFluentAssertTest.java | 462 +++--- .../test/base/AbstractJsonMatchersTest.java | 129 +- .../jsonunit/test/base/JsonTestUtils.java | 13 +- .../base/RecordingDifferenceListener.java | 5 +- .../jsonunit/test/base/RegexBuilder.java | 1 - .../test/base/beans/Jackson2Bean.java | 2 +- .../beans/Jackson2IgnorePropertyBean.java | 1 - .../jsonunit/test/all/AllAssertJTest.java | 74 +- .../jsonunit/test/all/AllJsonAssertTest.java | 66 +- .../test/all/AllJsonFluentAssertTest.java | 8 +- .../test/all/AllJsonMatchersTest.java | 16 +- .../jsonunit/test/gson/GsonAssertJTest.java | 2 +- .../test/gson/GsonJsonAssertTest.java | 1 - .../test/gson/GsonJsonFluentAssertTest.java | 4 +- .../jackson2config/Jackson2ConfigTest.java | 7 +- .../Java8ObjectMapperProvider.java | 1 - .../test/jackson2/Jackson2AssertJTest.java | 20 +- .../jackson2/Jackson2FluentAssertTest.java | 4 +- .../test/johnzon/JohnzonAssertJTest.java | 8 +- .../test/johnzon/JohnzonJsonAssertTest.java | 1 - .../johnzon/JohnzonJsonFluentAssertTest.java | 17 +- .../jsonunit/test/jsonpath/JsonPathTest.java | 39 +- .../test/jsonorg/JsonOrgAssertJTest.java | 6 +- .../test/jsonorg/JsonOrgJsonAssertTest.java | 12 +- .../jsonorg/JsonOrgJsonFluentAssertTest.java | 4 +- .../jsonunit/test/junit4/JUnit4Test.java | 19 +- .../jsonunit/test/moshi/MoshiAssertJTest.java | 10 +- .../test/moshi/MoshiFluentAssertTest.java | 4 +- .../test/nohamcrest/NoHamcrestTest.java | 6 +- 102 files changed, 2734 insertions(+), 1975 deletions(-) diff --git a/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/ExpectedNode.java b/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/ExpectedNode.java index ee6ec8134..ac4a09242 100644 --- a/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/ExpectedNode.java +++ b/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/ExpectedNode.java @@ -15,11 +15,9 @@ */ package net.javacrumbs.jsonunit.assertj; - -import net.javacrumbs.jsonunit.core.internal.Node; - import java.math.BigDecimal; import java.util.Iterator; +import net.javacrumbs.jsonunit.core.internal.Node; /** * In AssertJ we need to know which node is expected and which is actual. This class marks expected node. @@ -93,8 +91,7 @@ public Object getValue() { } @Override - public void ___do_not_implement_this_interface_seriously() { - } + public void ___do_not_implement_this_interface_seriously() {} @Override public String toString() { diff --git a/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/JsonAssert.java b/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/JsonAssert.java index d44caaffb..f45c143ba 100644 --- a/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/JsonAssert.java +++ b/json-unit-assertj/src/main/java/net/javacrumbs/jsonunit/assertj/JsonAssert.java @@ -15,6 +15,26 @@ */ package net.javacrumbs.jsonunit.assertj; +import static net.javacrumbs.jsonunit.core.internal.Diff.quoteTextValue; +import static net.javacrumbs.jsonunit.core.internal.JsonUtils.getNode; +import static net.javacrumbs.jsonunit.core.internal.JsonUtils.getPathPrefix; +import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.ARRAY; +import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.BOOLEAN; +import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.NULL; +import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.NUMBER; +import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.OBJECT; +import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.STRING; +import static net.javacrumbs.jsonunit.jsonpath.InternalJsonPathUtils.resolveJsonPaths; +import static org.assertj.core.description.Description.mostRelevantDescription; +import static org.assertj.core.util.Strings.isNullOrEmpty; + +import java.math.BigDecimal; +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; import net.javacrumbs.jsonunit.core.Configuration; import net.javacrumbs.jsonunit.core.ConfigurationWhen.ApplicableForPath; import net.javacrumbs.jsonunit.core.ConfigurationWhen.PathsParam; @@ -39,34 +59,15 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.math.BigDecimal; -import java.net.URI; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static net.javacrumbs.jsonunit.core.internal.Diff.quoteTextValue; -import static net.javacrumbs.jsonunit.core.internal.JsonUtils.getNode; -import static net.javacrumbs.jsonunit.core.internal.JsonUtils.getPathPrefix; -import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.ARRAY; -import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.BOOLEAN; -import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.NULL; -import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.NUMBER; -import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.OBJECT; -import static net.javacrumbs.jsonunit.core.internal.Node.NodeType.STRING; -import static net.javacrumbs.jsonunit.jsonpath.InternalJsonPathUtils.resolveJsonPaths; -import static org.assertj.core.description.Description.mostRelevantDescription; -import static org.assertj.core.util.Strings.isNullOrEmpty; - public class JsonAssert extends AbstractAssert { final Path path; final Configuration configuration; private final Object actualForMatcher; JsonAssert(Path path, Configuration configuration, Object actual, boolean alreadyParsed) { - super(alreadyParsed ? JsonUtils.wrapDeserializedObject(actual) : JsonUtils.convertToJson(actual, "actual"), JsonAssert.class); + super( + alreadyParsed ? JsonUtils.wrapDeserializedObject(actual) : JsonUtils.convertToJson(actual, "actual"), + JsonAssert.class); this.path = path; this.configuration = configuration; this.actualForMatcher = alreadyParsed ? JsonUtils.wrapDeserializedObject(actual) : actual; @@ -89,7 +90,6 @@ public JsonAssert node(@NotNull String node) { return new JsonAssert(path.to(node), configuration, getNode(actual, node)); } - /** * Allows to do multiple comparisons on a document like * @@ -133,7 +133,7 @@ public JsonAssert isEqualTo(@Nullable Object expected) { public JsonMapAssert isObject() { Node node = assertType(OBJECT); return new JsonMapAssert((Map) node.getValue(), path.asPrefix(), configuration) - .as("Different value found in node \"%s\"", path); + .as("Different value found in node \"%s\"", path); } /** @@ -151,7 +151,7 @@ public BigDecimalAssert isNumber() { public BigIntegerAssert isIntegralNumber() { Node node = internalMatcher().assertIntegralNumber(); return new BigIntegerAssert(node.decimalValue().toBigIntegerExact()) - .as("Different value found in node \"%s\"", path); + .as("Different value found in node \"%s\"", path); } /** @@ -167,7 +167,8 @@ public BigDecimalAssert asNumber() { try { return createBigDecimalAssert(new BigDecimal(node.asText())); } catch (NumberFormatException e) { - failWithMessage("Node \"" + path + "\" can not be converted to number expected: but was: <" + quoteTextValue(node.getValue()) + ">."); + failWithMessage("Node \"" + path + "\" can not be converted to number expected: but was: <" + + quoteTextValue(node.getValue()) + ">."); } } else { internalMatcher().failOnType(node, "number or string"); @@ -182,13 +183,7 @@ private BigDecimalAssert createBigDecimalAssert(BigDecimal value) { private InternalMatcher internalMatcher() { String description = mostRelevantDescription(info.description(), "Node \"" + path + "\""); - return new InternalMatcher( - actualForMatcher, - path.asPrefix(), - "", - configuration, - description - ); + return new InternalMatcher(actualForMatcher, path.asPrefix(), "", configuration, description); } /** @@ -199,8 +194,7 @@ private InternalMatcher internalMatcher() { @NotNull public JsonListAssert isArray() { Node node = assertType(ARRAY); - return new JsonListAssert((List)node.getValue(), path.asPrefix(), configuration) - .as( "Node \"%s\"", path); + return new JsonListAssert((List) node.getValue(), path.asPrefix(), configuration).as("Node \"%s\"", path); } /** @@ -345,7 +339,8 @@ public ConfigurableJsonAssert withOptions(@NotNull Collection