View Javadoc

1   package org.kuali.ole;
2   
3   import org.junit.Test;
4   import org.kuali.ole.docstore.xstream.FileUtil;
5   import org.kuali.ole.pojo.OleBibRecord;
6   import org.kuali.ole.pojo.OleEditorResponse;
7   
8   import java.io.File;
9   import java.net.URL;
10  import java.util.HashMap;
11  import java.util.Map;
12  
13  import static junit.framework.Assert.assertEquals;
14  import static junit.framework.Assert.assertNotNull;
15  import static junit.framework.Assert.assertTrue;
16  
17  /**
18   * Created by IntelliJ IDEA.
19   * User: pvsubrah
20   * Date: 4/11/12
21   * Time: 2:52 PM
22   * To change this template use File | Settings | File Templates.
23   */
24  public class OleEditorResponseHandler_UT {
25      private String xmlContent="";
26  
27      //TODO
28      @Test
29      public void testToXML() throws Exception {
30          OleEditorResponseHandler handler = new OleEditorResponseHandler();
31          OleEditorResponse response = new OleEditorResponse();
32          response.setTokenId("3000_0");
33          OleBibRecord record = new OleBibRecord();
34          record.setBibUUID("2345-6789");
35          record.setLinkedInstanceId("123-34567");
36          Map bibAssociatedFieldsValueMap = new HashMap();
37          bibAssociatedFieldsValueMap.put("author", "mock_author");
38          bibAssociatedFieldsValueMap.put("title", "mock_title");
39          record.setBibAssociatedFieldsValueMap(bibAssociatedFieldsValueMap);
40          response.setOleBibRecord(record);
41          System.out.println(handler.toXML(response));
42      }
43  
44  
45      //TODO
46      @Test
47      public void testFrom() throws Exception {
48          OleEditorResponseHandler oleEditorResponseHandler =
49                  new OleEditorResponseHandler();
50  
51          URL resource = getClass().getResource("OleEditorResponse.xml");
52          String xmlContent = new FileUtil().readFile(new File(resource.toURI()));
53  
54          OleEditorResponse oleEditorResponse = oleEditorResponseHandler.fromXML(xmlContent);
55          assertNotNull(oleEditorResponse);
56          assertEquals(oleEditorResponse.getOleBibRecord().getBibUUID(),"2345-6789");
57          assertEquals(oleEditorResponse.getOleBibRecord().getLinkedInstanceId(),"123-34567");
58      }
59  }