1 package org.kuali.ole.loaders.describe;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.apache.log4j.Logger;
5 import org.junit.Assert;
6 import org.junit.Test;
7 import org.kuali.ole.loaders.common.FileUtils;
8 import org.kuali.ole.loaders.common.RestClient;
9 import org.kuali.ole.loaders.common.service.OLELoaderRestClient;
10
11 import java.util.Map;
12
13
14
15
16
17 public class OLELocationTest{
18
19 private static final Logger LOG = Logger.getLogger(OLELocationTest.class);
20 private RestClient restClient = new RestClient();
21 public String BASE_URL = "http://192.168.55.223:8080/olefs/api/";
22
23
24
25 @Test
26 public void getLocation() throws Exception {
27 LOG.info("Sending request to OLE Rest service to fetch location");
28 Map<String,Object> responseMap = OLELoaderRestClient.jerseryClientGet(BASE_URL + "location/967");
29 System.out.println("Response Status : \n" + responseMap.get("status"));
30 System.out.println("Response Body : \n" + responseMap.get("content"));
31 }
32
33 @Test
34 public void importLocation() throws Exception {
35 String locationInfo = FileUtils.readFileContent("org/kuali/ole/loaders/describe/importLocation.json");
36 Map<String,Object> responseMap = OLELoaderRestClient.jerseryClientPost(BASE_URL + "/location", locationInfo);
37 System.out.println("Response Status : \n" + responseMap.get("status"));
38 Map headerMap = (Map) responseMap.get("header");
39 System.out.println("Response Rejected Items : \n" + headerMap.get("X-OLE-Rejected"));
40 Assert.assertTrue(StringUtils.isNotBlank((String)responseMap.get("content")));
41 LOG.info((String)responseMap.get("content"));
42 }
43
44 @Test
45 public void updateLocation() throws Exception {
46 String locationInfo = FileUtils.readFileContent("org/kuali/ole/loaders/describe/updateLocation.json");
47 Map<String,Object> responseMap = OLELoaderRestClient.jerseryClientPut(BASE_URL + "/location/921", locationInfo);
48 System.out.println("Response Status : \n" + responseMap.get("status"));
49 Assert.assertTrue(StringUtils.isNotBlank((String)responseMap.get("content")));
50 LOG.info((String)responseMap.get("content"));
51 }
52
53 @Test
54 public void getLocationLevel() throws Exception {
55 LOG.info("Sending request to OLE Rest service to fetch location");
56 Map<String,Object> responseMap = OLELoaderRestClient.jerseryClientGet(BASE_URL + "locationLevel/2");
57 System.out.println("Response Status : \n" + responseMap.get("status"));
58 Assert.assertTrue(StringUtils.isNotBlank((String)responseMap.get("content")));
59 LOG.info((String) responseMap.get("content"));
60 }
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 }