use of org.apache.ignite.internal.commandline.cache.CacheCommands in project ignite by apache.
the class CommandHandlerParsingTest method testFindAndDeleteGarbage.
/**
*/
@Test
public void testFindAndDeleteGarbage() {
String nodeId = UUID.randomUUID().toString();
String delete = FindAndDeleteGarbageArg.DELETE.toString();
String groups = "group1,grpoup2,group3";
List<List<String>> lists = generateArgumentList(FIND_AND_DELETE_GARBAGE.text(), new T2<>(nodeId, false), new T2<>(delete, false), new T2<>(groups, false));
for (List<String> list : lists) {
ConnectionAndSslParameters args = parseArgs(list);
assertTrue(args.command() instanceof CacheCommands);
CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
FindAndDeleteGarbage.Arguments arg = (FindAndDeleteGarbage.Arguments) subcommand.subcommand().arg();
if (list.contains(nodeId))
assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId().toString());
else
assertNull(arg.nodeId());
assertEquals(list.contains(delete), arg.delete());
if (list.contains(groups))
assertEquals(3, arg.groups().size());
else
assertNull(arg.groups());
}
}
use of org.apache.ignite.internal.commandline.cache.CacheCommands in project ignite by apache.
the class CommandHandlerParsingTest method testValidateIndexArguments.
/**
* validate_indexes command arguments parsing and validation
*/
@Test
public void testValidateIndexArguments() {
// happy case for all parameters
try {
int expectedCheckFirst = 10;
int expectedCheckThrough = 11;
UUID nodeId = UUID.randomUUID();
ConnectionAndSslParameters args = parseArgs(asList(CACHE.text(), VALIDATE_INDEXES.text(), "cache1, cache2", nodeId.toString(), CHECK_FIRST.toString(), Integer.toString(expectedCheckFirst), CHECK_THROUGH.toString(), Integer.toString(expectedCheckThrough)));
assertTrue(args.command() instanceof CacheCommands);
CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
CacheValidateIndexes.Arguments arg = (CacheValidateIndexes.Arguments) subcommand.subcommand().arg();
assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId());
assertEquals("checkFirst parameter unexpected value", expectedCheckFirst, arg.checkFirst());
assertEquals("checkThrough parameter unexpected value", expectedCheckThrough, arg.checkThrough());
} catch (IllegalArgumentException e) {
fail("Unexpected exception: " + e);
}
try {
int expectedParam = 11;
UUID nodeId = UUID.randomUUID();
ConnectionAndSslParameters args = parseArgs(asList(CACHE.text(), VALIDATE_INDEXES.text(), nodeId.toString(), CHECK_THROUGH.toString(), Integer.toString(expectedParam)));
assertTrue(args.command() instanceof CacheCommands);
CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
CacheValidateIndexes.Arguments arg = (CacheValidateIndexes.Arguments) subcommand.subcommand().arg();
assertNull("caches weren't specified, null value expected", arg.caches());
assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId());
assertEquals("checkFirst parameter unexpected value", -1, arg.checkFirst());
assertEquals("checkThrough parameter unexpected value", expectedParam, arg.checkThrough());
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
assertParseArgsThrows("Value for '--check-first' property should be positive.", CACHE.text(), VALIDATE_INDEXES.text(), CHECK_FIRST.toString(), "0");
assertParseArgsThrows("Numeric value for '--check-through' parameter expected.", CACHE.text(), VALIDATE_INDEXES.text(), CHECK_THROUGH.toString());
}
Aggregations