/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.gui.JvOptionPane;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class AnnotationSorterTest
{
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
private static final int NUM_SEQS = 6;
private static final int NUM_ANNS = 7;
*/
protected AlignmentAnnotation[] buildAnnotations(int numAnns)
{
- List<AlignmentAnnotation> annlist = new ArrayList<AlignmentAnnotation>();
+ List<AlignmentAnnotation> annlist = new ArrayList<>();
for (int i = 0; i < numAnns; i++)
{
AlignmentAnnotation ann = new AlignmentAnnotation(SS + i, "", 0);
* </ul>
*/
@Test(groups = { "Functional" })
- public void testSortBySequenceAndType_autocalcLast()
+ public void testSortBySequenceAndLabel_autocalcLast()
{
// @formatter:off
anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
anns[6].sequenceRef = al.getSequenceAt(3); anns[6].label = "IRP";
// @formatter:on
- AnnotationSorter testee = new AnnotationSorter(al, false);
+ AnnotationSorter testee = new AnnotationSorter(al, false, false);
testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
assertEquals("label5", anns[0].label); // for sequence 0
assertEquals("label0", anns[1].label); // for sequence 1
* Variant with autocalculated annotations sorting to front
*/
@Test(groups = { "Functional" })
- public void testSortBySequenceAndType_autocalcFirst()
+ public void testSortBySequenceAndLabel_autocalcFirst()
{
// @formatter:off
anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
anns[6].sequenceRef = al.getSequenceAt(3); anns[6].label = "IRP";
// @formatter:on
- AnnotationSorter testee = new AnnotationSorter(al, true);
+ AnnotationSorter testee = new AnnotationSorter(al, true, false);
testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
assertEquals("Quality", anns[0].label); // autocalc annotations
assertEquals("Consensus", anns[1].label); // retain ordering
* </ul>
*/
@Test(groups = { "Functional" })
- public void testSortByTypeAndSequence_autocalcLast()
+ public void testSortByLabelAndSequence_autocalcLast()
{
// @formatter:off
anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
anns[6].sequenceRef = al.getSequenceAt(2); anns[6].label = "Structure";
// @formatter:on
- AnnotationSorter testee = new AnnotationSorter(al, false);
+ AnnotationSorter testee = new AnnotationSorter(al, false, false);
testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
assertEquals("IRON", anns[0].label); // IRON / sequence 0
assertEquals("iron", anns[1].label); // iron / sequence 3
* Variant of test with autocalculated annotations sorted to front
*/
@Test(groups = { "Functional" })
- public void testSortByTypeAndSequence_autocalcFirst()
+ public void testSortByLabelAndSequence_autocalcFirst()
{
// @formatter:off
anns[0].sequenceRef = al.getSequenceAt(1); anns[0].label = "label0";
anns[6].sequenceRef = al.getSequenceAt(2); anns[6].label = "Structure";
// @formatter:on
- AnnotationSorter testee = new AnnotationSorter(al, true);
+ AnnotationSorter testee = new AnnotationSorter(al, true, false);
testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
assertEquals("Quality", anns[0].label); // autocalc annotations
assertEquals("Consensus", anns[1].label); // retain ordering
anns[6].sequenceRef = al.getSequenceAt(2); anns[6].label = "Structure";
// @formatter:on
- AnnotationSorter testee = new AnnotationSorter(al, true);
+ AnnotationSorter testee = new AnnotationSorter(al, true, false);
testee.sort(anns, SequenceAnnotationOrder.NONE);
assertEquals("Quality", anns[0].label); // autocalc annotations
assertEquals("Consensus", anns[1].label); // retain ordering
annotations[i].label = "label" + i;
}
long startTime = System.currentTimeMillis();
- AnnotationSorter testee = new AnnotationSorter(alignment, false);
+ AnnotationSorter testee = new AnnotationSorter(alignment, false, false);
testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
long endTime = System.currentTimeMillis();
final long elapsed = endTime - startTime;
annotations[i].label = "label" + i;
}
long startTime = System.currentTimeMillis();
- AnnotationSorter testee = new AnnotationSorter(alignment, false);
+ AnnotationSorter testee = new AnnotationSorter(alignment, false, false);
testee.sort(annotations, SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
long endTime = System.currentTimeMillis();
final long elapsed = endTime - startTime;
annotations[i].label = labels[r.nextInt(labels.length)];
}
long startTime = System.currentTimeMillis();
- AnnotationSorter testee = new AnnotationSorter(alignment, false);
+ AnnotationSorter testee = new AnnotationSorter(alignment, false, false);
testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
long endTime = System.currentTimeMillis();
long elapsed = endTime - startTime;