use of org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction in project incubator-pulsar by apache.
the class CmdFunctionsTest method testCreateWithoutFunctionName.
@Test
public void testCreateWithoutFunctionName() throws Exception {
String inputTopicName = TEST_NAME + "-input-topic";
String outputTopicName = TEST_NAME + "-output-topic";
cmd.run(new String[] { "create", "--inputs", inputTopicName, "--output", outputTopicName, "--jar", "SomeJar.jar", "--tenant", "sample", "--namespace", "ns1", "--className", DummyFunction.class.getName() });
CreateFunction creater = cmd.getCreater();
assertEquals("CmdFunctionsTest$DummyFunction", creater.getFunctionConfig().getName());
verify(functions, times(1)).createFunction(any(FunctionConfig.class), anyString());
}
use of org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction in project incubator-pulsar by apache.
the class CmdFunctionsTest method testCreateWithoutNamespace.
@Test
public void testCreateWithoutNamespace() throws Exception {
String fnName = TEST_NAME + "-function";
String inputTopicName = "persistent://tenant/standalone/namespace/input-topic";
String outputTopicName = "persistent://tenant/standalone/namespace/output-topic";
cmd.run(new String[] { "create", "--name", fnName, "--inputs", inputTopicName, "--output", outputTopicName, "--jar", "SomeJar.jar", "--className", DummyFunction.class.getName() });
CreateFunction creater = cmd.getCreater();
assertEquals("tenant", creater.getFunctionConfig().getTenant());
assertEquals("namespace", creater.getFunctionConfig().getNamespace());
verify(functions, times(1)).createFunction(any(FunctionConfig.class), anyString());
}
use of org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction in project incubator-pulsar by apache.
the class CmdFunctionsTest method testCreateWithoutOutputTopic.
@Test
public void testCreateWithoutOutputTopic() throws Exception {
String inputTopicName = TEST_NAME + "-input-topic";
cmd.run(new String[] { "create", "--inputs", inputTopicName, "--jar", "SomeJar.jar", "--tenant", "sample", "--namespace", "ns1", "--className", DummyFunction.class.getName() });
CreateFunction creater = cmd.getCreater();
assertEquals(inputTopicName + "-" + "CmdFunctionsTest$DummyFunction" + "-output", creater.getFunctionConfig().getOutput());
verify(functions, times(1)).createFunction(any(FunctionConfig.class), anyString());
}
use of org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction in project incubator-pulsar by apache.
the class CmdFunctionsTest method testCreateWithoutTenant.
@Test
public void testCreateWithoutTenant() throws Exception {
String fnName = TEST_NAME + "-function";
String inputTopicName = "persistent://tenant/standalone/namespace/input-topic";
String outputTopicName = "persistent://tenant/standalone/namespace/output-topic";
cmd.run(new String[] { "create", "--name", fnName, "--inputs", inputTopicName, "--output", outputTopicName, "--jar", "SomeJar.jar", "--namespace", "ns1", "--className", DummyFunction.class.getName() });
CreateFunction creater = cmd.getCreater();
assertEquals("tenant", creater.getFunctionConfig().getTenant());
verify(functions, times(1)).createFunction(any(FunctionConfig.class), anyString());
}
use of org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction in project incubator-pulsar by apache.
the class CmdFunctionsTest method testCreateFunction.
/*
TODO(sijie):- Can we fix this?
@Test
public void testLocalRunnerCmdSettings() throws Exception {
String fnName = TEST_NAME + "-function";
String sourceTopicName = TEST_NAME + "-source-topic";
String output = TEST_NAME + "-sink-topic";
cmd.run(new String[] {
"localrun",
"--name", fnName,
"--source-topics", sourceTopicName,
"--output", output
});
LocalRunner runner = cmd.getLocalRunner();
assertEquals(fnName, runner.getFunctionName());
assertEquals(sourceTopicName, runner.getInputs());
assertEquals(output, runner.getOutput());
assertNull(runner.getFnConfigFile());
}
@Test
public void testLocalRunnerCmdYaml() throws Exception {
URL yamlUrl = getClass().getClassLoader().getResource("test_function_config.yml");
String configFile = yamlUrl.getPath();
cmd.run(new String[] {
"localrun",
"--function-config", configFile
});
LocalRunner runner = cmd.getLocalRunner();
assertNull(runner.getFunctionName());
assertNull(runner.getInputs());
assertNull(runner.getOutput());
assertEquals(configFile, runner.getFnConfigFile());
}
*/
@Test
public void testCreateFunction() throws Exception {
String fnName = TEST_NAME + "-function";
String inputTopicName = TEST_NAME + "-input-topic";
String outputTopicName = TEST_NAME + "-output-topic";
cmd.run(new String[] { "create", "--name", fnName, "--inputs", inputTopicName, "--output", outputTopicName, "--jar", "SomeJar.jar", "--tenant", "sample", "--namespace", "ns1", "--className", DummyFunction.class.getName() });
CreateFunction creater = cmd.getCreater();
assertEquals(fnName, creater.getFunctionName());
assertEquals(inputTopicName, creater.getInputs());
assertEquals(outputTopicName, creater.getOutput());
verify(functions, times(1)).createFunction(any(FunctionConfig.class), anyString());
}
Aggregations