use of org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME_SECOND in project ignite by apache.
the class GridCommandHandlerIndexListTest method testCacheIndexList.
/**
* Tests --index name option and output correctness.
*/
@Test
public void testCacheIndexList() {
final String idxName = "PERSON_ORGID_ASC_IDX";
final int expectedLinesNum = 15;
final int expectedIndexDescrLinesNum = 2;
injectTestSystemOut();
final CommandHandler handler = new CommandHandler(createTestLogger());
assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--index-name", idxName));
String outStr = testOut.toString();
assertTrue(outStr.contains("grpName=" + GROUP_NAME + ", cacheName=" + CACHE_NAME + ", idxName=PERSON_ORGID_ASC_IDX, " + "colsNames=ArrayList [ORGID, _KEY], tblName=PERSON"));
assertTrue(outStr.contains("grpName=" + GROUP_NAME_SECOND + ", cacheName=" + CACHE_NAME_SECOND + ", idxName=PERSON_ORGID_ASC_IDX, colsNames=ArrayList [ORGID, _KEY], tblName=PERSON"));
final String[] outputLines = outStr.split("\n");
int outputLinesNum = outputLines.length;
assertEquals("Unexpected number of lines: " + outputLinesNum, outputLinesNum, expectedLinesNum);
long indexDescrLinesNum = Arrays.stream(outputLines).filter(s -> s.contains("grpName=")).count();
assertEquals("Unexpected number of index description lines: " + indexDescrLinesNum, indexDescrLinesNum, expectedIndexDescrLinesNum);
Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
assertNotNull(cmdResult);
final int resSetSize = cmdResult.size();
assertEquals("Unexpected result set size: " + resSetSize, resSetSize, 2);
boolean isResSetCorrect = cmdResult.stream().map(IndexListInfoContainer::indexName).allMatch((name) -> name.equals(idxName));
assertTrue("Unexpected result set", isResSetCorrect);
}
Aggregations