@Test
public void testWorkFlowDocument() throws WorkflowException {
try {
// save
String initiator = "clerk1";
GlobalVariables.setUserSession(new UserSession(initiator));
MatterWork work = getTestUtils().populateMatterWork((MatterWork) KRADServiceLocatorWeb.getDocumentService().getNewDocument(
getDocTypeName() + "Test"));
// bo does not exist until it is saved - initiated docs will not show up on the inquiry
/*MatterWork bo = getBoSvc().findBySinglePrimaryKey(work.getClass(), work.getDocumentHeader());
assertNotNull("for initiated doc, workflow document should not be null", bo.getDocumentHeader().getWorkflowDocument());*/
work = (MatterWork)KRADServiceLocatorWeb.getDocumentService().saveDocument(work);
MatterWork bo = getBoSvc().findBySinglePrimaryKey(work.getClass(), work.getDocumentNumber());
assertNotNull("for saved doc, workflow document should not be null", bo.getDocumentHeader().getWorkflowDocument());
assertEquals("principal name differs", initiator, bo.getDocumentInitiatorNetworkId());
work = (MatterWork) KRADServiceLocatorWeb.getDocumentService().routeDocument(work, "submit", null);
WorkflowDocument workflowDoc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(initiator), work.getDocumentNumber());
assertTrue("work should be enroute", workflowDoc.isEnroute());
String approver = "lawyer1";
GlobalVariables.setUserSession(new UserSession(approver));
work = (MatterWork) KRADServiceLocatorWeb.getDocumentService().approveDocument(work, "approved", null);
//workflowDoc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(initiator), work.getDocumentNumber());
// assertTrue("work should be final", work.getDocumentHeader().getWorkflowDocument().isFinal()); FAIL - is it because the test bo does not have an ojb config entry?
//retrieve again to confirm status