1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.repository;
17
18 import org.junit.Before;
19 import org.junit.Ignore;
20 import org.junit.Test;
21 import org.kuali.ole.BaseTestCase;
22 import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
23 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
24 import org.kuali.ole.docstore.model.xmlpojo.ingest.Response;
25 import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler;
26 import org.kuali.ole.docstore.service.BeanLocator;
27 import org.kuali.ole.docstore.service.IngestNIndexHandlerService;
28 import org.kuali.ole.logger.DocStoreLogger;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 import java.io.File;
33 import java.net.URL;
34 import java.util.Iterator;
35 import java.util.List;
36
37 import static junit.framework.Assert.assertNotNull;
38
39
40
41
42
43
44
45
46 @Ignore
47 @Deprecated
48 public class CheckoutManager_UT
49 extends BaseTestCase {
50
51 private IngestNIndexHandlerService ingestNIndexHandlerService = BeanLocator
52 .getIngestNIndexHandlerService();
53 private static final Logger LOG = LoggerFactory
54 .getLogger(CheckoutManager_UT.class);
55
56 @Before
57 public void setUp() throws Exception {
58 super.setUp();
59 }
60
61 @Test
62 public void testCheckOut() throws Exception {
63 URL resource = getClass().getResource("request.xml");
64 File file = new File(resource.toURI());
65 String inputFile = readFile(file);
66 Request request = new RequestHandler().toObject(inputFile);
67 Response response = ingestNIndexHandlerService.ingestNIndexRequestDocuments(request);
68 assertNotNull(response);
69 List<RequestDocument> docStoreDocuments = request.getRequestDocuments();
70
71 CheckoutManager checkoutManager = new CheckoutManager();
72 DocStoreLogger docStoreLogger = checkoutManager.getDocStoreLogger();
73 docStoreLogger.log("checkOutManager");
74 for (Iterator<RequestDocument> iterator = docStoreDocuments.iterator(); iterator.hasNext(); ) {
75 RequestDocument next = iterator.next();
76 String checkedOutContent = checkoutManager.checkOut(next.getUuid(), "mockUser", "checkout");
77 docStoreLogger.log("checkOut content:" + checkedOutContent);
78 assertNotNull(checkedOutContent);
79 }
80 }
81
82 @Test
83 public void testCheckOutForInstance() throws Exception {
84
85 URL resource = getClass().getResource("/org/kuali/ole/repository/requestInstance.xml");
86 File file = new File(resource.toURI());
87 String inputFile = readFile(file);
88 Request request = new RequestHandler().toObject(inputFile);
89 Response response = ingestNIndexHandlerService.ingestNIndexRequestDocuments(request);
90 assertNotNull(response);
91 List<RequestDocument> docStoreDocuments = request.getRequestDocuments();
92
93 CheckoutManager checkoutManager = new CheckoutManager();
94 for (Iterator<RequestDocument> iterator = docStoreDocuments.iterator(); iterator.hasNext(); ) {
95 RequestDocument next = iterator.next();
96 String checkedOutContent = checkoutManager.checkOut(next.getUuid(), "mockUser", "checkout");
97 assertNotNull(checkedOutContent);
98 System.out.println(checkedOutContent);
99
100
101 }
102 }
103
104 }