View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Created by IntelliJ IDEA.
41   * User: pvsubrah
42   * Date: 9/14/11
43   * Time: 10:22 AM
44   * To change this template use File | Settings | File Templates.
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 }