Package: TestEnvironmentUtils
TestEnvironmentUtils
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TestEnvironmentUtils() |
|
|
|
|
|
||||||||||||||||||||
arePropertiesEqual(Map, Map) |
|
|
|
|
|
||||||||||||||||||||
typesEqual(Set, Set) |
|
|
|
|
|
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.test.environment;
19:
20: import java.util.Map;
21: import java.util.Set;
22:
23: public class TestEnvironmentUtils {
24:
25: private TestEnvironmentUtils() {
26: throw new AssertionError();
27: }
28:
29: public static <K, V> boolean arePropertiesEqual(Map<K, Set<V>> pOne, Map<K, Set<V>> pTwo) {
30:• if (pOne.size() != pTwo.size()) {
31: return false;
32: }
33:• for (Map.Entry<K, Set<V>> e : pOne.entrySet()) {
34:• if (!pTwo.containsKey(e.getKey())) {
35: return false;
36: }
37: final Set<?> set = pTwo.get(e.getKey());
38:• if (!e.getValue().equals(set)) {
39: return false;
40: }
41: }
42: return true;
43: }
44:
45: public static <E> boolean typesEqual(Set<E> expected, Set<E> actual) {
46:• if (expected == null && actual != null || expected != null && actual == null) {
47: return false;
48: }
49:• return expected == null || expected.size() == actual.size() && expected.containsAll(actual);
50: }
51: }