Skip to content

Package: TestEnvironmentUtils

TestEnvironmentUtils

nameinstructionbranchcomplexitylinemethod
TestEnvironmentUtils()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
arePropertiesEqual(Map, Map)
M: 6 C: 36
86%
M: 3 C: 5
63%
M: 3 C: 2
40%
M: 3 C: 6
67%
M: 0 C: 1
100%
typesEqual(Set, Set)
M: 6 C: 19
76%
M: 8 C: 6
43%
M: 7 C: 1
13%
M: 1 C: 2
67%
M: 0 C: 1
100%

Coverage

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