use of java.util.Arrays.stream in project ignite by apache.
the class GridCommandHandlerClusterByClassTest method testCacheDistribution.
/**
*/
@Test
public void testCacheDistribution() {
Ignite ignite = crd;
createCacheAndPreload(ignite, 100);
injectTestSystemOut();
// Run distribution for all node and all cache
assertEquals(EXIT_CODE_OK, execute("--cache", "distribution", "null"));
String out = testOut.toString();
// Result include info by cache "default"
assertContains(log, out, "[next group: id=1544803905, name=default]");
// Result include info by cache "ignite-sys-cache"
assertContains(log, out, "[next group: id=-2100569601, name=ignite-sys-cache]");
// Run distribution for all node and all cache and include additional user attribute
assertEquals(EXIT_CODE_OK, execute("--cache", "distribution", "null", "--user-attributes", "ZONE,CELL,DC"));
out += "\n" + testOut.toString();
List<String> outLines = Arrays.stream(out.split("\n")).map(String::trim).collect(toList());
int firstIndex = outLines.indexOf("[next group: id=1544803905, name=default]");
int lastIndex = outLines.lastIndexOf("[next group: id=1544803905, name=default]");
String dataLine = outLines.get(firstIndex + 1);
String userArrtDataLine = outLines.get(lastIndex + 1);
long commaNum = dataLine.chars().filter(i -> i == ',').count();
long userArrtCommaNum = userArrtDataLine.chars().filter(i -> i == ',').count();
// Check that number of columns increased by 3
assertEquals(3, userArrtCommaNum - commaNum);
}
Aggregations