Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan committed Nov 29, 2024
1 parent 1386698 commit 045cc34
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static ConfigurableJsonAssert assertThatJson(
/**
* JSON to be used in expected part of the assertion,
*
* @param input
*
* @return Object suitable for comparison. Implementation type may change in the future.
*/
@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class JsonUtils {
/**
* Converts object to JSON.
*
* @param source
*
* @param label label to be logged in case of error.
* @return
*
*/
public static Node convertToJson(@Nullable Object source, String label) {
return convertToJson(source, label, false);
Expand Down Expand Up @@ -113,8 +113,8 @@ static boolean nodeAbsent(Object json, Path path, boolean treatNullAsAbsent) {
/**
* Add quotes around the object iff it's not a JSON object.
*
* @param source
* @return
*
*
*/
static String quoteIfNeeded(String source) {
String trimmed = source.trim();
Expand All @@ -134,8 +134,8 @@ static String quoteIfNeeded(String source) {
/**
* Add quotes around the object iff it's not a JSON object.
*
* @param source
* @return
*
*
*/
static Object quoteIfNeeded(Object source) {
if (source instanceof String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import net.javacrumbs.jsonunit.core.internal.Node.KeyValue;

class Normalizer {
Expand Down Expand Up @@ -92,8 +89,4 @@ private static void addIndent(StringBuilder sb, int indent) {
sb.append(' ');
}
}

private static <T> Stream<T> stream(Iterator<T> iterator) {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public InternalMatcher withDifferenceListener(@NotNull DifferenceListener differ
* <b>before</b> assertion.
* For more info see {@link net.javacrumbs.jsonunit.core.Option}
*
* @param firstOption
* @param otherOptions
*
*
* @see net.javacrumbs.jsonunit.core.Option
*/
@NotNull
Expand All @@ -148,8 +148,8 @@ public InternalMatcher withOptions(@NotNull Option firstOption, @NotNull Option.
* Sets advanced/local options. This method has to be called <b>before</b> assertion.
* For more info see {@link Configuration#when(PathsParam, ApplicableForPath...)}
*
* @param object
* @param actions
*
*
* @see Configuration#when(PathsParam, ApplicableForPath...)
*/
@NotNull
Expand Down Expand Up @@ -211,7 +211,7 @@ public void isNotEqualTo(@Nullable Object expected) {
* assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1");
* </code>
*
* @param newPath
*
*/
@NotNull
public InternalMatcher node(@NotNull String newPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private JsonFluentAssert(Object actual, String pathPrefix) {
* It is not called assertThat to not clash with StringAssert.
* The json parameter is converted to JSON using ObjectMapper.
*
* @param json
*
* @return new JsonFluentAssert object.
*/
public static ConfigurableJsonFluentAssert assertThatJson(Object json) {
Expand All @@ -94,7 +94,7 @@ public static ConfigurableJsonFluentAssert assertThatJson(Object json) {
*
* If the string parameter is not a valid JSON, it is quoted automatically.
*
* @param expected
*
* @return {@code this} object.
* @see #isStringEqualTo(String)
*/
Expand All @@ -116,7 +116,7 @@ public JsonFluentAssert isStringEqualTo(String expected) {
* Fails if compared documents are equal. The expected object is converted to JSON
* before comparison. Ignores order of sibling nodes and whitespaces.
*
* @param expected
*
* @return {@code this} object.
*/
public JsonFluentAssert isNotEqualTo(Object expected) {
Expand All @@ -132,7 +132,7 @@ public JsonFluentAssert isNotEqualTo(Object expected) {
* assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1");
* </code>
*
* @param newPath
*
* @return object comparing only node given by path.
*/
public JsonFluentAssert node(String newPath) {
Expand All @@ -142,7 +142,7 @@ public JsonFluentAssert node(String newPath) {
/**
* Fails if the node exists.
*
* @return
*
*/
public JsonFluentAssert isAbsent() {
internalMatcher.isAbsent();
Expand All @@ -160,7 +160,7 @@ public JsonFluentAssert isPresent() {
/**
* Fails if the selected JSON is not an Array or is not present.
*
* @return
*
*/
public ArrayAssert isArray() {

Expand Down Expand Up @@ -190,8 +190,8 @@ public void isString() {
* <li>Objects are mapped to a map so you can use json(Part)Equals or a Map internalMatcher</li>
* </ul>
*
* @param matcher
* @return
*
*
*/
public JsonFluentAssert matches(Matcher<?> matcher) {
internalMatcher.matches(matcher);
Expand All @@ -210,8 +210,8 @@ public static class ArrayAssert {

/**
* Fails if the array has different length.
* @param expectedLength
* @return
*
*
*/
public ArrayAssert ofLength(int expectedLength) {
arrayMatcher.ofLength(expectedLength);
Expand Down Expand Up @@ -254,7 +254,7 @@ private ConfigurableJsonFluentAssert(Object actual, String pathPrefix) {
* assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1");
* </code>
*
* @param newPath
*
* @return object comparing only node given by path.
*/
@Override
Expand All @@ -273,8 +273,8 @@ public ConfigurableJsonFluentAssert whenIgnoringPaths(String... pathsToBeIgnored
/**
* Sets the description of this object.
*
* @param description
* @return
*
*
*/
public ConfigurableJsonFluentAssert as(String description) {
return describedAs(description);
Expand All @@ -283,8 +283,8 @@ public ConfigurableJsonFluentAssert as(String description) {
/**
* Sets the description of this object.
*
* @param description
* @return
*
*
*/
public ConfigurableJsonFluentAssert describedAs(String description) {
return new ConfigurableJsonFluentAssert(internalMatcher.describedAs(description));
Expand All @@ -294,8 +294,8 @@ public ConfigurableJsonFluentAssert describedAs(String description) {
* Sets the placeholder that can be used to ignore values.
* The default value is ${json-unit.ignore}
*
* @param ignorePlaceholder
* @return
*
*
*/
public ConfigurableJsonFluentAssert ignoring(String ignorePlaceholder) {
return new ConfigurableJsonFluentAssert(internalMatcher.withIgnorePlaceholder(ignorePlaceholder));
Expand All @@ -305,7 +305,7 @@ public ConfigurableJsonFluentAssert ignoring(String ignorePlaceholder) {
* Sets the tolerance for floating number comparison. If set to null, requires exact match of the values.
* For example, if set to 0.01, ignores all differences lower than 0.01, so 1 and 0.9999 are considered equal.
*
* @param tolerance
*
*/
public ConfigurableJsonFluentAssert withTolerance(double tolerance) {
return new ConfigurableJsonFluentAssert(internalMatcher.withTolerance(tolerance));
Expand All @@ -315,7 +315,7 @@ public ConfigurableJsonFluentAssert withTolerance(double tolerance) {
* Sets the tolerance for floating number comparison. If set to null, requires exact match of the values.
* For example, if set to 0.01, ignores all differences lower than 0.01, so 1 and 0.9999 are considered equal.
*
* @param tolerance
*
*/
public ConfigurableJsonFluentAssert withTolerance(BigDecimal tolerance) {
return new ConfigurableJsonFluentAssert(internalMatcher.withTolerance(tolerance));
Expand All @@ -337,8 +337,8 @@ public ConfigurableJsonFluentAssert withDifferenceListener(DifferenceListener di
* <b>before</b> assertion.
* For more info see {@link net.javacrumbs.jsonunit.core.Option}
*
* @param firstOption
* @param otherOptions
*
*
* @see net.javacrumbs.jsonunit.core.Option
*/
public ConfigurableJsonFluentAssert when(Option firstOption, Option... otherOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public ME when(
* <p/>
* If the string parameter is not a valid JSON, it is quoted automatically.
*
* @param expected
*
* @return {@code this} object.
* @see #isStringEqualTo(String)
*/
Expand Down Expand Up @@ -241,8 +241,8 @@ public MATCHER isNotNull() {
* <li>Objects are mapped to a map so you can use json(Part)Equals or a Map matcher</li>
* </ul>
*
* @param matcher
* @return
*
*
*/
@NotNull
public MATCHER matches(@NotNull final Matcher<?> matcher) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* JsonMatcher interface.
*
* @param <T>
*
*/
public interface ConfigurableJsonMatcher<T> extends Matcher<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
public class JsonAssert {
private static final String FULL_JSON = "fullJson";
private static final String ACTUAL = "actual";

private static final String ROOT = "";
private static Configuration configuration = Configuration.empty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.math.BigDecimal;
import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.Map;
import net.javacrumbs.jsonunit.core.Configuration;
import net.javacrumbs.jsonunit.core.ConfigurationWhen.ApplicableForPath;
import net.javacrumbs.jsonunit.core.ConfigurationWhen.PathsParam;
Expand Down Expand Up @@ -206,7 +205,7 @@ private static final class JsonPartMatcher<T> extends AbstractJsonMatcher<T> {
// other
// Hamcrest 2 calls doMatch() multiple times followed by multiple calls of describeMismatch()
// using IdentityHashMap since not all compared object do have to implement hashCode and equals
private final Map<Object, String> differences = new IdentityHashMap<>();
private final IdentityHashMap<Object, String> differences = new IdentityHashMap<>();

JsonPartMatcher(String path, Object expected) {
super(path);
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<version>2.38.0</version>
<configuration>
<java>
<palantirJavaFormat><version>2.38.0</version></palantirJavaFormat>
<palantirJavaFormat><version>2.50.0</version></palantirJavaFormat>
<removeUnusedImports />
</java>
<kotlin>
Expand Down

0 comments on commit 045cc34

Please sign in to comment.