Skip to content

Commit

Permalink
馃И #44 Add integration test for GetConnectorNamesCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
iabudiab authored and gunnarmorling committed Jan 22, 2022
1 parent 3f1d6b8 commit 5473c6a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@
import org.kcctl.util.ConfigurationContext;

import picocli.CommandLine.Command;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Spec;

@Command(name = "connector-name-completions", hidden = true)
public class ConnectorNamesCompletionCandidateCommand implements Runnable {

private final ConfigurationContext context;

@Spec
private CommandSpec spec;

@Inject
ConfigurationContext context;
public ConnectorNamesCompletionCandidateCommand(ConfigurationContext context) {
this.context = context;
}

@Override
public void run() {
Expand All @@ -38,6 +47,6 @@ public void run() {
.build(KafkaConnectApi.class);

List<String> connectors = kafkaConnectApi.getConnectors();
System.out.println(String.join(" ", connectors));
spec.commandLine().getOut().println(String.join(" ", connectors));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2021 The original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kcctl.command;

import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
import org.junit.jupiter.api.Test;
import org.kcctl.IntegrationTest;
import org.kcctl.support.InjectCommandContext;
import org.kcctl.support.KcctlCommandContext;

import io.quarkus.test.junit.QuarkusTest;
import picocli.CommandLine;

import static org.assertj.core.api.Assertions.assertThat;

@QuarkusTest
@DisplayNameGeneration(ReplaceUnderscores.class)
class ConnectorNamesCompletionCandidateCommandTest extends IntegrationTest {

@InjectCommandContext
KcctlCommandContext<ConnectorNamesCompletionCandidateCommand> context;

@Test
public void should_print_connector_names() {
registerTestConnector("test1");
registerTestConnector("test2");

int exitCode = context.commandLine().execute();
assertThat(exitCode).isEqualTo(CommandLine.ExitCode.OK);
assertThat(context.output().toString().trim())
.isEqualTo("test1 test2");
}
}

0 comments on commit 5473c6a

Please sign in to comment.