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
18
19
20
21
22
23
24 @ContextConfiguration(locations = {"classpath:/SpringBeans.xml"})
25 @RunWith(value = SpringJUnit4ClassRunner.class)
26 @TransactionConfiguration(defaultRollback = true)
27
28 public class OleAccessMethod_UT {
29
30 private BusinessObjectService boService ;
31 @Test
32 @Transactional
33 public void testSave() {
34 OleAccessMethod oleAccessMethod = new OleAccessMethod();
35 oleAccessMethod.setAccessMethodCode("mockCd0");
36 oleAccessMethod.setAccessMethodName("mockAccessMethodName0");
37 oleAccessMethod.setSource("mockSource0");
38 Timestamp st = new Timestamp(System.currentTimeMillis());
39 oleAccessMethod.setSourceDate(new java.sql.Date(st.getTime()));
40 oleAccessMethod.setActive(true);
41 boService = KRADServiceLocator.getBusinessObjectService();
42 boService.save(oleAccessMethod);
43 OleAccessMethod oleAccessMethodService = boService.findBySinglePrimaryKey(OleAccessMethod.class,oleAccessMethod.getAccessMethodId());
44 assertEquals("mockCd0",oleAccessMethodService.getAccessMethodCode());
45 assertEquals("mockAccessMethodName0",oleAccessMethodService.getAccessMethodName());
46 }
47
48 @Test
49 @Transactional
50 public void testSearch(){
51 OleAccessMethod oleAccessMethod = new OleAccessMethod();
52 oleAccessMethod.setAccessMethodCode("mockCd3");
53 oleAccessMethod.setAccessMethodName("mockAccessMethodName3");
54 oleAccessMethod.setSource("mockSource3");
55 Timestamp st = new Timestamp(System.currentTimeMillis());
56 oleAccessMethod.setSourceDate(new java.sql.Date(st.getTime()));
57 oleAccessMethod.setActive(true);
58 boService = KRADServiceLocator.getBusinessObjectService();
59 boService.save(oleAccessMethod);
60 OleAccessMethod oleAccessMethodService = boService.findBySinglePrimaryKey(OleAccessMethod.class,oleAccessMethod.getAccessMethodId());
61 assertEquals("mockCd3",oleAccessMethodService.getAccessMethodCode());
62 assertEquals("mockAccessMethodName3",oleAccessMethodService.getAccessMethodName());
63 }
64 }