long startTime = 0;
HashMap processList = new HashMap();
TestAssertion testAssertion = null;
AssertionProcess assertionProcess;
AssertionResult assertionResult;
TreeMap preReqResults;
PrereqFailedList prereqFailedList;
String preReqId;
Class[] paramTypes = new Class[1];
// If this is an instance of MessageValidator or EnvelopeValidator
// then use BaseMessageValidator as a param type of assertions constructor
paramTypes[0] = this instanceof BaseMessageValidator ?
BaseMessageValidator.class : this.getClass();
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();