}
/**
+ * assert wrapper: tests all references in the given alignment are consistent
+ *
+ * @param alignment
+ */
+ public static void assertAlignmentDatasetRefs(AlignmentI alignment)
+ {
+ verifyAlignmentDatasetRefs(alignment, true, null);
+ }
+
+ /**
+ * assert wrapper: tests all references in the given alignment are consistent
+ *
+ * @param alignment
+ * @param message
+ * - prefixed to any assert failed messages
+ */
+ public static void assertAlignmentDatasetRefs(AlignmentI alignment,
+ String message)
+ {
+ verifyAlignmentDatasetRefs(alignment, true, message);
+ }
+
+ /**
* verify sequence and dataset references are properly contained within
* dataset
*
* - the alignmentI object to verify (either alignment or dataset)
* @param raiseAssert
* - when set, testng assertions are raised.
+ * @param message
+ * - null or a string message to prepend to the assert failed messages.
* @return true if alignment references were in order, otherwise false.
*/
public static boolean verifyAlignmentDatasetRefs(AlignmentI alignment,
- boolean raiseAssert)
+ boolean raiseAssert, String message)
{
+ if (message==null) { message = ""; }
if (alignment == null)
{
if (raiseAssert)
{
- Assert.fail("Alignment for verification was null.");
+ Assert.fail(message+"Alignment for verification was null.");
}
return false;
}
{
if (raiseAssert)
{
- Assert.fail("Alignment contained a sequence who's dataset sequence has a second dataset reference.");
+ Assert.fail(message+" Alignment contained a sequence who's dataset sequence has a second dataset reference.");
}
return false;
}
{
if (raiseAssert)
{
- Assert.fail("Alignment contained a sequence who's dataset sequence was not in the dataset.");
+ Assert.fail(message+" Alignment contained a sequence who's dataset sequence was not in the dataset.");
}
return false;
}
}
- return verifyAlignmentDatasetRefs(alignment.getDataset(), raiseAssert);
+ return verifyAlignmentDatasetRefs(alignment.getDataset(), raiseAssert, message);
}
else
{
{
if (raiseAssert)
{
- Assert.fail("Dataset contained a sequence with non-null dataset reference (ie not a dataset sequence!)");
+ Assert.fail(message+" Dataset contained a sequence with non-null dataset reference (ie not a dataset sequence!)");
}
return false;
}
{
if (raiseAssert)
{
- Assert.fail("DBRefEntry for sequence in alignment had map to sequence which was not a dataset sequence");
+ Assert.fail(message+" DBRefEntry for sequence in alignment had map to sequence which was not a dataset sequence");
}
return false;
{
if (raiseAssert)
{
- Assert.fail("DBRefEntry for sequence in alignment had map to sequence not in dataset");
+ Assert.fail(message+" DBRefEntry for sequence in alignment had map to sequence not in dataset");
}
return false;
}
{
if (raiseAssert)
{
- Assert.fail("CodonFrame-SSM-FromSeq is not a dataset sequence");
+ Assert.fail(message+" CodonFrame-SSM-FromSeq is not a dataset sequence");
}
return false;
}
if (raiseAssert)
{
- Assert.fail("CodonFrame-SSM-FromSeq is not contained in dataset");
+ Assert.fail(message+" CodonFrame-SSM-FromSeq is not contained in dataset");
}
return false;
}
{
if (raiseAssert)
{
- Assert.fail("CodonFrame-SSM-Mapping-ToSeq is not a dataset sequence");
+ Assert.fail(message+" CodonFrame-SSM-Mapping-ToSeq is not a dataset sequence");
}
return false;
}
if (raiseAssert)
{
- Assert.fail("CodonFrame-SSM-Mapping-ToSeq is not contained in dataset");
+ Assert.fail(message+" CodonFrame-SSM-Mapping-ToSeq is not contained in dataset");
}
return false;
}
try
{
- Assert.assertTrue(verifyAlignmentDatasetRefs(al, true),
+ Assert.assertTrue(verifyAlignmentDatasetRefs(al, true, null),
"Valid test alignment failed when raiseAsserts enabled:"
+ msg);
} catch (AssertionError ae)
+ msg, ae);
}
// also check validation passes with asserts disabled
- Assert.assertTrue(verifyAlignmentDatasetRefs(al, false),
+ Assert.assertTrue(verifyAlignmentDatasetRefs(al, false, null),
"Valid test alignment failed when raiseAsserts disabled:"
+ msg);
}
{
try
{
- Assert.assertFalse(verifyAlignmentDatasetRefs(al, true));
+ Assert.assertFalse(verifyAlignmentDatasetRefs(al, true, null));
Assert.fail("Invalid test alignment passed but no assertion raised when raiseAsserts enabled:"
+ msg);
} catch (AssertionError ae)
// expected behaviour
}
// also check validation passes with asserts disabled
- Assert.assertFalse(verifyAlignmentDatasetRefs(al, false),
+ Assert.assertFalse(verifyAlignmentDatasetRefs(al, false, null),
"Invalid test alignment passed when raiseAsserts disabled:"
+ msg);
}
assertTrue("Didn't retrieve " + first, af != null);
// verify references for retrieved data
- AlignmentTest.verifyAlignmentDatasetRefs(af.getViewport()
- .getAlignment(), true);
+ AlignmentTest.assertAlignmentDatasetRefs(af.getViewport()
+ .getAlignment(), "Pass (" + pass1 + "," + pass2 + ","
+ + pass3 + "): Fetch " + first + ":");
// store project to recover on next pass
stringify(dbtoviewBit, savedProjects, first, af.alignPanel);
.get(first).toString(), FormatAdapter.FILE);
// verify references for recovered data
- AlignmentTest.verifyAlignmentDatasetRefs(af.getViewport()
- .getAlignment(), true);
+ AlignmentTest.assertAlignmentDatasetRefs(af.getViewport()
+ .getAlignment(), "Pass (" + pass1 + "," + pass2 + ","
+ + pass3 + "): Recover " + first + ":");
}
}
for (AlignmentViewPanel avp : cra_views)
{
+ nextxref = first + " -> " + db + "{" + p++ + "}";
+
// verify references for this panel
- AlignmentTest.verifyAlignmentDatasetRefs(avp.getAlignment(),
- true);
+ AlignmentTest.assertAlignmentDatasetRefs(avp.getAlignment(),
+ "" + "Pass (" + pass1 + "," + pass2 + "): For "
+ + nextxref + ":");
SequenceI[] xrseqs = avp.getAlignment().getSequencesArray();
- nextxref = first + " -> " + db + "{" + p++ + "}";
viewsourcedb.put(avp, nextxref);
stringify(dbtoviewBit, savedProjects, nextxref, avp);
+ xrefdb + "{" + q++ + "}";
// verify references for this panel
- AlignmentTest.verifyAlignmentDatasetRefs(
- nextavp.getAlignment(), true);
+ AlignmentTest.assertAlignmentDatasetRefs(
+ nextavp.getAlignment(), "" + "Pass (" + pass1
+ + "," + pass2 + "): For "
+ + nextnextxref + ":");
viewsourcedb.put(nextavp, nextnextxref);
stringify(dbtoviewBit, savedProjects, nextnextxref,