1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.search.engine.test.mocks;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
/**
* @author Roberto E. Escobar
*/
public final class EngineAsserts {
private EngineAsserts() {
// Test Utility Class
}
public static void assertTagsEqual(List<Pair<String, Long>> expected, List<Pair<String, Long>> actual) {
Assert.assertEquals(expected.size(), actual.size());
for (int index = 0; index < expected.size(); index++) {
assertEquals(expected.get(index), actual.get(index));
}
}
public static void assertEquals(List<MatchLocation> expected, List<MatchLocation> actual) {
Assert.assertEquals(expected.size(), actual.size());
for (int index = 0; index < expected.size(); index++) {
assertEquals(expected.get(index), actual.get(index));
}
}
public static final void assertEquals(AttributeData expected, AttributeData actual) {
if (expected == null) {
Assert.assertNull(actual);
} else {
Assert.assertEquals(expected.getArtId(), actual.getArtId());
Assert.assertEquals(expected.getAttrTypeId(), actual.getAttrTypeId());
Assert.assertEquals(expected.getGammaId(), actual.getGammaId());
Assert.assertEquals(expected.getBranchId(), actual.getBranchId());
Assert.assertEquals(expected.getStringValue(), actual.getStringValue());
Assert.assertEquals(expected.getUri(), actual.getUri());
Assert.assertEquals(expected.isUriValid(), actual.isUriValid());
}
}
public static void assertEquals(Pair<String, Long> expected, Pair<String, Long> actual) {
Assert.assertEquals(expected.getFirst(), actual.getFirst());
Assert.assertEquals(expected.getSecond(), actual.getSecond());
}
public static void assertEquals(MatchLocation expected, MatchLocation actual) {
if (expected == null) {
Assert.assertNull(actual);
} else {
Assert.assertEquals(expected.getStartPosition(), actual.getStartPosition());
Assert.assertEquals(expected.getEndPosition(), actual.getEndPosition());
Assert.assertEquals(expected.toString(), actual.toString());
}
}
public static List<Pair<String, Long>> asTags(String word, long... entries) {
List<Pair<String, Long>> data = new ArrayList<Pair<String, Long>>();
for (int index = 0; index < entries.length; index++) {
data.add(new Pair<String, Long>(word, entries[index]));
}
return data;
}
public static List<MatchLocation> asLocations(int... data) {
List<MatchLocation> locations = new ArrayList<MatchLocation>();
if (data != null && data.length > 0) {
for (int index = 0; index < data.length; index++) {
locations.add(new MatchLocation(data[index], data[++index]));
}
}
return locations;
}
}
|