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          }
50          catch (Exception e) {
51              LOG.info(e.getMessage());
52              fail();
53          }
54      }
55  
56      @Test
57      public void testReIndexingBatchStatus(){
58          ReIndexingBatchStatus reIndexingBatchStatus = new  ReIndexingBatchStatus();
59          reIndexingBatchStatus.setBatchEndTime(reIndexingBatchStatus.getBatchEndTime());
60          reIndexingBatchStatus.setBatchIndexingTime(reIndexingBatchStatus.getBatchIndexingTime());
61          reIndexingBatchStatus.setBatchLoadTime(reIndexingBatchStatus.getBatchLoadTime());
62          reIndexingBatchStatus.setBatchStartTime(reIndexingBatchStatus.getBatchStartTime());
63          reIndexingBatchStatus.setBatchTotalTime(reIndexingBatchStatus.getBatchTotalTime());
64          reIndexingBatchStatus.setRecordsProcessed(reIndexingBatchStatus.getRecordsProcessed());
65          reIndexingBatchStatus.setRecordsRemaining(reIndexingBatchStatus.getRecordsRemaining());
66          reIndexingBatchStatus.setStatus(reIndexingBatchStatus.getStatus());
67      }
68  
69      @Test
70      public void testReIndexingStatus(){
71          ReIndexingStatus reIndexingStatus = ReIndexingStatus.getInstance();
72          reIndexingStatus.reset();
73          reIndexingStatus.getDocTypeList();
74          reIndexingStatus.startDocType(DocCategory.WORK.getCode(),DocType.BIB.getCode(),DocFormat.MARC.getCode());
75          reIndexingStatus.getDocTypeList();
76          ReIndexingDocTypeStatus reIndexingDocTypeStatus = new ReIndexingDocTypeStatus();
77          List list = new ArrayList<ReIndexingDocTypeStatus>();
78          list.add(reIndexingDocTypeStatus);
79          ReIndexingBatchStatus reIndexingBatchStatus = new ReIndexingBatchStatus();
80          List reIndexingBatchStatusList = new ArrayList<ReIndexingBatchStatus>();
81          reIndexingBatchStatusList.add(reIndexingBatchStatus);
82          reIndexingDocTypeStatus.setReIndBatStatusList(reIndexingBatchStatusList);
83          reIndexingStatus.setReIndTypStatusList(list);
84          LOG.info("ReIndexingStatsuList : " + reIndexingStatus.getReIndTypStatusList());
85          reIndexingStatus.getJsonString();
86          reIndexingStatus.toString();
87      }
88  
89      @Test
90      public void testReIndexingDocTypeStatus() {
91          ReIndexingDocTypeStatus reIndexingDocTypeStatus = new ReIndexingDocTypeStatus();
92          reIndexingDocTypeStatus.getDocCategory();
93          reIndexingDocTypeStatus.setReIndBatStatusList(reIndexingDocTypeStatus.getReIndBatStatusList());
94          reIndexingDocTypeStatus.getDocCategory();
95          reIndexingDocTypeStatus.getDocFormat();
96          reIndexingDocTypeStatus.getDocType();
97          reIndexingDocTypeStatus.getStatus();
98      }
99  
100 }