Skip to content

Package: Generators

Generators

nameinstructionbranchcomplexitylinemethod
createProperties()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createProperties(int)
M: 4 C: 58
94%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 11
100%
M: 0 C: 1
100%
createReferencedList()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createReferencedList(int)
M: 4 C: 14
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 5
100%
M: 0 C: 1
100%
createSimpleList()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createSimpleList(int)
M: 4 C: 14
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 5
100%
M: 0 C: 1
100%
createSimpleSet()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createSimpleSet(int)
M: 4 C: 14
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 5
100%
M: 0 C: 1
100%
generateInstances(Collection, String, int)
M: 4 C: 46
92%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 10
100%
M: 0 C: 1
100%
getTypes()
M: 0 C: 19
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 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 cz.cvut.kbss.jopa.test.OWLClassA;
18:
19: import java.net.URI;
20: import java.util.*;
21:
22: /**
23: * Generators of test data.
24: *
25: * @author ledvima1
26: */
27: public abstract class Generators {
28:
29: private static final int DEFAULT_SIZE = 5;
30: private static final Set<String> TYPES = getTypes();
31:
32: private Generators() {
33: // Private constructor
34: }
35:
36: public static List<OWLClassA> createSimpleList() {
37: return createSimpleList(DEFAULT_SIZE);
38: }
39:
40: public static List<OWLClassA> createReferencedList() {
41: return createReferencedList(DEFAULT_SIZE);
42: }
43:
44: public static Set<OWLClassA> createSimpleSet() {
45: return createSimpleSet(DEFAULT_SIZE);
46: }
47:
48: public static List<OWLClassA> createSimpleList(int size) {
49:• assert size > 0;
50: final List<OWLClassA> lst = new ArrayList<>(size);
51: generateInstances(lst, "http://krizik.felk.cvut.cz/ontologies/jopa/tests/entityASimple",
52: size);
53: return lst;
54: }
55:
56: public static List<OWLClassA> createReferencedList(int size) {
57:• assert size > 0;
58: final List<OWLClassA> lst = new ArrayList<>(size);
59: generateInstances(lst,
60: "http://krizik.felk.cvut.cz/ontologies/jopa/tests/entityAReferenced", size);
61: return lst;
62: }
63:
64: public static Map<String, Set<String>> createProperties() {
65: return createProperties(DEFAULT_SIZE);
66: }
67:
68: public static Map<String, Set<String>> createProperties(int size) {
69:• assert size > 0;
70: final Map<String, Set<String>> m = new HashMap<>(size);
71: int counter = TestEnvironmentUtils.randomInt(1000);
72:• for (int i = 0; i < size; i++) {
73: final Set<String> value = new HashSet<>(4);
74:• for (int j = 0; j < size; j++) {
75: value.add("http://krizik.felk.cvut.cz/ontologies/jopa/tests/ObjectPropertyValue_" + j + "_"
76: + counter);
77: }
78: m.put("http://krizik.felk.cvut.cz/ontologies/jopa/attributes#property" + counter, value);
79: counter++;
80:
81: }
82: return m;
83: }
84:
85: public static Set<OWLClassA> createSimpleSet(int size) {
86:• assert size > 0;
87: final Set<OWLClassA> set = new HashSet<>(size);
88: generateInstances(set, "http://krizik.felk.cvut.cz/ontologies/jopa/tests/entityASimpleSet",
89: size);
90: return set;
91: }
92:
93: private static void generateInstances(Collection<OWLClassA> col, String uriBase, int size) {
94:• assert size > 0;
95: int counter = TestEnvironmentUtils.randomInt(1000);
96:• for (int i = 0; i < size; i++) {
97: final OWLClassA a = new OWLClassA();
98: a.setUri(URI.create(uriBase + counter));
99: a.setStringAttribute("stringAttributeeee" + counter);
100: counter++;
101: a.setTypes(TYPES);
102: col.add(a);
103: }
104: }
105:
106: private static Set<String> getTypes() {
107: final Set<String> types = new HashSet<>(3);
108: types.add("http://krizik.felk.cvut.cz/ontologies/jopa/entities#OWLClassA");
109: types.add("http://krizik.felk.cvut.cz/ontologies/jopa/entities#OWLClassX");
110: types.add("http://krizik.felk.cvut.cz/ontologies/jopa/entities#OWLClassZ");
111: return types;
112: }
113: }