Object[] params = new Object[1];
params[0] = this;
// Get entry from context
Entry entry = entryContext.getEntry();
// Add entry to artifact
this.reportArtifact.addEntry(entry);
// Add entry to report
if (this instanceof EnvelopeValidator)
this.reporter.setCurrentEnvelopeEntry(entry);
else this.reporter.setCurrentEntry(entry);
try
{
// Go through the list of test assertions for the artifact
Iterator iterator = profileArtifact.getTestAssertionList().iterator();
while (iterator.hasNext())
{
// Get next test assertion
testAssertion = (TestAssertion) iterator.next();
// Reset variables
assertionResult = null;
// If the test assertion is enabled, then continue
// if ((testAssertion.isEnabled()) &&
// testAssertion.getEntryTypeName().equals(targetContext.getEntry().getEntryType().getTypeName())) {
if (testAssertion.isEnabled()
&& isPrimaryEntryTypeMatch(testAssertion, entryContext))
{
try
{
// Add 1 to assertion processed count
assertionCount++;
// If the assertion process hasn't been created yet, then create it
if ((assertionProcess =
(AssertionProcess) processList.get(testAssertion.getId()))
== null)
{
// Create a new assertion process
Class assertionClass =
Class.forName(classPrefix + testAssertion.getId());
assertionProcess =
(AssertionProcess) assertionClass.getConstructor(
paramTypes).newInstance(
params);
// Add it to the list
processList.put(testAssertion.getId(), assertionProcess);
}
// Check whether entry is null
if (entry.getEntryDetail() == null)
{
assertionResult =
createAssertionResult(
testAssertion,
AssertionResult.RESULT_MISSING_INPUT,
(String) null);
}
// Check to see if the test assertion should be run
//if (isNotApplicable(testAssertion, entryContext)) {
else if (isNotApplicable(testAssertion))
{
assertionResult =
createAssertionResult(
testAssertion,
AssertionResult.RESULT_NOT_APPLICABLE,
(String) null);
}
else
{
// Processing all the assertion pre-requisites
preReqResults = null;
prereqFailedList = null;
// Get list of pre-reqs for specified assertion
Iterator i = testAssertion.getPrereqIdList().iterator();
while (i.hasNext())
{
if (preReqResults == null)
preReqResults = new TreeMap();
// Get next id
preReqId = (String) i.next();
// Get the prereq result
AssertionResult preReqResult = reporter.getAssertionResult(preReqId);
// Adding a result priority value to preReqResults
preReqResults.put(
resultPriority.get(preReqResult.getResult()),
preReqResult.getResult());
// If the prereq failed, then add it to the list
if (((Integer)resultPriority.get(preReqResult.getResult())).intValue()
> MAX_VALID_PRIORITY)
{
// Adding failed prereq ID to the list
if (prereqFailedList == null)
prereqFailedList = new PrereqFailedListImpl();
prereqFailedList.addTestAssertionID(preReqId);
}
}
if (prereqFailedList != null) {
// Getting the highest pre-requisites' result
Integer maxRes = (Integer)preReqResults.lastKey();
String resString = (String)preReqResults.get(maxRes);
if (resString.equals(AssertionResult.RESULT_FAILED)
||resString.equals(AssertionResult.RESULT_WARNING)) {
resString = AssertionResult.RESULT_PREREQ_FAILED;
}
// Create assertion result based on pre-requisites which are not passed
assertionResult = createAssertionResult(testAssertion, resString, prereqFailedList);
}
// Pre-requisites are passed, validate current assertion
else {
// Reset test assertion
assertionProcess.reset();
// VERBOSE
if (verboseOption)
{
System.err.println(
" Processing "
+ testAssertion.getId()
+ " for entry reference ID ["
+ entry.getReferenceID()
+ "] ...");
startTime = System.currentTimeMillis();
}
// Validate the target