View Javadoc

1   package org.kuali.ole.docstore.process;
2   
3   import org.junit.Before;
4   import org.junit.Test;
5   import org.kuali.ole.BaseTestCase;
6   import org.kuali.ole.OleDocStoreData;
7   import org.kuali.ole.RepositoryBrowser;
8   import org.kuali.ole.docstore.metrics.reindex.ReIndexingBatchStatus;
9   import org.kuali.ole.docstore.metrics.reindex.ReIndexingDocTypeStatus;
10  import org.kuali.ole.docstore.metrics.reindex.ReIndexingStatus;
11  import org.kuali.ole.docstore.model.enums.DocCategory;
12  import org.kuali.ole.docstore.model.enums.DocFormat;
13  import org.kuali.ole.docstore.model.enums.DocType;
14  import org.slf4j.Logger;
15  import org.slf4j.LoggerFactory;
16  
17  import java.util.*;
18  
19  import static org.junit.Assert.fail;
20  
21  /**
22   * Class to test RebuildIndexesHandler.
23   *
24   * @author Rajesh Chowdary K
25   * @created May 2, 2012
26   */
27  public class RebuildIndexesHandler_UT extends BaseTestCase {
28  
29      private static final Logger LOG = LoggerFactory.getLogger(RebuildIndexesHandler_UT.class);
30  
31      @Before
32      public void setUp() throws Exception {
33          System.setProperty("OLE_DOCSTORE_USE_DISCOVERY", Boolean.TRUE.toString());
34      }
35  
36      @Test
37      public void testRebuildIndexesForMarc() {
38          try {
39              RebuildIndexesHandler reBuilder = RebuildIndexesHandler.getInstance();
40              String category = DocCategory.WORK.getCode();
41              String type = DocType.INSTANCE.getDescription();
42              String format = DocFormat.MARC.getCode();
43              reBuilder.startProcess(null, null, null);
44              reBuilder.run();
45              reBuilder.stopProcess();
46              reBuilder.startProcess(category, type, format);
47              reBuilder.run();
48              reBuilder.stopProcess();
49          } catch (Exception e) {
50              LOG.info(e.getMessage(),e);
51              fail();
52          }
53      }
54  
55      @Test
56      public void testReIndexingBatchStatus() {
57          ReIndexingBatchStatus reIndexingBatchStatus = new ReIndexingBatchStatus();
58          reIndexingBatchStatus.setBatchEndTime(reIndexingBatchStatus.getBatchEndTime());
59          reIndexingBatchStatus.setBatchIndexingTime(reIndexingBatchStatus.getBatchIndexingTime());
60          reIndexingBatchStatus.setBatchLoadTime(reIndexingBatchStatus.getBatchLoadTime());
61          reIndexingBatchStatus.setBatchStartTime(reIndexingBatchStatus.getBatchStartTime());
62          reIndexingBatchStatus.setBatchTotalTime(reIndexingBatchStatus.getBatchTotalTime());
63          reIndexingBatchStatus.setRecordsProcessed(reIndexingBatchStatus.getRecordsProcessed());
64          reIndexingBatchStatus.setRecordsRemaining(reIndexingBatchStatus.getRecordsRemaining());
65          reIndexingBatchStatus.setStatus(reIndexingBatchStatus.getStatus());
66      }
67  
68      @Test
69      public void testReIndexingStatus() {
70          ReIndexingStatus reIndexingStatus = ReIndexingStatus.getInstance();
71          reIndexingStatus.reset();
72          reIndexingStatus.getDocTypeList();
73          reIndexingStatus.startDocType(DocCategory.WORK.getCode(), DocType.BIB.getCode(), DocFormat.MARC.getCode());
74          reIndexingStatus.getDocTypeList();
75          ReIndexingDocTypeStatus reIndexingDocTypeStatus = new ReIndexingDocTypeStatus();
76          List list = new ArrayList<ReIndexingDocTypeStatus>();
77          list.add(reIndexingDocTypeStatus);
78          ReIndexingBatchStatus reIndexingBatchStatus = new ReIndexingBatchStatus();
79          List reIndexingBatchStatusList = new ArrayList<ReIndexingBatchStatus>();
80          reIndexingBatchStatusList.add(reIndexingBatchStatus);
81          reIndexingDocTypeStatus.setReIndBatStatusList(reIndexingBatchStatusList);
82          reIndexingStatus.setReIndTypStatusList(list);
83          LOG.info("ReIndexingStatsuList : " + reIndexingStatus.getReIndTypStatusList());
84          reIndexingStatus.getJsonString();
85          reIndexingStatus.toString();
86      }
87  
88      @Test
89      public void testReIndexingDocTypeStatus() {
90          ReIndexingDocTypeStatus reIndexingDocTypeStatus = new ReIndexingDocTypeStatus();
91          reIndexingDocTypeStatus.getDocCategory();
92          reIndexingDocTypeStatus.setReIndBatStatusList(reIndexingDocTypeStatus.getReIndBatStatusList());
93          reIndexingDocTypeStatus.getDocCategory();
94          reIndexingDocTypeStatus.getDocFormat();
95          reIndexingDocTypeStatus.getDocType();
96          reIndexingDocTypeStatus.getStatus();
97      }
98  
99  }