nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);
nonExecutableRequest = new DummyApprovalRequest(reqadmin,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);
	public void testApprove() throws Exception {		DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);		pub.addApprovalRequest(admin1, nonExecutableRequest);				Approval approval1 = new Approval("ap1test");		pub.approve(admin1, nonExecutableRequest.generateApprovalId(), approval1);				Collection result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());		assertTrue(result.size() == 1);							ApprovalDataVO next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_WAITINGFORAPPROVAL);		assertTrue(next.getRemainingApprovals() == 1);				Approval approvalAgain = new Approval("apAgaintest");		try{		  pub.approve(admin1, nonExecutableRequest.generateApprovalId(), approvalAgain);		  fail("The same admin shouln'tt be able to approve a request twice");		}catch(AdminAlreadyApprovedRequestException e){}				Approval approval2 = new Approval("ap2test");		pub.approve(admin2, nonExecutableRequest.generateApprovalId(), approval2);				result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());		assertTrue(result.size() == 1);					next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_APPROVED);		assertTrue(next.getRemainingApprovals() == 0);				// 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);				pub.removeApprovalRequest(admin1, next.getId());						// Test using an executable Dummy, different behaviour		DummyApprovalRequest executableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,true);		pub.addApprovalRequest(admin1, executableRequest);												pub.approve(admin1, nonExecutableRequest.generateApprovalId(), approval1);		pub.approve(admin2, nonExecutableRequest.generateApprovalId(), approval2);				result = pub.findApprovalDataVO(admin1, executableRequest.generateApprovalId());		assertTrue(result.size() == 1);			next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_EXECUTED);				// Make sure that the approval still have status executed after exiration		Thread.sleep(5000);		result = pub.findApprovalDataVO(admin1, executableRequest.generateApprovalId());		assertTrue(result.size() == 1);						next = (ApprovalDataVO) result.iterator().next();		assertTrue("Status = " + next.getStatus(), next.getStatus() == ApprovalDataVO.STATUS_EXECUTED);						pub.removeApprovalRequest(admin1, next.getId());				// Test to request and to approve with the same admin		nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);		pub.addApprovalRequest(admin1, nonExecutableRequest);		Approval approvalUsingReqAdmin = new Approval("approvalUsingReqAdmin");		try{		  pub.approve(reqadmin, nonExecutableRequest.generateApprovalId(), approvalUsingReqAdmin);		  fail("Request admin shouln't be able to approve their own request");		}catch(AdminAlreadyApprovedRequestException e){}		result = pub.findApprovalDataVO(admin1, executableRequest.generateApprovalId());		assertTrue(result.size() == 1);			next = (ApprovalDataVO) result.iterator().next();				pub.removeApprovalRequest(admin1, next.getId());					}