| 1 | 
    
            
    
     | 
    
           | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
           | 
  
            
  
    | 17 | 
    
            
    
     | 
    
      package org.kuali.rice.kew.docsearch;     | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
            
  
    | 19 | 
    
            
    
     | 
    
      import org.junit.Test;     | 
  
            
  
    | 20 | 
    
            
    
     | 
    
      import org.kuali.rice.core.framework.persistence.jdbc.sql.SQLUtils;     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.docsearch.service.DocumentSearchService;     | 
  
            
  
    | 22 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.doctype.bo.DocumentType;     | 
  
            
  
    | 23 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.doctype.service.DocumentTypeService;     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.engine.node.RouteNode;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.service.KEWServiceLocator;     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.service.WorkflowDocument;     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.test.KEWTestCase;     | 
  
            
  
    | 28 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.util.KEWConstants;     | 
  
            
  
    | 29 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.web.KeyValueSort;     | 
  
            
  
    | 30 | 
    
            
    
     | 
    
      import org.kuali.rice.kim.bo.Person;     | 
  
            
  
    | 31 | 
    
            
    
     | 
    
      import org.kuali.rice.kim.service.KIMServiceLocator;     | 
  
            
  
    | 32 | 
    
            
    
     | 
    
      import org.kuali.rice.test.BaselineTestCase;     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
      import org.kuali.rice.test.TestHarnessServiceLocator;     | 
  
            
  
    | 34 | 
    
            
    
     | 
    
      import org.springframework.jdbc.core.JdbcTemplate;     | 
  
            
  
    | 35 | 
    
            
    
     | 
    
           | 
  
            
  
    | 36 | 
    
            
    
     | 
    
      import java.math.BigDecimal;     | 
  
            
  
    | 37 | 
    
            
    
     | 
    
      import java.util.Calendar;     | 
  
            
  
    | 38 | 
    
            
    
     | 
    
      import java.util.Iterator;     | 
  
            
  
    | 39 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
           | 
  
            
  
    | 41 | 
    
            
    
     | 
    
      import static org.junit.Assert.*;     | 
  
            
  
    | 42 | 
    
            
    
     | 
    
           | 
  
            
  
    | 43 | 
    
            
    
     | 
    
      @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)     | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 305 (305) | 
           Complexity: 28 | 
           Complexity Density: 0.11 | 
                        
            
        | 
    
  
  
    | 44 | 
    
            
    
     | 
    
      public class DocumentSearchTest extends KEWTestCase {     | 
  
            
  
    | 45 | 
    
            
    
     | 
    
          private static final String KREW_DOC_HDR_T = "KREW_DOC_HDR_T";     | 
  
            
  
    | 46 | 
    
            
    
     | 
    
          private static final String INITIATOR_COL = "INITR_PRNCPL_ID";     | 
  
            
  
    | 47 | 
    
            
    
     | 
    
           | 
  
            
  
    | 48 | 
    
            
    
     | 
    
          DocumentSearchService docSearchService;     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 50 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 51 | 
    
            
    
     | 
    
          protected void loadTestData() throws Exception {     | 
  
            
  
    | 52 | 
    
           0
    
     | 
    
              loadXmlFile("SearchAttributeConfig.xml");     | 
  
            
  
    | 53 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 54 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 56 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
          protected void setUpAfterDataLoad() throws Exception {     | 
  
            
  
    | 58 | 
    
           0
    
     | 
    
              docSearchService = (DocumentSearchService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);     | 
  
            
  
    | 59 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 60 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 25 (25) | 
           Complexity: 1 | 
           Complexity Density: 0.04 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 61 | 
    
           0
    
     | 
    
           @Test public void testDocSearch() throws Exception {...     | 
  
            
  
    | 62 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName("bmcgough");     | 
  
            
  
    | 63 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 64 | 
    
           0
    
     | 
    
              List searchResults = null;     | 
  
            
  
    | 65 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = null;     | 
  
            
  
    | 66 | 
    
           0
    
     | 
    
              criteria.setDocTitle("*IN");     | 
  
            
  
    | 67 | 
    
           0
    
     | 
    
              criteria.setNamedSearch("bytitle");     | 
  
            
  
    | 68 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 69 | 
    
           0
    
     | 
    
              criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 70 | 
    
           0
    
     | 
    
              criteria.setDocTitle("*IN-CFSG");     | 
  
            
  
    | 71 | 
    
           0
    
     | 
    
              criteria.setNamedSearch("for in accounts");     | 
  
            
  
    | 72 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 73 | 
    
           0
    
     | 
    
              criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 74 | 
    
           0
    
     | 
    
              criteria.setFromDateApproved("09/16/2004");     | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 76 | 
    
           0
    
     | 
    
              criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 77 | 
    
           0
    
     | 
    
              criteria.setDocRouteNodeId("3");     | 
  
            
  
    | 78 | 
    
           0
    
     | 
    
              criteria.setDocRouteNodeLogic("equal");     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 80 | 
    
           0
    
     | 
    
              user = KIMServiceLocator.getPersonService().getPersonByPrincipalName("bmcgough");     | 
  
            
  
    | 81 | 
    
           0
    
     | 
    
              SavedSearchResult savedSearchResults = docSearchService.getSavedSearchResults(user.getPrincipalId(), "DocSearch.NamedSearch.bytitle");     | 
  
            
  
    | 82 | 
    
           0
    
     | 
    
              assertNotNull(savedSearchResults);     | 
  
            
  
    | 83 | 
    
           0
    
     | 
    
              assertNotNull(savedSearchResults.getSearchResult());     | 
  
            
  
    | 84 | 
    
           0
    
     | 
    
              savedSearchResults = docSearchService.getSavedSearchResults(user.getPrincipalId(), "DocSearch.NamedSearch.for in accounts");     | 
  
            
  
    | 85 | 
    
           0
    
     | 
    
              assertNotNull(savedSearchResults);     | 
  
            
  
    | 86 | 
    
           0
    
     | 
    
              assertNotNull(savedSearchResults.getSearchResult());     | 
  
            
  
    | 87 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 88 | 
    
            
    
     | 
    
           | 
  
            
  
    | 89 | 
    
            
    
     | 
    
               | 
  
            
  
    | 90 | 
    
            
    
     | 
    
           | 
  
            
  
    | 91 | 
    
            
    
     | 
    
           | 
  
            
  
    | 92 | 
    
            
    
     | 
    
           | 
  
            
  
    | 93 | 
    
            
    
     | 
    
      @throws     | 
  
            
  
    | 94 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 17 (17) | 
           Complexity: 1 | 
           Complexity Density: 0.06 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 95 | 
    
           0
    
     | 
    
           @Test public void testDocSearch_MissingInitiator() throws Exception {...     | 
  
            
  
    | 96 | 
    
           0
    
     | 
    
              String documentTypeName = "SearchDocType";     | 
  
            
  
    | 97 | 
    
           0
    
     | 
    
              DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);     | 
  
            
  
    | 98 | 
    
           0
    
     | 
    
              String userNetworkId = "arh14";     | 
  
            
  
    | 99 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 100 | 
    
           0
    
     | 
    
              WorkflowDocument workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), documentTypeName);     | 
  
            
  
    | 101 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("testDocSearch_MissingInitiator");     | 
  
            
  
    | 102 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 103 | 
    
            
    
     | 
    
           | 
  
            
  
    | 104 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 105 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 106 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 107 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 108 | 
    
            
    
     | 
    
           | 
  
            
  
    | 109 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 110 | 
    
           0
    
     | 
    
              new JdbcTemplate(TestHarnessServiceLocator.getDataSource()).execute("update " + KREW_DOC_HDR_T + " set " + INITIATOR_COL + " = 'bogus user' where DOC_HDR_ID = " + workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 111 | 
    
            
    
     | 
    
           | 
  
            
  
    | 112 | 
    
            
    
     | 
    
           | 
  
            
  
    | 113 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName("jhopf");     | 
  
            
  
    | 114 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 115 | 
    
           0
    
     | 
    
              criteria.setDocTypeFullName(documentTypeName);     | 
  
            
  
    | 116 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 117 | 
    
           0
    
     | 
    
              assertNotNull(result);     | 
  
            
  
    | 118 | 
    
           0
    
     | 
    
              assertNotNull(result.getSearchResults());     | 
  
            
  
    | 119 | 
    
           0
    
     | 
    
              assertEquals("Search returned invalid number of documents", 1, result.getSearchResults().size());     | 
  
            
  
    | 120 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 121 | 
    
            
    
     | 
    
           | 
  
            
  
    | 122 | 
    
            
    
     | 
    
               | 
  
            
  
    | 123 | 
    
            
    
     | 
    
           | 
  
            
  
    | 124 | 
    
            
    
     | 
    
      @throws     | 
  
            
  
    | 125 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 16 (16) | 
           Complexity: 1 | 
           Complexity Density: 0.06 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 126 | 
    
           0
    
     | 
    
           @Test public void testDocSearch_SearchOnMissingInitiator() throws Exception {...     | 
  
            
  
    | 127 | 
    
           0
    
     | 
    
              String documentTypeName = "SearchDocType";     | 
  
            
  
    | 128 | 
    
           0
    
     | 
    
              DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);     | 
  
            
  
    | 129 | 
    
           0
    
     | 
    
              String userNetworkId = "arh14";     | 
  
            
  
    | 130 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 131 | 
    
           0
    
     | 
    
              WorkflowDocument workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), documentTypeName);     | 
  
            
  
    | 132 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("testDocSearch_MissingInitiator");     | 
  
            
  
    | 133 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 134 | 
    
            
    
     | 
    
           | 
  
            
  
    | 135 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 136 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 137 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 138 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 139 | 
    
            
    
     | 
    
           | 
  
            
  
    | 140 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 141 | 
    
           0
    
     | 
    
              new JdbcTemplate(TestHarnessServiceLocator.getDataSource()).execute("update " + KREW_DOC_HDR_T + " set " + INITIATOR_COL + " = 'bogus user' where DOC_HDR_ID = " + workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 142 | 
    
            
    
     | 
    
           | 
  
            
  
    | 143 | 
    
            
    
     | 
    
           | 
  
            
  
    | 144 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName("jhopf");     | 
  
            
  
    | 145 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 146 | 
    
           0
    
     | 
    
              criteria.setInitiator("bogus user");     | 
  
            
  
    | 147 | 
    
            
    
     | 
    
           | 
  
            
  
    | 148 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 149 | 
    
           0
    
     | 
    
              int size = result.getSearchResults().size();     | 
  
            
  
    | 150 | 
    
           0
    
     | 
    
              assertTrue("Searching by an invalid initiator should return nothing", size == 0);     | 
  
            
  
    | 151 | 
    
            
    
     | 
    
           | 
  
            
  
    | 152 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 153 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 41 (41) | 
           Complexity: 1 | 
           Complexity Density: 0.02 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 154 | 
    
           0
    
     | 
    
           @Test public void testDocSearch_RouteNodeName() throws Exception {...     | 
  
            
  
    | 155 | 
    
           0
    
     | 
    
              loadXmlFile("DocSearchTest_RouteNode.xml");     | 
  
            
  
    | 156 | 
    
           0
    
     | 
    
              String documentTypeName = "SearchDocType_RouteNodeTest";     | 
  
            
  
    | 157 | 
    
           0
    
     | 
    
              DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);     | 
  
            
  
    | 158 | 
    
           0
    
     | 
    
              String userNetworkId = "rkirkend";     | 
  
            
  
    | 159 | 
    
            
    
     | 
    
           | 
  
            
  
    | 160 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 161 | 
    
           0
    
     | 
    
              WorkflowDocument workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), documentTypeName);     | 
  
            
  
    | 162 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("Routing style");     | 
  
            
  
    | 163 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 164 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 165 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 166 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 167 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 168 | 
    
           0
    
     | 
    
              workflowDocument.approve("");     | 
  
            
  
    | 169 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 170 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsFinal());     | 
  
            
  
    | 171 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), documentTypeName);     | 
  
            
  
    | 172 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("Routing style");     | 
  
            
  
    | 173 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 174 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 175 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 176 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 177 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 178 | 
    
            
    
     | 
    
           | 
  
            
  
    | 179 | 
    
            
    
     | 
    
           | 
  
            
  
    | 180 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName(userNetworkId);     | 
  
            
  
    | 181 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 182 | 
    
           0
    
     | 
    
              criteria.setDocTypeFullName(documentTypeName);     | 
  
            
  
    | 183 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 184 | 
    
           0
    
     | 
    
              assertNotNull(result);     | 
  
            
  
    | 185 | 
    
           0
    
     | 
    
              assertNotNull(result.getSearchResults());     | 
  
            
  
    | 186 | 
    
           0
    
     | 
    
              assertEquals("Search returned invalid number of documents", 2, result.getSearchResults().size());     | 
  
            
  
    | 187 | 
    
            
    
     | 
    
           | 
  
            
  
    | 188 | 
    
           0
    
     | 
    
              criteria.setDocRouteNodeId(getRouteNodeForSearch(documentTypeName,workflowDocument.getNodeNames()));     | 
  
            
  
    | 189 | 
    
           0
    
     | 
    
              criteria.setDocRouteNodeLogic("equal");     | 
  
            
  
    | 190 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 191 | 
    
           0
    
     | 
    
              assertNotNull(result);     | 
  
            
  
    | 192 | 
    
           0
    
     | 
    
              assertNotNull(result.getSearchResults());     | 
  
            
  
    | 193 | 
    
           0
    
     | 
    
              assertEquals("Search returned invalid number of documents", 1, result.getSearchResults().size());     | 
  
            
  
    | 194 | 
    
            
    
     | 
    
           | 
  
            
  
    | 195 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 196 | 
    
           0
    
     | 
    
              loadXmlFile("DocSearchTest_RouteNode.xml");     | 
  
            
  
    | 197 | 
    
            
    
     | 
    
           | 
  
            
  
    | 198 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 199 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 200 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 201 | 
    
           0
    
     | 
    
              criteria.setDocRouteNodeId(getRouteNodeForSearch(documentTypeName,workflowDocument.getNodeNames()));     | 
  
            
  
    | 202 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 203 | 
    
           0
    
     | 
    
              assertNotNull(result);     | 
  
            
  
    | 204 | 
    
           0
    
     | 
    
              assertNotNull(result.getSearchResults());     | 
  
            
  
    | 205 | 
    
           0
    
     | 
    
              assertEquals("Search returned invalid number of documents", 1, result.getSearchResults().size());     | 
  
            
  
    | 206 | 
    
            
    
     | 
    
           | 
  
            
  
    | 207 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 208 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 12 (12) | 
           Complexity: 3 | 
           Complexity Density: 0.38 | 
                        
            
        | 
    
  
  
    | 209 | 
    
           0
    
     | 
    
           private String getRouteNodeForSearch(String documentTypeName, String[] nodeNames) {...     | 
  
            
  
    | 210 | 
    
           0
    
     | 
    
              assertEquals(1,    nodeNames.length);     | 
  
            
  
    | 211 | 
    
           0
    
     | 
    
          String expectedNodeName = nodeNames[0];     | 
  
            
  
    | 212 | 
    
           0
    
     | 
    
              List routeNodes = KEWServiceLocator.getRouteNodeService().getFlattenedNodes(KEWServiceLocator.getDocumentTypeService().findByName(documentTypeName), true);     | 
  
            
  
    | 213 | 
    
           0
    
     | 
    
              for (Iterator iterator = routeNodes.iterator(); iterator.hasNext();) {     | 
  
            
  
    | 214 | 
    
           0
    
     | 
    
              RouteNode node = (RouteNode) iterator.next();     | 
  
            
  
    | 215 | 
    
           0
    
     | 
    
              if (expectedNodeName.equals(node.getRouteNodeName())) {     | 
  
            
  
    | 216 | 
    
           0
    
     | 
    
              return node.getRouteNodeName();     | 
  
            
  
    | 217 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 218 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 219 | 
    
           0
    
     | 
    
              return null;     | 
  
            
  
    | 220 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 221 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 3 (3) | 
           Complexity: 1 | 
           Complexity Density: 0.33 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 222 | 
    
           0
    
     | 
    
           @Test public void testGetNamedDocSearches() throws Exception {...     | 
  
            
  
    | 223 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName("bmcgough");     | 
  
            
  
    | 224 | 
    
           0
    
     | 
    
              List namedSearches = docSearchService.getNamedSearches(user.getPrincipalId());     | 
  
            
  
    | 225 | 
    
           0
    
     | 
    
              assertNotNull(namedSearches);     | 
  
            
  
    | 226 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 227 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 14 (14) | 
           Complexity: 1 | 
           Complexity Density: 0.07 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 228 | 
    
           0
    
     | 
    
           @Test public void testDefaultCreateDateSearchCriteria() throws Exception {...     | 
  
            
  
    | 229 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName("bmcgough");     | 
  
            
  
    | 230 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 231 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 232 | 
    
           0
    
     | 
    
              assertNotNull("Should have a date created value",criteria.getFromDateCreated());     | 
  
            
  
    | 233 | 
    
           0
    
     | 
    
              Calendar criteriaDate = Calendar.getInstance();     | 
  
            
  
    | 234 | 
    
           0
    
     | 
    
              criteriaDate.setTime(SQLUtils.convertStringDateToTimestamp(criteria.getFromDateCreated()));     | 
  
            
  
    | 235 | 
    
           0
    
     | 
    
              assertEquals("Criteria date minus today's date should equal the constant value", KEWConstants.DOCUMENT_SEARCH_NO_CRITERIA_CREATE_DATE_DAYS_AGO.doubleValue(), getDifferenceInDays(criteriaDate), 0);     | 
  
            
  
    | 236 | 
    
            
    
     | 
    
           | 
  
            
  
    | 237 | 
    
           0
    
     | 
    
              criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 238 | 
    
           0
    
     | 
    
              criteria.setDocTitle("testing");     | 
  
            
  
    | 239 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 240 | 
    
           0
    
     | 
    
              assertNotNull("Should have a date created value",criteria.getFromDateCreated());     | 
  
            
  
    | 241 | 
    
           0
    
     | 
    
              criteriaDate = Calendar.getInstance();     | 
  
            
  
    | 242 | 
    
           0
    
     | 
    
              criteriaDate.setTime(SQLUtils.convertStringDateToTimestamp(criteria.getFromDateCreated()));     | 
  
            
  
    | 243 | 
    
           0
    
     | 
    
              assertEquals("Criteria date minus today's date should equal the constant value", KEWConstants.DOCUMENT_SEARCH_DOC_TITLE_CREATE_DATE_DAYS_AGO.doubleValue(), getDifferenceInDays(criteriaDate), 0);     | 
  
            
  
    | 244 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 245 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 10 (10) | 
           Complexity: 1 | 
           Complexity Density: 0.1 | 
                        
            
        | 
    
  
  
    | 246 | 
    
           0
    
     | 
    
           private static double getDifferenceInDays(Calendar compareDate) {...     | 
  
            
  
    | 247 | 
    
           0
    
     | 
    
              Calendar today = Calendar.getInstance();     | 
  
            
  
    | 248 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 249 | 
    
           0
    
     | 
    
              today.set(Calendar.HOUR_OF_DAY, 0);     | 
  
            
  
    | 250 | 
    
           0
    
     | 
    
              today.set(Calendar.MINUTE, 0);     | 
  
            
  
    | 251 | 
    
           0
    
     | 
    
              today.set(Calendar.SECOND, 0);     | 
  
            
  
    | 252 | 
    
           0
    
     | 
    
              today.set(Calendar.MILLISECOND, 0);     | 
  
            
  
    | 253 | 
    
            
    
     | 
    
           | 
  
            
  
    | 254 | 
    
           0
    
     | 
    
              compareDate.set(Calendar.HOUR_OF_DAY, 0);     | 
  
            
  
    | 255 | 
    
           0
    
     | 
    
              compareDate.set(Calendar.MINUTE, 0);     | 
  
            
  
    | 256 | 
    
           0
    
     | 
    
              compareDate.set(Calendar.SECOND, 0);     | 
  
            
  
    | 257 | 
    
           0
    
     | 
    
              compareDate.set(Calendar.MILLISECOND, 0);     | 
  
            
  
    | 258 | 
    
            
    
     | 
    
           | 
  
            
  
    | 259 | 
    
           0
    
     | 
    
              return (BigDecimal.valueOf(compareDate.getTimeInMillis()).subtract(BigDecimal.valueOf(today.getTimeInMillis()))).divide(BigDecimal.valueOf(24 * 60 * 60 * 1000.00), BigDecimal.ROUND_HALF_UP).doubleValue();     | 
  
            
  
    | 260 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 261 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 59 (59) | 
           Complexity: 3 | 
           Complexity Density: 0.05 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 262 | 
    
           0
    
     | 
    
           @Test public void testUseWorkflowSuperUserDocHandlerPolicy() throws Exception {...     | 
  
            
  
    | 263 | 
    
           0
    
     | 
    
              String customDocHandlerDocumentType = "SearchDocType";     | 
  
            
  
    | 264 | 
    
           0
    
     | 
    
              String standardDocHandlerDocumentType = "SearchDocType2";     | 
  
            
  
    | 265 | 
    
           0
    
     | 
    
              DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(customDocHandlerDocumentType);     | 
  
            
  
    | 266 | 
    
           0
    
     | 
    
              String userNetworkId = "rkirkend";     | 
  
            
  
    | 267 | 
    
            
    
     | 
    
           | 
  
            
  
    | 268 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 269 | 
    
           0
    
     | 
    
              WorkflowDocument workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), standardDocHandlerDocumentType);     | 
  
            
  
    | 270 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("Routing style");     | 
  
            
  
    | 271 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 272 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 273 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 274 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 275 | 
    
            
    
     | 
    
           | 
  
            
  
    | 276 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 277 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), customDocHandlerDocumentType);     | 
  
            
  
    | 278 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("Routing style");     | 
  
            
  
    | 279 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 280 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 281 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 282 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 283 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 284 | 
    
           0
    
     | 
    
              workflowDocument.approve("");     | 
  
            
  
    | 285 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 286 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsFinal());     | 
  
            
  
    | 287 | 
    
            
    
     | 
    
           | 
  
            
  
    | 288 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId(userNetworkId), customDocHandlerDocumentType);     | 
  
            
  
    | 289 | 
    
           0
    
     | 
    
              workflowDocument.setTitle("Routing style");     | 
  
            
  
    | 290 | 
    
           0
    
     | 
    
              workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 291 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 292 | 
    
           0
    
     | 
    
              workflowDocument = new WorkflowDocument(getPrincipalId("jhopf"),workflowDocument.getRouteHeaderId());     | 
  
            
  
    | 293 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.stateIsEnroute());     | 
  
            
  
    | 294 | 
    
           0
    
     | 
    
              assertTrue(workflowDocument.isApprovalRequested());     | 
  
            
  
    | 295 | 
    
            
    
     | 
    
           | 
  
            
  
    | 296 | 
    
           0
    
     | 
    
              Person user = KIMServiceLocator.getPersonService().getPersonByPrincipalName(userNetworkId);     | 
  
            
  
    | 297 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 298 | 
    
           0
    
     | 
    
              criteria.setSuperUserSearch("YES");     | 
  
            
  
    | 299 | 
    
           0
    
     | 
    
              criteria.setDocTypeFullName(customDocHandlerDocumentType);     | 
  
            
  
    | 300 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 301 | 
    
           0
    
     | 
    
              assertNotNull(result);     | 
  
            
  
    | 302 | 
    
           0
    
     | 
    
              assertNotNull(result.getSearchResults());     | 
  
            
  
    | 303 | 
    
           0
    
     | 
    
              assertEquals("Search returned invalid number of documents", 2, result.getSearchResults().size());     | 
  
            
  
    | 304 | 
    
           0
    
     | 
    
              for (DocumentSearchResult resultElement : result.getSearchResults()) {     | 
  
            
  
    | 305 | 
    
           0
    
     | 
    
              KeyValueSort kvs = resultElement.getResultContainer(DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID);     | 
  
            
  
    | 306 | 
    
           0
    
     | 
    
              assertNotNull("A valid column field value should be returned for key " + DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID, kvs);     | 
  
            
  
    | 307 | 
    
           0
    
     | 
    
              assertTrue("The document handler redirect for the client should be included in the route header id url", kvs.getValue().contains(KEWConstants.DOC_HANDLER_REDIRECT_PAGE));     | 
  
            
  
    | 308 | 
    
           0
    
     | 
    
              assertTrue("The document handler redirect for the client should include the command value for super user search", kvs.getValue().contains(KEWConstants.SUPERUSER_COMMAND));     | 
  
            
  
    | 309 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 310 | 
    
            
    
     | 
    
           | 
  
            
  
    | 311 | 
    
           0
    
     | 
    
              user = KIMServiceLocator.getPersonService().getPersonByPrincipalName(userNetworkId);     | 
  
            
  
    | 312 | 
    
           0
    
     | 
    
              criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 313 | 
    
           0
    
     | 
    
              criteria.setSuperUserSearch("YES");     | 
  
            
  
    | 314 | 
    
           0
    
     | 
    
              result = docSearchService.getList(user.getPrincipalId(), criteria);     | 
  
            
  
    | 315 | 
    
           0
    
     | 
    
              assertNotNull(result);     | 
  
            
  
    | 316 | 
    
           0
    
     | 
    
              assertNotNull(result.getSearchResults());     | 
  
            
  
    | 317 | 
    
           0
    
     | 
    
              assertEquals("Search returned invalid number of documents", 3, result.getSearchResults().size());     | 
  
            
  
    | 318 | 
    
           0
    
     | 
    
              for (DocumentSearchResult resultElement : result.getSearchResults()) {     | 
  
            
  
    | 319 | 
    
           0
    
     | 
    
              KeyValueSort routeHeaderIdValue = resultElement.getResultContainer(DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID);     | 
  
            
  
    | 320 | 
    
           0
    
     | 
    
              assertNotNull("A valid column field value should be returned for key " + DocumentSearchResult.PROPERTY_NAME_ROUTE_HEADER_ID, routeHeaderIdValue);     | 
  
            
  
    | 321 | 
    
           0
    
     | 
    
              KeyValueSort documentTypeValue = resultElement.getResultContainer(DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL);     | 
  
            
  
    | 322 | 
    
           0
    
     | 
    
              assertNotNull("A valid column field value should be returned for key " + DocumentSearchResult.PROPERTY_NAME_DOC_TYPE_LABEL, documentTypeValue);     | 
  
            
  
    | 323 | 
    
           0
    
     | 
    
              if (customDocHandlerDocumentType.equals(documentTypeValue.getValue())) {     | 
  
            
  
    | 324 | 
    
           0
    
     | 
    
              assertTrue("The document handler redirect for the client should be included in the route header id url", routeHeaderIdValue.getValue().contains(KEWConstants.DOC_HANDLER_REDIRECT_PAGE));     | 
  
            
  
    | 325 | 
    
           0
    
     | 
    
              assertTrue("The document handler redirect for the client should include the command value for super user search", routeHeaderIdValue.getValue().contains(KEWConstants.SUPERUSER_COMMAND));     | 
  
            
  
    | 326 | 
    
           0
    
     | 
    
              } else if (standardDocHandlerDocumentType.equals(documentTypeValue.getValue())) {     | 
  
            
  
    | 327 | 
    
           0
    
     | 
    
              assertTrue("The document handler redirect for the client should be included in the route header id url", !routeHeaderIdValue.getValue().contains(KEWConstants.DOC_HANDLER_REDIRECT_PAGE));     | 
  
            
  
    | 328 | 
    
            
    
     | 
    
              } else {     | 
  
            
  
    | 329 | 
    
           0
    
     | 
    
              fail("Found document search result row with document type '" + documentTypeValue.getValue() + "' that should not have existed");     | 
  
            
  
    | 330 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 331 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 332 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 333 | 
    
            
    
     | 
    
           | 
  
            
  
    | 334 | 
    
            
    
     | 
    
               | 
  
            
  
    | 335 | 
    
            
    
     | 
    
           | 
  
            
  
    | 336 | 
    
            
    
     | 
    
      @throws     | 
  
            
  
    | 337 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 92 (92) | 
           Complexity: 12 | 
           Complexity Density: 0.17 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 338 | 
    
           0
    
     | 
    
           @Test public void testDocSearch_WildcardsOnRegularAttributes() throws Exception {...     | 
  
            
  
    | 339 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 340 | 
    
            
    
     | 
    
           | 
  
            
  
    | 341 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 342 | 
    
           0
    
     | 
    
              String docTypeName = "SearchDocType";     | 
  
            
  
    | 343 | 
    
           0
    
     | 
    
              String[] principalNames = {"bmcgough", "quickstart", "rkirkend"};     | 
  
            
  
    | 344 | 
    
           0
    
     | 
    
              String[] titles = {"The New Doc", "Document Number 2", "Some New Document"};     | 
  
            
  
    | 345 | 
    
           0
    
     | 
    
              String[] docIds = new String[titles.length];     | 
  
            
  
    | 346 | 
    
           0
    
     | 
    
              String[] appDocIds = {"6543", "5432", "4321"};     | 
  
            
  
    | 347 | 
    
           0
    
     | 
    
              String[] approverNames = {null, "jhopf", null};     | 
  
            
  
    | 348 | 
    
           0
    
     | 
    
              for (int i = 0; i < titles.length; i++) {     | 
  
            
  
    | 349 | 
    
           0
    
     | 
    
                  WorkflowDocument workflowDocument = new WorkflowDocument(     | 
  
            
  
    | 350 | 
    
            
    
     | 
    
                          KIMServiceLocator.getPersonService().getPersonByPrincipalName(principalNames[i]).getPrincipalId(), docTypeName);     | 
  
            
  
    | 351 | 
    
           0
    
     | 
    
                  workflowDocument.setTitle(titles[i]);     | 
  
            
  
    | 352 | 
    
           0
    
     | 
    
                  workflowDocument.setAppDocId(appDocIds[i]);     | 
  
            
  
    | 353 | 
    
           0
    
     | 
    
                  workflowDocument.routeDocument("routing this document.");     | 
  
            
  
    | 354 | 
    
           0
    
     | 
    
                  docIds[i] = workflowDocument.getRouteHeaderId().toString();     | 
  
            
  
    | 355 | 
    
           0
    
     | 
    
                  if (approverNames[i] != null) {     | 
  
            
  
    | 356 | 
    
           0
    
     | 
    
                      workflowDocument.setPrincipalId(KIMServiceLocator.getPersonService().getPersonByPrincipalName(approverNames[i]).getPrincipalId());     | 
  
            
  
    | 357 | 
    
           0
    
     | 
    
                      workflowDocument.approve("approving this document.");     | 
  
            
  
    | 358 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 359 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 360 | 
    
           0
    
     | 
    
              String principalId = KIMServiceLocator.getPersonService().getPersonByPrincipalName("bmcgough").getPrincipalId();     | 
  
            
  
    | 361 | 
    
           0
    
     | 
    
              DocSearchCriteriaDTO criteria = null;     | 
  
            
  
    | 362 | 
    
           0
    
     | 
    
              List<DocumentSearchResult> searchResults = null;     | 
  
            
  
    | 363 | 
    
           0
    
     | 
    
              DocumentSearchResultComponents result = null;     | 
  
            
  
    | 364 | 
    
            
    
     | 
    
           | 
  
            
  
    | 365 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 366 | 
    
           0
    
     | 
    
              String[] searchStrings = {"!quickstart", "!rkirkend!bmcgough", "!quickstart&&!rkirkend", "!admin", "user1", "quickstart|bmcgough",     | 
  
            
  
    | 367 | 
    
            
    
     | 
    
                      "admin|rkirkend", ">bmcgough", ">=rkirkend", "<bmcgough", "<=quickstart", ">bmcgough&&<=rkirkend", "<rkirkend&&!bmcgough",     | 
  
            
  
    | 368 | 
    
            
    
     | 
    
                      "?mc?oug?", "*t", "*i?k*", "*", "!quick*", "!b???????!?kirk???", "!*g*&&!*k*", ">bmc?ough", "<=quick*", "quickstart..rkirkend"};     | 
  
            
  
    | 369 | 
    
           0
    
     | 
    
              int[] expectedResults = {2, 1, 1, 3, 0, 2, 1, 2, 1, 0, 2, 2, 1, 1, 1, 2, 3, 2, 1, 0, 2, 1, 2};     | 
  
            
  
    | 370 | 
    
           0
    
     | 
    
              for (int i = 0; i < searchStrings.length; i++) {     | 
  
            
  
    | 371 | 
    
           0
    
     | 
    
                  criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 372 | 
    
           0
    
     | 
    
                  criteria.setInitiator(searchStrings[i]);     | 
  
            
  
    | 373 | 
    
           0
    
     | 
    
                  result = docSearchService.getList(principalId, criteria);     | 
  
            
  
    | 374 | 
    
           0
    
     | 
    
                  searchResults = result.getSearchResults();     | 
  
            
  
    | 375 | 
    
           0
    
     | 
    
                  assertEquals("Initiator search at index " + i + " retrieved the wrong number of documents.", expectedResults[i], searchResults.size());     | 
  
            
  
    | 376 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 377 | 
    
            
    
     | 
    
           | 
  
            
  
    | 378 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 379 | 
    
           0
    
     | 
    
              searchStrings = new String[] {"jhopf","!jhopf", ">jhopf", "<jjopf", ">=quickstart", "<=jhopf", "jhope..jhopg", "?hopf", "*i*", "!*f", "j*"};     | 
  
            
  
    | 380 | 
    
           0
    
     | 
    
              expectedResults = new int[] {1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1};     | 
  
            
  
    | 381 | 
    
           0
    
     | 
    
              for (int i = 0; i < searchStrings.length; i++) {     | 
  
            
  
    | 382 | 
    
           0
    
     | 
    
                  criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 383 | 
    
           0
    
     | 
    
                  criteria.setApprover(searchStrings[i]);     | 
  
            
  
    | 384 | 
    
           0
    
     | 
    
                  result = docSearchService.getList(principalId, criteria);     | 
  
            
  
    | 385 | 
    
           0
    
     | 
    
                  searchResults = result.getSearchResults();     | 
  
            
  
    | 386 | 
    
           0
    
     | 
    
                  assertEquals("Approver search at index " + i + " retrieved the wrong number of documents.", expectedResults[i], searchResults.size());     | 
  
            
  
    | 387 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 388 | 
    
            
    
     | 
    
           | 
  
            
  
    | 389 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 390 | 
    
           0
    
     | 
    
              searchStrings = new String[] {"!"+docIds[0], docIds[1]+"|"+docIds[2], "<="+docIds[1], ">="+docIds[2], "<"+docIds[0]+"&&>"+docIds[2],     | 
  
            
  
    | 391 | 
    
            
    
     | 
    
                      ">"+docIds[1], "<"+docIds[2]+"&&!"+docIds[0], docIds[0]+".."+docIds[2], "?"+docIds[1]+"*", "?9*7"};     | 
  
            
  
    | 392 | 
    
           0
    
     | 
    
              expectedResults = new int[] {1, 2, 2, 1, 0, 1, 1, 3, 1, 0};     | 
  
            
  
    | 393 | 
    
           0
    
     | 
    
              for (int i = 0; i < searchStrings.length; i++) {     | 
  
            
  
    | 394 | 
    
           0
    
     | 
    
                  criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 395 | 
    
           0
    
     | 
    
                  criteria.setRouteHeaderId(searchStrings[i]);     | 
  
            
  
    | 396 | 
    
           0
    
     | 
    
                  result = docSearchService.getList(principalId, criteria);     | 
  
            
  
    | 397 | 
    
           0
    
     | 
    
                  searchResults = result.getSearchResults();     | 
  
            
  
    | 398 | 
    
           0
    
     | 
    
                  assertEquals("Doc ID search at index " + i + " retrieved the wrong number of documents.", expectedResults[i], searchResults.size());     | 
  
            
  
    | 399 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 400 | 
    
            
    
     | 
    
           | 
  
            
  
    | 401 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 402 | 
    
           0
    
     | 
    
              searchStrings = new String[] {"6543", "5432|4321", ">4321", "<=5432", ">=6543", "<3210", "!3210", "!5432", "!4321!5432", ">4321&&!6543",     | 
  
            
  
    | 403 | 
    
            
    
     | 
    
                      "*5?3*", "*", "?3?1", "!*43*", "!???2", ">43*1", "<=5432&&!?32?", "5432..6543"};     | 
  
            
  
    | 404 | 
    
           0
    
     | 
    
              expectedResults = new int[] {1, 2, 2, 2, 1, 0, 3, 2, 1, 1, 2, 3, 1, 0, 2, 3, 1, 2};     | 
  
            
  
    | 405 | 
    
           0
    
     | 
    
              for (int i = 0; i < searchStrings.length; i++) {     | 
  
            
  
    | 406 | 
    
           0
    
     | 
    
                  criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 407 | 
    
           0
    
     | 
    
                  criteria.setAppDocId(searchStrings[i]);     | 
  
            
  
    | 408 | 
    
           0
    
     | 
    
                  result = docSearchService.getList(principalId, criteria);     | 
  
            
  
    | 409 | 
    
           0
    
     | 
    
                  searchResults = result.getSearchResults();     | 
  
            
  
    | 410 | 
    
           0
    
     | 
    
                  if(expectedResults[i] !=  searchResults.size()){                     | 
  
            
  
    | 411 | 
    
           0
    
     | 
    
                      assertEquals("App doc ID search at index " + i + " retrieved the wrong number of documents.", expectedResults[i], searchResults.size());     | 
  
            
  
    | 412 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 413 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 414 | 
    
            
    
     | 
    
           | 
  
            
  
    | 415 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 416 | 
    
           0
    
     | 
    
              searchStrings = new String[] {"jhopf","!jhopf", ">jhopf", "<jjopf", ">=quickstart", "<=jhopf", "jhope..jhopg", "?hopf", "*i*", "!*f", "j*"};     | 
  
            
  
    | 417 | 
    
           0
    
     | 
    
              expectedResults = new int[] {3, 0, 0, 3, 0, 3, 3, 3, 0, 0, 3};     | 
  
            
  
    | 418 | 
    
           0
    
     | 
    
              for (int i = 0; i < searchStrings.length; i++) {     | 
  
            
  
    | 419 | 
    
           0
    
     | 
    
                  criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 420 | 
    
           0
    
     | 
    
                  criteria.setViewer(searchStrings[i]);     | 
  
            
  
    | 421 | 
    
           0
    
     | 
    
                  result = docSearchService.getList(principalId, criteria);     | 
  
            
  
    | 422 | 
    
           0
    
     | 
    
                  searchResults = result.getSearchResults();     | 
  
            
  
    | 423 | 
    
           0
    
     | 
    
                  if(expectedResults[i] !=  searchResults.size()){                     | 
  
            
  
    | 424 | 
    
           0
    
     | 
    
                      assertEquals("Viewer search at index " + i + " retrieved the wrong number of documents.", expectedResults[i], searchResults.size());     | 
  
            
  
    | 425 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 426 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 427 | 
    
            
    
     | 
    
           | 
  
            
  
    | 428 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 429 | 
    
           0
    
     | 
    
              searchStrings = new String[] {"Some New Document", "Document Number 2|The New Doc", "!The New Doc", "!Some New Document!Document Number 2",     | 
  
            
  
    | 430 | 
    
            
    
     | 
    
                      "!The New Doc&&!Some New Document", ">Document Number 2", "<=Some New Document", ">=The New Doc&&<Some New Document", ">A New Doc",     | 
  
            
  
    | 431 | 
    
            
    
     | 
    
                      "<Some New Document|The New Doc", ">=Document Number 2&&!Some New Document", "*Docu??nt*", "*New*", "The ??? Doc", "*Doc*", "*Number*",     | 
  
            
  
    | 432 | 
    
            
    
     | 
    
                      "Some New Document..The New Doc", "Document..The", "*New*&&!*Some*", "!The ??? Doc|!*New*"};     | 
  
            
  
    | 433 | 
    
           0
    
     | 
    
              expectedResults = new int[] {1, 2, 2, 1, 1, 2, 2, 0, 3, 2, 2, 2, 2, 1, 3, 1, 2, 2, 1, 2};     | 
  
            
  
    | 434 | 
    
           0
    
     | 
    
              for (int i = 0; i < searchStrings.length; i++) {     | 
  
            
  
    | 435 | 
    
           0
    
     | 
    
                  criteria = new DocSearchCriteriaDTO();     | 
  
            
  
    | 436 | 
    
           0
    
     | 
    
                  criteria.setDocTitle(searchStrings[i]);     | 
  
            
  
    | 437 | 
    
           0
    
     | 
    
                  result = docSearchService.getList(principalId, criteria);     | 
  
            
  
    | 438 | 
    
           0
    
     | 
    
                  searchResults = result.getSearchResults();     | 
  
            
  
    | 439 | 
    
           0
    
     | 
    
                  if(expectedResults[i] !=  searchResults.size()){     | 
  
            
  
    | 440 | 
    
           0
    
     | 
    
                      assertEquals("Doc title search at index " + i + " retrieved the wrong number of documents.", expectedResults[i], searchResults.size());     | 
  
            
  
    | 441 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 442 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 443 | 
    
            
    
     | 
    
           | 
  
            
  
    | 444 | 
    
            
    
     | 
    
           | 
  
            
  
    | 445 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 446 | 
    
            
    
     | 
    
               | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 447 | 
    
           0
    
     | 
    
           private String getPrincipalId(String principalName) {...     | 
  
            
  
    | 448 | 
    
           0
    
     | 
    
              return KIMServiceLocator.getIdentityManagementService().getPrincipalByPrincipalName(principalName).getPrincipalId();     | 
  
            
  
    | 449 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 450 | 
    
            
    
     | 
    
      }     |