}
protected void valid(COSDictionary action, boolean valid, String expectedCode) throws Exception
{
ActionManagerFactory fact = new ActionManagerFactory();
PreflightContext ctx = createContext();
COSDictionary dict = new COSDictionary();
dict.setItem(COSName.A, action);
// process the action validation
List<AbstractActionManager> actions = fact.getActionManagers(ctx, dict);
for (AbstractActionManager abstractActionManager : actions)
{
abstractActionManager.valid();
}
// check the result
if (!valid)
{
List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
assertFalse(errors.isEmpty());
if (expectedCode != null || !"".equals(expectedCode))
{
boolean found = false;
for (ValidationError err : errors)
{
if (err.getErrorCode().equals(expectedCode))
{
found = true;
break;
}
}
assertTrue(found);
}
}
else
{
if (ctx.getDocument().getResult() != null)
{
List<ValidationError> errors = ctx.getDocument().getResult().getErrorsList();
assertTrue(errors.isEmpty());
}
}
}