public void testCompensateAgent() throws Exception{
int agentSsn = 11;
int customerSsn = 10;
// create policy
InsurencePolicyDTO samplePolicy = null;
InvitationDTO invitation = new InvitationDTO();
invitation.setAgent(new UserDTO(agentSsn));
invitation.setCustomer(new UserDTO(customerSsn));
// send invitation
service.sendInvitation(invitation, samplePolicy);
// make sure the agent was not compensate before
// so the test can actually work
List<Integer> pays;
pays = payTable.getByUser(agentSsn);
assertEquals(0, pays.size());
// purchase policy
InsurencePolicyDTO policy = new InsurencePolicyDTO();
policy.setUserSSN(10);
policy.setPropertyName("My Property");
policy.setPropertyValue(1000);
policy.setDeductibles(100);
int quote = service.calculateQuoteForPolicy(policy);
policy.setQuote(quote);
service.purchasePolicy(policy);
// wait a bit for asynchronous methods to execute.
Thread.sleep(1000);