1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.travel.dataobject;
17
18 import org.junit.Test;
19 import org.kuali.rice.krad.service.KRADServiceLocator;
20 import org.kuali.rice.krad.test.KRADTestCase;
21 import org.kuali.rice.test.BaselineTestCase;
22
23 import java.math.BigDecimal;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28
29
30
31
32
33
34 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB)
35 public class TravelMileageRateTest extends KRADTestCase {
36
37 private static final String MILEAGE_RATE_CODE = "IL";
38 private static final String MILEAGE_RATE_NAME = "International";
39 private static final BigDecimal MILEAGE_RATE = new BigDecimal("50");
40
41
42
43
44 @Test
45 public void testTravelMileageRate() {
46 assertTrue(TravelMileageRate.class.getName() + " is not mapped in JPA",
47 KRADServiceLocator.getDataObjectService().supports(TravelMileageRate.class));
48
49 String id = createTravelMileageRate();
50
51 TravelMileageRate travelMileageRate = KRADServiceLocator.getDataObjectService().find(TravelMileageRate.class, id);
52 assertNotNull("Travel Mileage Rate ID is null", travelMileageRate.getMileageRateId());
53 assertEquals("Travel Mileage Rate code is incorrect", MILEAGE_RATE_CODE, travelMileageRate.getMileageRateCd());
54 assertEquals("Travel Mileage Rate name is incorrect", MILEAGE_RATE_NAME, travelMileageRate.getMileageRateName());
55 assertEquals("Travel Mileage Rate amount is incorrect", MILEAGE_RATE, travelMileageRate.getMileageRate());
56 assertTrue("Travel Mileage Rate is not active", travelMileageRate.isActive());
57 }
58
59 private String createTravelMileageRate() {
60 TravelMileageRate travelMileageRate = new TravelMileageRate();
61 travelMileageRate.setMileageRateCd(MILEAGE_RATE_CODE);
62 travelMileageRate.setMileageRateName(MILEAGE_RATE_NAME);
63 travelMileageRate.setMileageRate(MILEAGE_RATE);
64 travelMileageRate.setActive(true);
65
66 return KRADServiceLocator.getDataObjectService().save(travelMileageRate).getMileageRateId();
67 }
68 }