fix warnings
This commit is contained in:
parent
4d4ebe9c7f
commit
5d9f74ff1e
4 changed files with 13 additions and 19 deletions
|
|
@ -13,7 +13,6 @@ import java.util.concurrent.atomic.LongAdder;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
/**
|
||||
* Deep (recursive) comparison of two objects
|
||||
* - floating point comparison with optional precision
|
||||
|
|
@ -21,6 +20,7 @@ import java.util.stream.Stream;
|
|||
*
|
||||
* In case of maps or differing object types, every item in apple is expected in orange, so apple can be subset of orange.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class Compare {
|
||||
private final static Map<Character, String> CHAR_ESCAPES = Map.of('\t', "\\t", '\b', "\\b", '\n', "\\n", '\r', "\\r", '\f', "\\f", '\\', "\\\\");
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ public class Compare {
|
|||
if (apple.getClass() != orange.getClass()) {
|
||||
if (allowDifferingTypes) {
|
||||
// convert objects to maps and compare their keys/values
|
||||
return compareMaps(property, ToMap.map(apple), (Map<?, ?>) ToMap.map(orange), allowDifferingTypes);
|
||||
return compareMaps(property, ToMap.map(apple), ToMap.map(orange), allowDifferingTypes);
|
||||
} else {
|
||||
return Result.unequal(property, asString(apple) + " != " + asString(orange));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.Objects;
|
|||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Result {
|
||||
private final boolean areEqual;
|
||||
private final List<String> diffs;
|
||||
|
|
@ -70,6 +71,14 @@ public class Result {
|
|||
return areEqual;
|
||||
}
|
||||
|
||||
public boolean hasException(){
|
||||
return e != null;
|
||||
}
|
||||
|
||||
public Throwable getException() {
|
||||
return e;
|
||||
}
|
||||
|
||||
public static Result merge(Result... result) {
|
||||
boolean areEqual = Arrays.stream(result).allMatch(r -> r.areEqual);
|
||||
List<String> diffs = Arrays.stream(result)
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
import nl.sander.reflective.tomap.AbstractToMap;
|
||||
import nl.sander.reflective.compare.PlumBean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExampleMappifier extends AbstractToMap {
|
||||
|
||||
public Map<String, Object> toMap(Object o) {
|
||||
HashMap<String, Object> m = new HashMap<>();
|
||||
add(m, "core", ((PlumBean) o).getCore());
|
||||
add(m, "number", ((PlumBean) o).getNumber());
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ public class DifferentTypesTest {
|
|||
assertTrue(Compare.any(new Apple("orange"), new Orange("orange")).areEqual());
|
||||
}
|
||||
|
||||
class Apple {
|
||||
static class Apple {
|
||||
final String color;
|
||||
|
||||
Apple(String color) {
|
||||
|
|
@ -18,7 +18,7 @@ public class DifferentTypesTest {
|
|||
}
|
||||
}
|
||||
|
||||
class Orange {
|
||||
static class Orange {
|
||||
final String color;
|
||||
|
||||
Orange(String color) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue