1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.travel.krad.test;
18
19 import edu.sampleu.travel.bo.TravelAccount;
20 import edu.sampleu.travel.bo.TravelAccountExtension;
21 import edu.sampleu.travel.bo.TravelAccountType;
22 import org.junit.Assert;
23 import org.junit.Test;
24 import org.kuali.rice.core.api.util.type.KualiPercent;
25 import org.kuali.rice.kew.api.exception.WorkflowException;
26 import org.kuali.rice.krad.exception.ValidationException;
27 import org.kuali.rice.krad.service.BusinessObjectService;
28 import org.kuali.rice.krad.service.KRADServiceLocator;
29 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
30 import org.kuali.rice.location.impl.campus.CampusTypeBo;
31 import org.kuali.rice.test.BaselineTestCase;
32 import org.kuali.test.BaseMaintenanceDocumentTest;
33
34
35
36
37
38 import java.util.HashMap;
39
40 import static junit.framework.Assert.assertNotNull;
41
42
43
44
45
46 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
47 public class TravelAccountMaintenanceDocumentTest extends BaseMaintenanceDocumentTest {
48 private BusinessObjectService businessObjectService;
49 String travAcctNumber = "8097";
50
51 @Override
52 public void setUp() throws Exception {
53 super.setUp();
54 businessObjectService = KRADServiceLocator.getBusinessObjectService();
55
56 }
57
58 @Override
59 protected Object getNewMaintainableObject() {
60
61 TravelAccount ac = new TravelAccount();
62 ac.setName("unit-test-acc");
63 ac.setSubsidizedPercent(new KualiPercent(0.02));
64 ac.setNumber(travAcctNumber);
65
66
67 TravelAccountExtension travExtension = new TravelAccountExtension();
68
69 HashMap<String, String> primaryKeys = new HashMap<String, String>(1);
70 primaryKeys.put("accountTypeCode", "EAT");
71 TravelAccountType expAcctType = businessObjectService.findByPrimaryKey(TravelAccountType.class, primaryKeys);
72 travExtension.setAccountType(expAcctType);
73 travExtension.setNumber(travAcctNumber);
74
75 ac.setExtension(travExtension);
76
77
78 return ac;
79 }
80
81 @Override
82 protected String getDocumentTypeName() {
83 return "TravelAccountMaintenanceDocument";
84 }
85
86 @Override
87 protected String getInitiatorPrincipalName() {
88 return "admin";
89 }
90
91 @Override
92 protected Object getOldMaintainableObject() {
93 return getNewMaintainableObject();
94 }
95
96 @Test
97
98
99
100 public void testRouteNewDoc() throws WorkflowException {
101 setupNewAccountMaintDoc(getDocument());
102 KRADServiceLocatorWeb.getDocumentService().routeDocument(getDocument(), "submit", null);
103 Assert.assertTrue(getDocument().getDocumentHeader().getWorkflowDocument().isFinal());
104
105 HashMap<String, String> primaryKeys = new HashMap<String, String>(1);
106 primaryKeys.put("number", travAcctNumber);
107 TravelAccount travAcct = businessObjectService.findByPrimaryKey(TravelAccount.class, primaryKeys);
108 assertNotNull(travAcct);
109 }
110 }