DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);
DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmin,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);
	public void testReject() throws Exception {		DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);		pub.addApprovalRequest(reqadmin, nonExecutableRequest);				Approval approval1 = new Approval("ap1test");		pub.approve(admin1, nonExecutableRequest.generateApprovalId(), approval1);				Collection result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());					ApprovalDataVO next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_WAITINGFORAPPROVAL);		assertTrue(next.getRemainingApprovals() == 1);				Approval rejection = new Approval("rejectiontest");		pub.reject(admin2, nonExecutableRequest.generateApprovalId(), rejection);		result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());					next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_REJECTED);		assertTrue(next.getRemainingApprovals() == 0);				pub.removeApprovalRequest(admin1, next.getId());				nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);		pub.addApprovalRequest(reqadmin, nonExecutableRequest);						rejection = new Approval("rejectiontest2");		pub.reject(admin1, nonExecutableRequest.generateApprovalId(), rejection);		result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());					next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_REJECTED);		assertTrue(next.getRemainingApprovals() == 0);				// Try to approve a rejected request		try{		  pub.approve(admin2, nonExecutableRequest.generateApprovalId(), approval1);		  fail("It shouldn't be possible to approve a rejected request");		}catch(ApprovalException e){}				// Test that the approval exipres as it should		Thread.sleep(5000);		result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());		assertTrue(result.size() == 1);						next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_EXPIRED);				// Try to reject an expired request		try{		  pub.reject(admin2, nonExecutableRequest.generateApprovalId(), rejection);		  fail("It shouln't be possible to reject and expired request");		}catch(ApprovalException e){}						pub.removeApprovalRequest(admin1, next.getId());	}