| 1 |
|
package org.kuali.student.common.search; |
| 2 |
|
|
| 3 |
|
import java.util.ArrayList; |
| 4 |
|
import java.util.List; |
| 5 |
|
|
| 6 |
|
import org.kuali.student.common.exceptions.DoesNotExistException; |
| 7 |
|
import org.kuali.student.common.exceptions.InvalidParameterException; |
| 8 |
|
import org.kuali.student.common.exceptions.MissingParameterException; |
| 9 |
|
import org.kuali.student.common.exceptions.OperationFailedException; |
| 10 |
|
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
| 11 |
|
import org.kuali.student.common.search.dto.SearchRequest; |
| 12 |
|
import org.kuali.student.common.search.dto.SearchResult; |
| 13 |
|
import org.kuali.student.common.search.dto.SearchResultCell; |
| 14 |
|
import org.kuali.student.common.search.dto.SearchResultRow; |
| 15 |
|
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
| 16 |
|
import org.kuali.student.common.search.dto.SearchTypeInfo; |
| 17 |
|
import org.kuali.student.common.search.service.SearchService; |
| 18 |
|
import org.kuali.student.common.search.service.impl.CrossSearchManager; |
| 19 |
|
import org.kuali.student.common.search.service.impl.SearchDispatcherImpl; |
| 20 |
|
import org.kuali.student.common.search.service.impl.SearchManagerImpl; |
| 21 |
|
|
|
|
|
| 0% |
Uncovered Elements: 81 (81) |
Complexity: 13 |
Complexity Density: 0.2 |
|
| 22 |
|
public class MockSearch implements SearchService { |
| 23 |
|
SearchManagerImpl sm; |
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 24 |
0
|
public MockSearch(){... |
| 25 |
0
|
sm = new SearchManagerImpl("classpath:test-cross-search.xml"); |
| 26 |
0
|
CrossSearchManager csm = new CrossSearchManager(); |
| 27 |
0
|
sm.setCrossSearchManager(csm); |
| 28 |
0
|
SearchDispatcherImpl sd = new SearchDispatcherImpl(); |
| 29 |
0
|
List<SearchService> services = new ArrayList<SearchService>(); |
| 30 |
0
|
services.add(this); |
| 31 |
0
|
sd.setServices(services); |
| 32 |
0
|
csm.setSearchDispatcher(sd); |
| 33 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 34 |
0
|
@Override... |
| 35 |
|
public List<SearchTypeInfo> getSearchTypes() |
| 36 |
|
throws OperationFailedException { |
| 37 |
0
|
return sm.getSearchTypes(); |
| 38 |
|
} |
| 39 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
0
|
@Override... |
| 41 |
|
public SearchTypeInfo getSearchType(String searchTypeKey) |
| 42 |
|
throws DoesNotExistException, InvalidParameterException, |
| 43 |
|
MissingParameterException, OperationFailedException { |
| 44 |
0
|
return sm.getSearchType(searchTypeKey); |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 47 |
0
|
@Override... |
| 48 |
|
public List<SearchTypeInfo> getSearchTypesByResult( |
| 49 |
|
String searchResultTypeKey) throws DoesNotExistException, |
| 50 |
|
InvalidParameterException, MissingParameterException, |
| 51 |
|
OperationFailedException { |
| 52 |
0
|
return sm.getSearchTypesByResult(searchResultTypeKey); |
| 53 |
|
} |
| 54 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 55 |
0
|
@Override... |
| 56 |
|
public List<SearchTypeInfo> getSearchTypesByCriteria( |
| 57 |
|
String searchCriteriaTypeKey) throws DoesNotExistException, |
| 58 |
|
InvalidParameterException, MissingParameterException, |
| 59 |
|
OperationFailedException { |
| 60 |
0
|
return sm.getSearchTypesByCriteria(searchCriteriaTypeKey); |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
0
|
@Override... |
| 64 |
|
public List<SearchResultTypeInfo> getSearchResultTypes() |
| 65 |
|
throws OperationFailedException { |
| 66 |
0
|
return sm.getSearchResultTypes(); |
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 69 |
0
|
@Override... |
| 70 |
|
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) |
| 71 |
|
throws DoesNotExistException, InvalidParameterException, |
| 72 |
|
MissingParameterException, OperationFailedException { |
| 73 |
0
|
return sm.getSearchResultType(searchResultTypeKey); |
| 74 |
|
} |
| 75 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 76 |
0
|
@Override... |
| 77 |
|
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() |
| 78 |
|
throws OperationFailedException { |
| 79 |
0
|
return sm.getSearchCriteriaTypes(); |
| 80 |
|
} |
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0
|
@Override... |
| 83 |
|
public SearchCriteriaTypeInfo getSearchCriteriaType( |
| 84 |
|
String searchCriteriaTypeKey) throws DoesNotExistException, |
| 85 |
|
InvalidParameterException, MissingParameterException, |
| 86 |
|
OperationFailedException { |
| 87 |
0
|
return sm.getSearchCriteriaType(searchCriteriaTypeKey); |
| 88 |
|
} |
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 4 |
Complexity Density: 0.08 |
|
| 90 |
0
|
@Override... |
| 91 |
|
public SearchResult search(SearchRequest searchRequest) |
| 92 |
|
throws MissingParameterException { |
| 93 |
0
|
if("test.search1".equals(searchRequest.getSearchKey())){ |
| 94 |
0
|
SearchResult searchResult = new SearchResult(); |
| 95 |
0
|
SearchResultRow row = new SearchResultRow(); |
| 96 |
0
|
SearchResultCell cell = new SearchResultCell(); |
| 97 |
0
|
cell.setKey("col1"); |
| 98 |
0
|
cell.setValue("value1-1"); |
| 99 |
0
|
row.getCells().add(cell); |
| 100 |
|
|
| 101 |
0
|
cell = new SearchResultCell(); |
| 102 |
0
|
cell.setKey("col2"); |
| 103 |
0
|
cell.setValue("value2-1"); |
| 104 |
0
|
row.getCells().add(cell); |
| 105 |
|
|
| 106 |
0
|
searchResult.getRows().add(row); |
| 107 |
|
|
| 108 |
0
|
row = new SearchResultRow(); |
| 109 |
0
|
cell = new SearchResultCell(); |
| 110 |
0
|
cell.setKey("col1"); |
| 111 |
0
|
cell.setValue("value1-2"); |
| 112 |
0
|
row.getCells().add(cell); |
| 113 |
|
|
| 114 |
0
|
cell = new SearchResultCell(); |
| 115 |
0
|
cell.setKey("col2"); |
| 116 |
0
|
cell.setValue("value2-2"); |
| 117 |
0
|
row.getCells().add(cell); |
| 118 |
|
|
| 119 |
0
|
searchResult.getRows().add(row); |
| 120 |
0
|
return searchResult; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
0
|
if("test.search2".equals(searchRequest.getSearchKey())){ |
| 124 |
0
|
SearchResult searchResult = new SearchResult(); |
| 125 |
0
|
SearchResultRow row = new SearchResultRow(); |
| 126 |
0
|
SearchResultCell cell = new SearchResultCell(); |
| 127 |
0
|
cell.setKey("C-A"); |
| 128 |
0
|
cell.setValue("Avalue1-1"); |
| 129 |
0
|
row.getCells().add(cell); |
| 130 |
|
|
| 131 |
0
|
cell = new SearchResultCell(); |
| 132 |
0
|
cell.setKey("C-B"); |
| 133 |
0
|
cell.setValue("Avalue2-1"); |
| 134 |
0
|
row.getCells().add(cell); |
| 135 |
|
|
| 136 |
0
|
searchResult.getRows().add(row); |
| 137 |
|
|
| 138 |
0
|
row = new SearchResultRow(); |
| 139 |
0
|
cell = new SearchResultCell(); |
| 140 |
0
|
cell.setKey("C-A"); |
| 141 |
0
|
cell.setValue("Avalue1-2"); |
| 142 |
0
|
row.getCells().add(cell); |
| 143 |
|
|
| 144 |
0
|
cell = new SearchResultCell(); |
| 145 |
0
|
cell.setKey("C-B"); |
| 146 |
0
|
cell.setValue("Avalue2-2"); |
| 147 |
0
|
row.getCells().add(cell); |
| 148 |
|
|
| 149 |
0
|
searchResult.getRows().add(row); |
| 150 |
0
|
return searchResult; |
| 151 |
0
|
}else if("test.crossSearch".equals(searchRequest.getSearchKey())){ |
| 152 |
0
|
return sm.search(searchRequest, null); |
| 153 |
|
} |
| 154 |
0
|
return null; |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
} |