in genie-client/src/integTest/java/com/netflix/genie/client/CommandClientIntegrationTest.java [72:182]
void testGetCommandsUsingParams() throws Exception {
final Set<String> command1Tags = Sets.newHashSet("foo", "pi");
final Set<String> command2Tags = Sets.newHashSet("bar", "pi");
final List<String> executableAndArgs = Lists.newArrayList("exec");
final Command command1 = new Command.Builder(
"command1name",
"command1user",
"1.0",
CommandStatus.ACTIVE,
executableAndArgs,
1000
)
.withTags(command1Tags)
.build();
final Command command2 =
new Command.Builder(
"command2name",
"command2user",
"2.0",
CommandStatus.INACTIVE,
executableAndArgs
)
.withTags(command2Tags)
.build();
final String command1Id = this.commandClient.createCommand(command1);
final String command2Id = this.commandClient.createCommand(command2);
// Test get by tags
Assertions
.assertThat(
this.commandClient.getCommands(
null, null, null, Lists.newArrayList("foo"), null, null, null, null
)
)
.hasSize(1)
.extracting(Command::getId)
.filteredOn(Optional::isPresent)
.extracting(Optional::get)
.containsExactly(command1Id);
Assertions
.assertThat(
this.commandClient.getCommands(
null, null, null, Lists.newArrayList("pi"), null, null, null, null
)
)
.hasSize(2)
.extracting(Command::getId)
.filteredOn(Optional::isPresent)
.extracting(Optional::get)
.containsExactly(command2Id, command1Id);
// Test get by name
Assertions
.assertThat(
this.commandClient.getCommands(
"command1name", null, null, null, null, null, null, null
)
)
.hasSize(1)
.extracting(Command::getId)
.filteredOn(Optional::isPresent)
.extracting(Optional::get)
.containsExactly(command1Id);
// Test get by status
Assertions
.assertThat(
this.commandClient.getCommands(
null, null, Lists.newArrayList(CommandStatus.ACTIVE.toString()), null, null, null, null, null
)
)
.hasSize(1)
.extracting(Command::getId)
.filteredOn(Optional::isPresent)
.extracting(Optional::get)
.containsExactly(command1Id);
final List<String> statuses = Lists.newArrayList(
CommandStatus.ACTIVE.toString(),
CommandStatus.INACTIVE.toString()
);
Assertions
.assertThat(
this.commandClient.getCommands(
null, null, statuses, null, null, null, null, null
)
)
.hasSize(2)
.extracting(Command::getId)
.filteredOn(Optional::isPresent)
.extracting(Optional::get)
.containsExactly(command2Id, command1Id);
// Test find by user
Assertions
.assertThat(
this.commandClient.getCommands(
null, "command2user", null, null
)
)
.hasSize(1)
.extracting(Command::getId)
.filteredOn(Optional::isPresent)
.extracting(Optional::get)
.containsExactly(command2Id);
}