| 1 |
|
package jalview.testutils; |
| 2 |
|
|
| 3 |
|
import org.testng.annotations.DataProvider; |
| 4 |
|
import org.testng.annotations.Test; |
| 5 |
|
import jalview.datamodel.Annotation; |
| 6 |
|
|
| 7 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
| 8 |
|
|
| 9 |
|
import java.awt.Color; |
| 10 |
|
import java.util.*; |
| 11 |
|
|
| |
|
| 67.4% |
Uncovered Elements: 14 (43) |
Complexity: 26 |
Complexity Density: 8.67 |
|
| 12 |
|
public class AnnotationsMatcherTest |
| 13 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 14 |
1 |
@DataProvider... |
| 15 |
|
public Object[][] matchingAnnotationsLists() |
| 16 |
|
{ |
| 17 |
1 |
return new Object[][] { |
| 18 |
|
{ |
| 19 |
|
new Annotation[] { |
| 20 |
|
new Annotation("C", "", 'C', 0.0f), |
| 21 |
|
new Annotation("C", "", 'C', 0.1f), |
| 22 |
|
new Annotation("B", "", 'B', 0.2f) }, |
| 23 |
|
new Annotation[] { |
| 24 |
|
new Annotation("C", "", 'C', 0.0f), |
| 25 |
|
new Annotation("C", "", 'C', 0.1f), |
| 26 |
|
new Annotation("B", "", 'B', 0.2f) } }, |
| 27 |
|
{ |
| 28 |
|
new Annotation[] { |
| 29 |
|
new Annotation("X", "xxx", 'X', 1.3f), |
| 30 |
|
new Annotation("V", "vvv", 'V', 1.5f), |
| 31 |
|
new Annotation("B", "bbb", 'B', 2.5f) }, |
| 32 |
|
new Annotation[] { |
| 33 |
|
new Annotation("X", "xxx", 'X', 1.3f), |
| 34 |
|
new Annotation("V", "vvv", 'V', 1.5f), |
| 35 |
|
new Annotation("B", "bbb", 'B', 2.5f) } }, |
| 36 |
|
{ |
| 37 |
|
new Annotation[] { |
| 38 |
|
new Annotation("A", "", 'A', 0.2f, Color.RED), |
| 39 |
|
new Annotation("A", "", 'A', 0.3f, Color.GREEN), |
| 40 |
|
new Annotation("C", "", 'C', 0.4f, Color.YELLOW), |
| 41 |
|
new Annotation("C", "", 'C', 0.5f) }, |
| 42 |
|
new Annotation[] { |
| 43 |
|
new Annotation("A", "", 'A', 0.2f, Color.RED), |
| 44 |
|
new Annotation("A", "", 'A', 0.3f, Color.GREEN), |
| 45 |
|
new Annotation("C", "", 'C', 0.4f, Color.YELLOW), |
| 46 |
|
new Annotation("C", "", 'C', 0.5f) } }, |
| 47 |
|
{ |
| 48 |
|
new Annotation[] { |
| 49 |
|
Annotation.EMPTY_ANNOTATION, Annotation.EMPTY_ANNOTATION }, |
| 50 |
|
new Annotation[] { |
| 51 |
|
Annotation.EMPTY_ANNOTATION, Annotation.EMPTY_ANNOTATION } }, |
| 52 |
|
{ |
| 53 |
|
new Annotation[] { null, null, null, null }, |
| 54 |
|
new Annotation[] { null, null, null, null } } }; |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 50% |
Uncovered Elements: 1 (2) |
Complexity: 2 |
Complexity Density: - |
1PASS
|
|
| 57 |
5 |
@Test(groups = { "Functional" }, dataProvider = "matchingAnnotationsLists")... |
| 58 |
|
public void testMatchesSafely_matchingAnnotations(Annotation[] template, |
| 59 |
|
Annotation[] testdata) |
| 60 |
|
{ |
| 61 |
5 |
assert new AnnotationsMatcher(Arrays.asList(template)) |
| 62 |
|
.matchesSafely(testdata); |
| 63 |
|
} |
| 64 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 65 |
1 |
@DataProvider... |
| 66 |
|
public Object[][] matchingAnnotations() |
| 67 |
|
{ |
| 68 |
1 |
return new Object[][] { |
| 69 |
|
{ |
| 70 |
|
new Annotation("A", "aaa", 'A', 0.1f), |
| 71 |
|
new Annotation("A", "aaa", 'A', 0.1f) }, |
| 72 |
|
{ |
| 73 |
|
new Annotation("A", "abcdef", 'A', 0.1f, Color.RED), |
| 74 |
|
new Annotation("A", "abcdef", 'A', 0.1f, Color.RED) }, |
| 75 |
|
{ |
| 76 |
|
new Annotation("", "xxxx", ' ', 0.0f), |
| 77 |
|
new Annotation("", "xxxx", ' ', 0.0f) }, |
| 78 |
|
{ |
| 79 |
|
new Annotation("", "", ' ', 0.0f), |
| 80 |
|
new Annotation("", "", ' ', 0.0f) }, |
| 81 |
|
{ |
| 82 |
|
new Annotation(null, null, ' ', 0.0f), |
| 83 |
|
new Annotation(null, null, ' ', 0.0f) }, |
| 84 |
|
{ |
| 85 |
|
new Annotation(null, "", ' ', 0.0f), |
| 86 |
|
new Annotation("", null, ' ', 0.0f) }, |
| 87 |
|
{ new Annotation(0f), Annotation.EMPTY_ANNOTATION }, |
| 88 |
|
{ new Annotation(1f), new Annotation("", "", ' ', 1f, null) }, }; |
| 89 |
|
} |
| 90 |
|
|
| |
|
| 50% |
Uncovered Elements: 1 (2) |
Complexity: 2 |
Complexity Density: - |
1PASS
|
|
| 91 |
8 |
@Test(groups = { "Functional" }, dataProvider = "matchingAnnotations")... |
| 92 |
|
public void testAnnotationsEqual_matchingAnnotations(Annotation first, |
| 93 |
|
Annotation second) |
| 94 |
|
{ |
| 95 |
8 |
assert AnnotationsMatcher.annotationsEqual(first, second); |
| 96 |
|
} |
| 97 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
1 |
@DataProvider... |
| 99 |
|
public Object[][] mismatchingAnnotations() |
| 100 |
|
{ |
| 101 |
1 |
return new Object[][] { |
| 102 |
|
{ |
| 103 |
|
new Annotation("A", "aaa", 'A', 1f), |
| 104 |
|
new Annotation("A", "aaa", 'B', 1f) }, |
| 105 |
|
{ new Annotation(1f), new Annotation(2f) }, |
| 106 |
|
{ new Annotation(1f), new Annotation("A", "", 'A', 1f) } }; |
| 107 |
|
} |
| 108 |
|
|
| |
|
| 50% |
Uncovered Elements: 1 (2) |
Complexity: 2 |
Complexity Density: - |
1PASS
|
|
| 109 |
3 |
@Test(groups = { "Functional" }, dataProvider = "mismatchingAnnotations")... |
| 110 |
|
public void testAnnotationsEqual_mismatchingAnnotations(Annotation first, |
| 111 |
|
Annotation second) |
| 112 |
|
{ |
| 113 |
3 |
assert !AnnotationsMatcher.annotationsEqual(first, second); |
| 114 |
|
} |
| 115 |
|
|
| |
|
| 50% |
Uncovered Elements: 1 (2) |
Complexity: 2 |
Complexity Density: - |
1PASS
|
|
| 116 |
1 |
@Test(groups = { "Functional" })... |
| 117 |
|
public void testAnnotationsEqual_nullsMatch() |
| 118 |
|
{ |
| 119 |
1 |
assert AnnotationsMatcher.annotationsEqual(null, null); |
| 120 |
|
} |
| 121 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 3 |
Complexity Density: - |
1PASS
|
|
| 122 |
1 |
@Test(groups = { "Functional" })... |
| 123 |
|
public void testAnnotationsEqual_nullNotMatchEmpty() |
| 124 |
|
{ |
| 125 |
1 |
assert !AnnotationsMatcher |
| 126 |
|
.annotationsEqual(null, Annotation.EMPTY_ANNOTATION); |
| 127 |
1 |
assert !AnnotationsMatcher |
| 128 |
|
.annotationsEqual(Annotation.EMPTY_ANNOTATION, null); |
| 129 |
|
} |
| 130 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 3 |
Complexity Density: - |
1PASS
|
|
| 131 |
1 |
@Test(groups = { "Functional" })... |
| 132 |
|
public void testAnnotationsEqual_compareNullDisplayCharToEmpty() |
| 133 |
|
{ |
| 134 |
1 |
assert AnnotationsMatcher |
| 135 |
|
.annotationsEqual(new Annotation("", "description", 'A', 0.1f), |
| 136 |
|
new Annotation(null, "description", 'A', 0.1f)); |
| 137 |
1 |
assert AnnotationsMatcher |
| 138 |
|
.annotationsEqual(new Annotation(null, "description", 'A', 0.1f), |
| 139 |
|
new Annotation("", "description", 'A', 0.1f)); |
| 140 |
|
} |
| 141 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 3 |
Complexity Density: - |
1PASS
|
|
| 142 |
1 |
@Test(groups = { "Functional" })... |
| 143 |
|
public void testAnnotationsEqual_compareNullDescriptionToEmpty() |
| 144 |
|
{ |
| 145 |
1 |
assert AnnotationsMatcher |
| 146 |
|
.annotationsEqual(new Annotation("A", null, 'A', 0.2f), |
| 147 |
|
new Annotation("A", "", 'A', 0.2f)); |
| 148 |
1 |
assert AnnotationsMatcher |
| 149 |
|
.annotationsEqual(new Annotation("A", "", 'A', 0.2f), |
| 150 |
|
new Annotation("A", null, 'A', 0.2f)); |
| 151 |
|
} |
| 152 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 3 |
Complexity Density: - |
1PASS
|
|
| 153 |
1 |
@Test(groups = { "Functional" })... |
| 154 |
|
public void testAnnotationsEqual_compareNullDisplayCharToBlank() |
| 155 |
|
{ |
| 156 |
1 |
assert !AnnotationsMatcher |
| 157 |
|
.annotationsEqual(new Annotation(" ", "aaa", 'A', 0.03f), |
| 158 |
|
new Annotation(null, "aaa", 'A', 0.03f)); |
| 159 |
1 |
assert !AnnotationsMatcher |
| 160 |
|
.annotationsEqual(new Annotation(null, "aaa", 'A', 0.04f), |
| 161 |
|
new Annotation(" ", "aaa", 'A', 0.04f)); |
| 162 |
|
} |
| 163 |
|
|
| |
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 3 |
Complexity Density: - |
1PASS
|
|
| 164 |
1 |
@Test(groups = { "Functional" })... |
| 165 |
|
public void testAnnotationsEqual_compareNullDescriptionToBlank() |
| 166 |
|
{ |
| 167 |
1 |
assert !AnnotationsMatcher |
| 168 |
|
.annotationsEqual(new Annotation("A", null, 'A', 0.0f), |
| 169 |
|
new Annotation("A", " ", 'A', 0.0f)); |
| 170 |
1 |
assert !AnnotationsMatcher |
| 171 |
|
.annotationsEqual(new Annotation("A", " ", 'A', 0.01f), |
| 172 |
|
new Annotation("A", null, 'A', 0.01f)); |
| 173 |
|
} |
| 174 |
|
} |