1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.travel.dataobject;
17
18 import edu.sampleu.travel.options.PostalCountryCode;
19 import edu.sampleu.travel.options.PostalStateCode;
20 import edu.sampleu.travel.options.TripType;
21 import org.junit.Test;
22 import org.kuali.rice.krad.service.KRADServiceLocator;
23 import org.kuali.rice.krad.test.KRADTestCase;
24 import org.kuali.rice.test.BaselineTestCase;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
29
30
31
32
33
34
35 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.ROLLBACK_CLEAR_DB)
36 public class TravelDestinationTest extends KRADTestCase {
37
38 private static final String DESTINATION_NAME = PostalStateCode.PR.getLabel();
39 private static final String COUNTRY_CODE = PostalCountryCode.US.getCode();
40 private static final String STATE_CODE = PostalStateCode.PR.getCode();
41
42
43
44
45 @Test
46 public void testTravelDestination() {
47 assertTrue(TravelDestination.class.getName() + " is not mapped in JPA",
48 KRADServiceLocator.getDataObjectService().supports(TravelDestination.class));
49
50 String id = createTravelDestination();
51
52 TravelDestination travelDestination = KRADServiceLocator.getDataObjectService().find(TravelDestination.class, id);
53 assertNotNull("Travel Destination ID is null", travelDestination.getTravelDestinationId());
54 assertEquals("Travel Destination name is incorrect", DESTINATION_NAME, travelDestination.getTravelDestinationName());
55 assertEquals("Travel Destination country is incorrect", COUNTRY_CODE, travelDestination.getCountryCd());
56 assertEquals("Travel Destination state is incorrect", STATE_CODE, travelDestination.getStateCd());
57 assertTrue("Travel Destination is not active", travelDestination.isActive());
58 }
59
60 private String createTravelDestination() {
61 TravelDestination travelDestination = new TravelDestination();
62 travelDestination.setTravelDestinationName(DESTINATION_NAME);
63 travelDestination.setCountryCd(COUNTRY_CODE);
64 travelDestination.setStateCd(STATE_CODE);
65 travelDestination.setActive(true);
66
67 return KRADServiceLocator.getDataObjectService().save(travelDestination).getTravelDestinationId();
68 }
69 }