View Javadoc

1   package org.kuali.ole.select.bo;
2   
3   import org.junit.Test;
4   import org.junit.runner.RunWith;
5   import org.kuali.rice.krad.service.BusinessObjectService;
6   import org.kuali.rice.krad.service.KRADServiceLocator;
7   import org.springframework.test.context.ContextConfiguration;
8   import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9   import org.springframework.test.context.transaction.TransactionConfiguration;
10  import org.springframework.transaction.annotation.Transactional;
11  
12  import java.sql.Timestamp;
13  
14  import static junit.framework.Assert.assertEquals;
15  import static junit.framework.Assert.assertNotNull;
16  import static junit.framework.Assert.assertNull;
17  
18  /**
19   * Created by IntelliJ IDEA.
20   * User: JuliyaMonica.S
21   * Date: 30/10/12
22   * Time: 6:05 PM
23   * To change this template use File | Settings | File Templates.
24   */
25  
26  @ContextConfiguration(locations = {"classpath:/SpringBeans.xml"})
27  @RunWith(value = SpringJUnit4ClassRunner.class)
28  @TransactionConfiguration(defaultRollback = true)
29  
30  public class OleBibProtectedField_UT {
31  
32      private BusinessObjectService boService ;
33      @Test
34      @Transactional
35      public void testSave() {
36          OleBibProtectedField oleBibProtectedField = new OleBibProtectedField();
37          oleBibProtectedField.setTag("Mock Tag");
38          oleBibProtectedField.setSubField("Mock SubField");
39          oleBibProtectedField.setFirstIndicator("Mock First Indicator");
40          oleBibProtectedField.setSecondIndicator("Mock Second Indicator");
41          oleBibProtectedField.setModifyFlag(true);
42          oleBibProtectedField.setActiveIndicator(true);
43          boService = KRADServiceLocator.getBusinessObjectService();
44          OleBibProtectedField savedBibProtectedField = boService.save(oleBibProtectedField);
45          assertNotNull(savedBibProtectedField);
46          assertNotNull(savedBibProtectedField.getOleBibProtectedFieldId());
47      }
48  
49      @Test
50      @Transactional
51      public void testSearch(){
52          OleBibProtectedField oleBibProtectedField = new OleBibProtectedField();
53          oleBibProtectedField.setTag("Mock Tag");
54          oleBibProtectedField.setSubField("Mock SubField");
55          oleBibProtectedField.setFirstIndicator("Mock First Indicator");
56          oleBibProtectedField.setSecondIndicator("Mock Second Indicator");
57          oleBibProtectedField.setModifyFlag(true);
58          oleBibProtectedField.setActiveIndicator(true);
59          boService = KRADServiceLocator.getBusinessObjectService();
60          OleBibProtectedField savedBibProtectedField = boService.save(oleBibProtectedField);
61          assertNotNull(savedBibProtectedField);
62          OleBibProtectedField bibProtectedField = boService.findBySinglePrimaryKey(OleBibProtectedField.class,
63                  savedBibProtectedField.getOleBibProtectedFieldId());
64  
65          assertEquals("Mock Tag",bibProtectedField.getTag());
66          assertEquals(true,bibProtectedField.isModifyFlag());
67      }
68  
69      @Test
70      @Transactional
71      public void testDelete(){
72          OleBibProtectedField oleBibProtectedField = new OleBibProtectedField();
73          oleBibProtectedField.setTag("Mock Tag");
74          oleBibProtectedField.setSubField("Mock SubField");
75          oleBibProtectedField.setFirstIndicator("Mock First Indicator");
76          oleBibProtectedField.setSecondIndicator("Mock Second Indicator");
77          oleBibProtectedField.setModifyFlag(true);
78          oleBibProtectedField.setActiveIndicator(true);
79          boService = KRADServiceLocator.getBusinessObjectService();
80          OleBibProtectedField savedBibProtectedField = boService.save(oleBibProtectedField);
81          assertNotNull(savedBibProtectedField);
82          OleBibProtectedField bibProtectedField = boService.findBySinglePrimaryKey(OleBibProtectedField.class,
83                  savedBibProtectedField.getOleBibProtectedFieldId());
84          assertNotNull(bibProtectedField);
85          boService.delete(savedBibProtectedField);
86          OleBibProtectedField deletedBibProtectedField = boService.findBySinglePrimaryKey(OleBibProtectedField.class,
87                  savedBibProtectedField.getOleBibProtectedFieldId());
88          assertNull(deletedBibProtectedField);
89  
90      }
91  
92  }