| 1 |
|
package jalview.datamodel; |
| 2 |
|
|
| 3 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
| 4 |
|
import static org.hamcrest.Matchers.equalTo; |
| 5 |
|
import static org.hamcrest.Matchers.is; |
| 6 |
|
import static org.hamcrest.Matchers.nullValue; |
| 7 |
|
|
| 8 |
|
import java.awt.Color; |
| 9 |
|
|
| 10 |
|
import org.testng.annotations.DataProvider; |
| 11 |
|
import org.testng.annotations.Test; |
| 12 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 13 |
|
public class AnnotationTest |
| 14 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 15 |
1 |
@Test(groups = "Functional")... |
| 16 |
|
public void testConstructor_ValueOnly() |
| 17 |
|
{ |
| 18 |
1 |
var annotation = new Annotation(0.5f); |
| 19 |
1 |
assertThat(annotation.displayCharacter, nullValue()); |
| 20 |
1 |
assertThat(annotation.description, nullValue()); |
| 21 |
1 |
assertThat(annotation.secondaryStructure, is(' ')); |
| 22 |
1 |
assertThat(annotation.value, is(0.5f)); |
| 23 |
1 |
assertThat(annotation.colour, is(nullValue())); |
| 24 |
|
} |
| 25 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 26 |
1 |
@Test(groups = "Functional")... |
| 27 |
|
public void testCopyConstructor_NullValue_EmptyAnnotationCreated() |
| 28 |
|
{ |
| 29 |
1 |
var annotation = new Annotation((Annotation) null); |
| 30 |
1 |
assertThat(annotation.displayCharacter, equalTo("")); |
| 31 |
1 |
assertThat(annotation.description, equalTo("")); |
| 32 |
1 |
assertThat(annotation.secondaryStructure, is(' ')); |
| 33 |
1 |
assertThat(annotation.value, is(0.0f)); |
| 34 |
1 |
assertThat(annotation.colour, is(nullValue())); |
| 35 |
|
} |
| 36 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 37 |
1 |
@DataProvider... |
| 38 |
|
public Object[] emptyAnnotations() |
| 39 |
|
{ |
| 40 |
1 |
return new Object[] { |
| 41 |
|
Annotation.EMPTY_ANNOTATION, new Annotation(0.0f), |
| 42 |
|
new Annotation((Annotation) null), |
| 43 |
|
new Annotation(Annotation.EMPTY_ANNOTATION), |
| 44 |
|
new Annotation("", "", ' ', 0.0f), |
| 45 |
|
new Annotation(null, null, ' ', 0.0f), |
| 46 |
|
new Annotation("", "", '\0', 0.0f), new Annotation("", null, ' ', 0.0f), |
| 47 |
|
new Annotation(null, "", ' ', 0.0f), new Annotation(" ", "", ' ', 0.0f), |
| 48 |
|
new Annotation(" .", "", ' ', 0.0f), new Annotation("", " ", ' ', 0.0f), |
| 49 |
|
new Annotation("", "", ' ', 0.0f, null), |
| 50 |
|
new Annotation("", " ", ' ', 0.0f), |
| 51 |
|
new Annotation("", "\n", ' ', 0.0f), }; |
| 52 |
|
} |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 54 |
15 |
@Test(groups = "Functional", dataProvider = "emptyAnnotations")... |
| 55 |
|
public void testIsWhitespace_EmptyAnnotations(Annotation annot) |
| 56 |
|
{ |
| 57 |
15 |
assertThat("Annotation " + annot + " is not whitespace, but should be", |
| 58 |
|
annot.isWhitespace()); |
| 59 |
|
} |
| 60 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
1 |
@DataProvider... |
| 62 |
|
public Object[] nonEmptyAnnotations() |
| 63 |
|
{ |
| 64 |
1 |
return new Object[] { |
| 65 |
|
new Annotation(0.4f), |
| 66 |
|
new Annotation(new Annotation(0.1f)), |
| 67 |
|
new Annotation("A", "", ' ', 0.0f), |
| 68 |
|
new Annotation("", "", ' ', 0.0f, Color.WHITE), |
| 69 |
|
new Annotation(null, null, ' ', -0.1f), |
| 70 |
|
new Annotation(null, null, 'A', 0.0f), |
| 71 |
|
new Annotation(null, "desc", ' ', 0.0f), |
| 72 |
|
new Annotation("0", "<nil>", '\0', 0.0f), |
| 73 |
|
}; |
| 74 |
|
} |
| 75 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 76 |
8 |
@Test(groups = "Functional", dataProvider = "nonEmptyAnnotations")... |
| 77 |
|
public void testIsWhitespace_NonEmptyAnnotation(Annotation annot) |
| 78 |
|
{ |
| 79 |
8 |
assertThat("Annotation " + annot + " is whitespace, but should not be", |
| 80 |
|
!annot.isWhitespace()); |
| 81 |
|
} |
| 82 |
|
} |