View Javadoc
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   * Created by sheiksalahudeenm on 3/5/15.
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      /* --------- Location Services Start ----------- */
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  /*    @Test
63      public void importLocationLevel() throws Exception {
64          String locationInfo = FileUtils.readFileContent("org/kuali/ole/loaders/describe/importLocationLevel.json");
65          Map<String,Object> responseMap = OLELoaderRestClient.jerseryClientPost(BASE_URL + "/locationLevel", locationInfo);
66          System.out.println("Response Status : \n" + responseMap.get("status"));
67          Assert.assertTrue(StringUtils.isNotBlank((String)responseMap.get("content")));
68          LOG.info((String)responseMap.get("content"));
69      }
70  
71      @Test
72      public void updateLocationLevel() throws Exception {
73          String locationInfo = FileUtils.readFileContent("org/kuali/ole/loaders/describe/updateLocationLevel.json");
74          String response = RestClient.jerseryClientPut(BASE_URL + "/locationLevel/2", locationInfo);
75          Assert.assertTrue(StringUtils.isNotBlank(response));
76          LOG.info(response);
77      }*/
78  
79      /* --------- Location Services End ----------- */
80  }