use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneIndexCommandsJUnitTest method verifyDestroyIndexCommandResult.
private void verifyDestroyIndexCommandResult(CommandResult result, List<CliFunctionResult> cliFunctionResults, String expectedStatus) {
assertEquals(Status.OK, result.getStatus());
TabularResultData data = (TabularResultData) result.getResultData();
List<String> members = data.retrieveAllValues("Member");
assertEquals(cliFunctionResults.size(), members.size());
// Verify each member
for (int i = 0; i < members.size(); i++) {
assertEquals("member" + i, members.get(i));
}
// Verify each status
List<String> status = data.retrieveAllValues("Status");
for (String statu : status) {
assertEquals(expectedStatus, statu);
}
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneIndexCommandsDUnitTest method searchWithoutFieldNameShouldReturnCorrectResults.
@Test
public void searchWithoutFieldNameShouldReturnCorrectResults() throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
createIndex(vm1);
Map<String, TestObject> entries = new HashMap<>();
entries.put("A", new TestObject("value1 ", "value2", "value3"));
entries.put("B", new TestObject("ABC", "EFG", "HIJ"));
entries.put("C", new TestObject("value1", "QWE", "RTY"));
entries.put("D", new TestObject("ABC", "EFG", "HIJ"));
entries.put("E", new TestObject("value1", "ABC", "EFG"));
entries.put("F", new TestObject("ABC", "EFG", "HIJ"));
entries.put("G", new TestObject("value1", "JKR", "POW"));
entries.put("H", new TestObject("ABC", "EFG", "H2J"));
putEntries(vm1, entries, 8);
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "QWE");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field2");
executeCommandAndLogResult(csb);
TabularResultData data = (TabularResultData) executeCommandAndGetResult(csb).getResultData();
assertEquals(1, data.retrieveAllValues("key").size());
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneIndexCommandsDUnitTest method searchShouldReturnCorrectResults.
@Test
public void searchShouldReturnCorrectResults() throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
createIndex(vm1);
Map<String, TestObject> entries = new HashMap<>();
entries.put("A", new TestObject("value1 ", "value2", "value3"));
entries.put("B", new TestObject("ABC", "EFG", "HIJ"));
entries.put("C", new TestObject("value1", "QWE", "RTY"));
entries.put("D", new TestObject("ABC", "EFG", "HIJ"));
entries.put("E", new TestObject("value1", "ABC", "EFG"));
entries.put("F", new TestObject("ABC", "EFG", "HIJ"));
entries.put("G", new TestObject(" value1", "JKR", "POW"));
entries.put("H", new TestObject("ABC", "EFG", "H2J"));
putEntries(vm1, entries, 8);
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
executeCommandAndLogResult(csb);
TabularResultData data = (TabularResultData) executeCommandAndGetResult(csb).getResultData();
assertEquals(4, data.retrieveAllValues("key").size());
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneIndexCommandsJUnitTest method testSearchIndexWhenSearchResultsHaveSameScore.
@Test
public void testSearchIndexWhenSearchResultsHaveSameScore() throws Exception {
final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
HashSet<LuceneSearchResults> queryResults = new HashSet<>();
queryResults.add(createQueryResults("A", "Result1", 1));
queryResults.add(createQueryResults("B", "Result1", 1));
queryResults.add(createQueryResults("C", "Result1", 1));
queryResults.add(createQueryResults("D", "Result1", 1));
queryResults.add(createQueryResults("E", "Result1", 1));
queryResults.add(createQueryResults("F", "Result1", 1));
queryResults.add(createQueryResults("G", "Result1", 1));
queryResults.add(createQueryResults("H", "Result1", 1));
queryResults.add(createQueryResults("I", "Result1", 1));
queryResults.add(createQueryResults("J", "Result1", 1));
queryResults.add(createQueryResults("K", "Result1", 1));
queryResults.add(createQueryResults("L", "Result1", 1));
queryResults.add(createQueryResults("M", "Result1", 1));
queryResults.add(createQueryResults("N", "Result1", 1));
queryResults.add(createQueryResults("P", "Result1", 1));
queryResults.add(createQueryResults("Q", "Result1", 1));
queryResults.add(createQueryResults("R", "Result1", 1));
queryResults.add(createQueryResults("S", "Result1", 1));
queryResults.add(createQueryResults("T", "Result1", 1));
queryResultsList.add(queryResults);
doReturn(mockResultCollector).when(commands).executeSearch(isA(LuceneQueryInfo.class));
doReturn(queryResultsList).when(mockResultCollector).getResult();
CommandResult result = (CommandResult) commands.searchIndex("index", "region", "Result1", "field1", -1, true);
TabularResultData data = (TabularResultData) result.getResultData();
assertEquals(queryResults.size(), data.retrieveAllValues("key").size());
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class LuceneClusterConfigurationDUnitTest method verifyMemberWithGroupStartsAfterAlterRegion.
@Test
public void verifyMemberWithGroupStartsAfterAlterRegion() throws Exception {
// Start a member with no group
startNodeUsingClusterConfiguration(1);
// Start a member with group
String group = "group1";
Properties properties = new Properties();
properties.setProperty(GROUPS, group);
MemberVM vm2 = startNodeUsingClusterConfiguration(2, properties);
// Connect Gfsh to locator
gfshConnector.connectAndVerify(locator);
// Create index and region in no group
createLuceneIndexUsingGfsh();
createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, null);
// Alter region in group
CommandResult alterRegionResult = alterRegionUsingGfsh(group);
TabularResultData alterRegionResultData = (TabularResultData) alterRegionResult.getResultData();
List<String> alterRegionResultDataStatus = alterRegionResultData.retrieveAllValues("Status");
// Verify region is altered on only one server
assertEquals(1, alterRegionResultDataStatus.size());
assertEquals("Region \"/" + REGION_NAME + "\" altered on \"" + vm2.getName() + "\"", alterRegionResultDataStatus.get(0));
// Start another member with group
startNodeUsingClusterConfiguration(3, properties);
// Verify all members have indexes
CommandResult listIndexesResult = listIndexesUsingGfsh();
TabularResultData listIndexesResultData = (TabularResultData) listIndexesResult.getResultData();
List<String> listIndexesResultDataStatus = listIndexesResultData.retrieveAllValues("Status");
assertEquals(3, listIndexesResultDataStatus.size());
for (String status : listIndexesResultDataStatus) {
assertEquals("Initialized", status);
}
}
Aggregations