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.Test;
20 import org.kuali.ole.BaseTestCase;
21 import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
22 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
23 import org.kuali.ole.docstore.model.xmlpojo.ingest.Response;
24 import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler;
25 import org.kuali.ole.docstore.service.BeanLocator;
26 import org.kuali.ole.docstore.service.IngestNIndexHandlerService;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 import java.io.File;
31 import java.net.URL;
32 import java.util.Iterator;
33 import java.util.List;
34
35 import static junit.framework.Assert.assertNotNull;
36
37
38
39
40
41
42
43
44 public class CheckoutManager_UT
45 extends BaseTestCase {
46
47 private IngestNIndexHandlerService ingestNIndexHandlerService = BeanLocator
48 .getIngestNIndexHandlerService();
49 private static final Logger LOG = LoggerFactory
50 .getLogger(CheckoutManager_UT.class);
51
52 @Before
53 public void setUp() throws Exception {
54 super.setUp();
55 }
56
57 @Test
58 public void testCheckOut() throws Exception {
59 URL resource = getClass().getResource("request.xml");
60 File file = new File(resource.toURI());
61 String inputFile = readFile(file);
62 Request request = new RequestHandler().toObject(inputFile);
63 Response response = ingestNIndexHandlerService.ingestNIndexRequestDocuments(request);
64 assertNotNull(response);
65 List<RequestDocument> docStoreDocuments = request.getRequestDocuments();
66
67 CheckoutManager checkoutManager = new CheckoutManager();
68 for (Iterator<RequestDocument> iterator = docStoreDocuments.iterator(); iterator.hasNext(); ) {
69 RequestDocument next = iterator.next();
70 String checkedOutContent = checkoutManager.checkOut(next.getUuid(), "mockUser", "checkout");
71 assertNotNull(checkedOutContent);
72
73 }
74 }
75
76 @Test
77 public void testCheckOutForInstance() throws Exception {
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 CheckoutManager checkoutManager = new CheckoutManager();
98
99 String checkedOutContent = checkoutManager
100 .checkOut("1143e0b5-53ca-41e2-8655-e0a76fe930f6", "mockUser", "checkout");
101 LOG.info("checkedOutContent " + checkedOutContent);
102
103
104 }
105
106 }