View Javadoc

1   package org.kuali.ole.catalog.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  
16  /**
17   * Created with IntelliJ IDEA.
18   * User: ?
19   * Date: 6/11/12
20   * Time: 7:53 PM
21   * To change this template use File | Settings | File Templates.
22   */
23  @ContextConfiguration(locations = {"classpath:/SpringBeans.xml"})
24  @RunWith(value = SpringJUnit4ClassRunner.class)
25  @TransactionConfiguration(defaultRollback = true)
26  public class OleShelvingScheme_UT {
27  
28      private BusinessObjectService boService ;
29  
30      @Test
31      @Transactional
32      public void testSave() {
33          OleShelvingScheme oleShelvingScheme = new OleShelvingScheme();
34          oleShelvingScheme.setShelvingSchemeCode("n1");
35          oleShelvingScheme.setShelvingSchemeName("No information provided");
36          oleShelvingScheme.setSource("Test Source");
37          Timestamp st = new Timestamp(System.currentTimeMillis());
38          oleShelvingScheme.setSourceDate(new java.sql.Date(st.getTime()));
39          oleShelvingScheme.setActive(true);
40          boService = KRADServiceLocator.getBusinessObjectService();
41          boService.save(oleShelvingScheme);
42          OleShelvingScheme oleShelvingSchemeService = boService.findBySinglePrimaryKey(OleShelvingScheme.class,oleShelvingScheme.getShelvingSchemeId());
43          assertEquals("n1",oleShelvingSchemeService.getShelvingSchemeCode());
44          assertEquals("No information provided",oleShelvingSchemeService.getShelvingSchemeName());
45      }
46  
47      @Test
48      @Transactional
49      public void testSearch() {
50          OleShelvingScheme oleShelvingScheme = new OleShelvingScheme();
51          oleShelvingScheme.setShelvingSchemeCode("01");
52          oleShelvingScheme.setShelvingSchemeName("Library of Congress classification ");
53          oleShelvingScheme.setSource("Test Source");
54          Timestamp st = new Timestamp(System.currentTimeMillis());
55          oleShelvingScheme.setSourceDate(new java.sql.Date(st.getTime()));
56          oleShelvingScheme.setActive(true);
57          boService = KRADServiceLocator.getBusinessObjectService();
58          boService.save(oleShelvingScheme);
59          OleShelvingScheme oleShelvingSchemeService = boService.findBySinglePrimaryKey(OleShelvingScheme.class,oleShelvingScheme.getShelvingSchemeId());
60          assertEquals("01",oleShelvingSchemeService.getShelvingSchemeCode());
61          assertEquals("Library of Congress classification ",oleShelvingSchemeService.getShelvingSchemeName());
62      }
63  }