DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);
DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmin,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);
	public void testAddApprovalRequest() throws Exception {						DummyApprovalRequest nonExecutableRequest = new DummyApprovalRequest(reqadmincert,null,caid,SecConst.EMPTY_ENDENTITYPROFILE,false);		        //		 Test that the approvalrequest doesn't exists.		Collection result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());		assertTrue(result.size() == 0);						pub.addApprovalRequest(admin1, nonExecutableRequest);						// Test that the approvalRequest exists now		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.getCAId() == caid);		assertTrue(next.getEndEntityProfileiId() == SecConst.EMPTY_ENDENTITYPROFILE);		assertTrue(next.getReqadmincertissuerdn().equals(CertTools.getIssuerDN(reqadmincert)));		assertTrue(next.getReqadmincertsn().equals(reqadmincert.getSerialNumber().toString(16)));		assertTrue(next.getApprovalId() == nonExecutableRequest.generateApprovalId());		assertTrue(next.getApprovalType() == nonExecutableRequest.getApprovalType());		assertTrue(next.getApprovals().size() == 0);		assertTrue(!next.getApprovalRequest().isExecutable());		assertTrue(next.getRemainingApprovals() == 2);				// Test that the request 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 to add the same action twice		pub.addApprovalRequest(admin1, nonExecutableRequest);		try{		  pub.addApprovalRequest(admin1, nonExecutableRequest);		  fail("It shouldn't be possible to add two identical requests.");		}catch(ApprovalException e){}  				// Then after one of them have expired		Thread.sleep(5000);		result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());		ApprovalDataVO expired = (ApprovalDataVO) result.iterator().next();				pub.addApprovalRequest(admin1, nonExecutableRequest);				pub.removeApprovalRequest(admin1, expired.getId());				result = pub.findApprovalDataVO(admin1, nonExecutableRequest.generateApprovalId());		next = (ApprovalDataVO) result.iterator().next();				pub.removeApprovalRequest(admin1, next.getId());	}