View Javadoc

1   package org.kuali.ole.deliver.bo;
2   
3   import org.junit.Test;
4   import org.junit.runner.RunWith;
5   import org.kuali.ole.SpringBaseTestCase;
6   import org.kuali.rice.krad.service.BusinessObjectService;
7   import org.kuali.rice.krad.service.KRADServiceLocator;
8   import org.springframework.test.context.ContextConfiguration;
9   import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10  import org.springframework.test.context.transaction.TransactionConfiguration;
11  import org.springframework.transaction.annotation.Transactional;
12  
13  import java.math.BigDecimal;
14  import java.util.Date;
15  import java.util.HashMap;
16  import java.util.List;
17  import java.util.Map;
18  
19  import static junit.framework.Assert.assertEquals;
20  
21  /**
22   * Created with IntelliJ IDEA.
23   * User: ?
24   * Date: 11/6/12
25   * Time: 11:34 AM
26   * To change this template use File | Settings | File Templates.
27   */
28  
29  public class PatronBillPayment_UT extends SpringBaseTestCase {
30  
31      private BusinessObjectService boService ;
32  
33      /**
34       *  Gets the businessObjectService attribute.
35       * @return  Returns the businessObjectService
36       */
37      private BusinessObjectService getBusinessObjectService() {
38          if (null == boService) {
39              boService = KRADServiceLocator.getBusinessObjectService();
40          }
41          return boService;
42      }
43      @Test
44      @Transactional
45      public void testSaveAndSearch() {
46          PatronBillPayment patronBillPayment = new PatronBillPayment();
47          FeeType feeType = new FeeType();
48          patronBillPayment.setBillDate(new java.sql.Date(new Date().getTime()));
49          patronBillPayment.setBillNumber("9999");
50          patronBillPayment.setPatronId("Mock PatronId");
51         /* patronBillPayment.setFirstName("Mock FirstName");
52          patronBillPayment.setLastName("Mock LastName");*/
53          patronBillPayment.setOperatorId("Mock OperatorId");
54          patronBillPayment.setMachineId("Mock MachineId");
55          feeType.setFeeType("Mock Fine");
56          feeType.setBillNumber("9999");
57          feeType.setFeeAmount(new BigDecimal(100.00));
58          patronBillPayment.setTotalAmount(new BigDecimal(100.00));
59          //OlePaymentStatus olePaymentStatus = getPaymentStatus();
60          OlePaymentStatus olePaymentStatus = new OlePaymentStatus();
61          olePaymentStatus.setPaymentStatusId("1");
62          feeType.setPaymentStatusCode("1");
63          feeType.setPaymentStatus("1");
64          feeType.setOlePaymentStatus(olePaymentStatus);
65  /*        if(olePaymentStatus!=null){
66              patronBillPayment.setOlePaymentStatus(olePaymentStatus);
67              patronBillPayment.setPaymentStatus(olePaymentStatus.getPaymentStatusId());
68          }*/
69          boService = KRADServiceLocator.getBusinessObjectService();
70          boService.save(patronBillPayment);
71          boService.save(feeType);
72          PatronBillPayment patronBillPaymentService = boService.findBySinglePrimaryKey(PatronBillPayment.class,patronBillPayment.getBillNumber());
73          assertEquals("Mock PatronId",patronBillPaymentService.getPatronId());
74         // assertEquals("Mock LastName",patronBillPaymentService.getLastName());
75      }
76      private OlePaymentStatus getPaymentStatus(){
77          Map statusMap = new HashMap();
78          statusMap.put("paymentStatusName", "Outstanding");
79          List<OlePaymentStatus> olePaymentStatusList = (List<OlePaymentStatus>)getBusinessObjectService().findMatching(OlePaymentStatus.class,statusMap);
80          return olePaymentStatusList!=null && olePaymentStatusList.size()>0 ? olePaymentStatusList.get(0): null;
81      }
82    }