001package org.kuali.ole.docstore.process;
002
003import org.junit.Before;
004import org.junit.Ignore;
005import org.junit.Test;
006import org.kuali.ole.BaseTestCase;
007import org.kuali.ole.OleDocStoreData;
008import org.kuali.ole.RepositoryBrowser;
009import org.kuali.ole.docstore.metrics.reindex.ReIndexingBatchStatus;
010import org.kuali.ole.docstore.metrics.reindex.ReIndexingDocTypeStatus;
011import org.kuali.ole.docstore.metrics.reindex.ReIndexingStatus;
012import org.kuali.ole.docstore.model.enums.DocCategory;
013import org.kuali.ole.docstore.model.enums.DocFormat;
014import org.kuali.ole.docstore.model.enums.DocType;
015import org.slf4j.Logger;
016import org.slf4j.LoggerFactory;
017
018import java.util.*;
019
020import static org.junit.Assert.fail;
021
022/**
023 * Class to test RebuildIndexesHandler.
024 *
025 * @author Rajesh Chowdary K
026 * @created May 2, 2012
027 */
028@Ignore
029@Deprecated
030public class RebuildIndexesHandler_UT extends BaseTestCase {
031
032    private static final Logger LOG = LoggerFactory.getLogger(RebuildIndexesHandler_UT.class);
033
034    @Before
035    public void setUp() throws Exception {
036        System.setProperty("OLE_DOCSTORE_USE_DISCOVERY", Boolean.TRUE.toString());
037    }
038
039    @Ignore
040    public void testRebuildIndexesForMarc() {
041        try {
042            RebuildIndexesHandler reBuilder = RebuildIndexesHandler.getInstance();
043            String category = DocCategory.WORK.getCode();
044            String type = DocType.INSTANCE.getDescription();
045            String format = DocFormat.MARC.getCode();
046            reBuilder.startProcess(null, null, null);
047            reBuilder.run();
048            reBuilder.stopProcess();
049            reBuilder.startProcess(category, type, format);
050            reBuilder.run();
051            reBuilder.stopProcess();
052        } catch (Exception e) {
053            LOG.info(e.getMessage(),e);
054            fail();
055        }
056    }
057
058    @Test
059    public void testReIndexingBatchStatus() {
060        ReIndexingBatchStatus reIndexingBatchStatus = new ReIndexingBatchStatus();
061        reIndexingBatchStatus.setBatchEndTime(reIndexingBatchStatus.getBatchEndTime());
062        reIndexingBatchStatus.setBatchIndexingTime(reIndexingBatchStatus.getBatchIndexingTime());
063        reIndexingBatchStatus.setBatchLoadTime(reIndexingBatchStatus.getBatchLoadTime());
064        reIndexingBatchStatus.setBatchStartTime(reIndexingBatchStatus.getBatchStartTime());
065        reIndexingBatchStatus.setBatchTotalTime(reIndexingBatchStatus.getBatchTotalTime());
066        reIndexingBatchStatus.setRecordsProcessed(reIndexingBatchStatus.getRecordsProcessed());
067        reIndexingBatchStatus.setRecordsRemaining(reIndexingBatchStatus.getRecordsRemaining());
068        reIndexingBatchStatus.setStatus(reIndexingBatchStatus.getStatus());
069    }
070
071    @Test
072    public void testReIndexingStatus() {
073        ReIndexingStatus reIndexingStatus = ReIndexingStatus.getInstance();
074        reIndexingStatus.reset();
075        reIndexingStatus.getDocTypeList();
076        reIndexingStatus.startDocType(DocCategory.WORK.getCode(), DocType.BIB.getCode(), DocFormat.MARC.getCode());
077        reIndexingStatus.getDocTypeList();
078        ReIndexingDocTypeStatus reIndexingDocTypeStatus = new ReIndexingDocTypeStatus();
079        List list = new ArrayList<ReIndexingDocTypeStatus>();
080        list.add(reIndexingDocTypeStatus);
081        ReIndexingBatchStatus reIndexingBatchStatus = new ReIndexingBatchStatus();
082        List reIndexingBatchStatusList = new ArrayList<ReIndexingBatchStatus>();
083        reIndexingBatchStatusList.add(reIndexingBatchStatus);
084        reIndexingDocTypeStatus.setReIndBatStatusList(reIndexingBatchStatusList);
085        reIndexingStatus.setReIndTypStatusList(list);
086        LOG.info("ReIndexingStatsuList : " + reIndexingStatus.getReIndTypStatusList());
087        reIndexingStatus.getJsonString();
088        reIndexingStatus.toString();
089    }
090
091    @Test
092    public void testReIndexingDocTypeStatus() {
093        ReIndexingDocTypeStatus reIndexingDocTypeStatus = new ReIndexingDocTypeStatus();
094        reIndexingDocTypeStatus.getDocCategory();
095        reIndexingDocTypeStatus.setReIndBatStatusList(reIndexingDocTypeStatus.getReIndBatStatusList());
096        reIndexingDocTypeStatus.getDocCategory();
097        reIndexingDocTypeStatus.getDocFormat();
098        reIndexingDocTypeStatus.getDocType();
099        reIndexingDocTypeStatus.getStatus();
100    }
101
102}