View Javadoc

1   package org.kuali.ole.deliver.circulationdesk.bo;
2   
3   import org.junit.Before;
4   import org.junit.Test;
5   import org.junit.runner.RunWith;
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.util.Collection;
14  
15  import static junit.framework.Assert.assertEquals;
16  
17  /**
18   * Created with IntelliJ IDEA.
19   * User: ?
20   * Date: 11/7/12
21   * Time: 5:32 PM
22   * To change this template use File | Settings | File Templates.
23   */
24  
25  @ContextConfiguration(locations = {"classpath:/SpringBeans.xml"})
26  @RunWith(value = SpringJUnit4ClassRunner.class)
27  @TransactionConfiguration(defaultRollback = true)
28  public class OleCirculationDesk_UT {
29  
30      private BusinessObjectService boService;
31  
32      @Before
33      public void setUp() throws Exception {
34          boService = KRADServiceLocator.getBusinessObjectService();
35  
36      }
37  
38      @Test
39      @Transactional
40      public void testSave() {
41          OleCirculationDesk oleCirculationDesk = new OleCirculationDesk();
42          oleCirculationDesk.setLocationId("11");
43          oleCirculationDesk.setCirculationDeskCode("code");
44          oleCirculationDesk.setCirculationDeskPublicName("publicName");
45          oleCirculationDesk.setCirculationDeskStaffName("staffName");
46          oleCirculationDesk.setOnHoldDays("2");
47          oleCirculationDesk.setActive(true);
48          boService = KRADServiceLocator.getBusinessObjectService();
49          boolean exists = false;
50          Collection<OleCirculationDesk> oleCirculationDeskCollection = boService.findAll(OleCirculationDesk.class);
51          for (OleCirculationDesk circulationDesk : oleCirculationDeskCollection) {
52              if (circulationDesk.getCirculationDeskCode()
53                                 .equalsIgnoreCase(oleCirculationDesk.getCirculationDeskCode())) {
54                  exists = true;
55              }
56          }
57  
58          if (!exists && oleCirculationDesk.getOnHoldDays() != null) {
59              boService.save(oleCirculationDesk);
60              OleCirculationDesk oleCirculationDeskService = boService
61                      .findBySinglePrimaryKey(OleCirculationDesk.class, oleCirculationDesk.getCirculationDeskId());
62              assertEquals("code", oleCirculationDeskService.getCirculationDeskCode());
63              assertEquals("publicName", oleCirculationDeskService.getCirculationDeskPublicName());
64          }
65  
66      }
67  
68      @Test
69      @Transactional
70      public void testSearch() {
71          OleCirculationDesk oleCirculationDesk = new OleCirculationDesk();
72          oleCirculationDesk.setLocationId("11");
73          oleCirculationDesk.setCirculationDeskCode("code");
74          oleCirculationDesk.setCirculationDeskPublicName("publicName");
75          oleCirculationDesk.setCirculationDeskStaffName("staffName");
76          oleCirculationDesk.setOnHoldDays("2");
77          oleCirculationDesk.setActive(true);
78          boService = KRADServiceLocator.getBusinessObjectService();
79          boolean exists = false;
80          Collection<OleCirculationDesk> oleCirculationDeskCollection = boService.findAll(OleCirculationDesk.class);
81          for (OleCirculationDesk circulationDesk : oleCirculationDeskCollection) {
82              if (circulationDesk.getCirculationDeskCode()
83                                 .equalsIgnoreCase(oleCirculationDesk.getCirculationDeskCode())) {
84                  exists = true;
85              }
86          }
87  
88          if (!exists && oleCirculationDesk.getOnHoldDays() != null) {
89              boService.save(oleCirculationDesk);
90              OleCirculationDesk oleCirculationDeskService = boService
91                      .findBySinglePrimaryKey(OleCirculationDesk.class, oleCirculationDesk.getCirculationDeskId());
92              assertEquals("code", oleCirculationDeskService.getCirculationDeskCode());
93              assertEquals("publicName", oleCirculationDeskService.getCirculationDeskPublicName());
94          }
95      }
96  
97  }
98  
99  
100