Search in sources :

Example 1 with Functions

use of org.apache.pulsar.client.admin.Functions in project incubator-pulsar by apache.

the class CmdFunctionsTest method setup.

@BeforeMethod
public void setup() throws Exception {
    this.admin = mock(PulsarAdminWithFunctions.class);
    this.functions = mock(Functions.class);
    when(admin.functions()).thenReturn(functions);
    when(admin.getServiceUrl()).thenReturn(URI.create("http://localhost:1234").toURL());
    when(admin.getClientConf()).thenReturn(new ClientConfigurationData());
    this.cmd = new CmdFunctions(admin);
    // mock reflections
    mockStatic(Reflections.class);
    when(Reflections.classExistsInJar(any(File.class), anyString())).thenReturn(true);
    when(Reflections.classExists(anyString())).thenReturn(true);
    when(Reflections.classInJarImplementsIface(any(File.class), anyString(), eq(Function.class))).thenReturn(true);
    when(Reflections.classImplementsIface(anyString(), any())).thenReturn(true);
    when(Reflections.createInstance(eq(DummyFunction.class.getName()), any(File.class))).thenReturn(new DummyFunction());
    when(Reflections.createInstance(eq(DefaultSerDe.class.getName()), any(File.class))).thenReturn(new DefaultSerDe(String.class));
}
Also used : ClientConfigurationData(org.apache.pulsar.client.impl.conf.ClientConfigurationData) PulsarAdminWithFunctions(org.apache.pulsar.client.admin.PulsarAdminWithFunctions) DeleteFunction(org.apache.pulsar.admin.cli.CmdFunctions.DeleteFunction) GetFunction(org.apache.pulsar.admin.cli.CmdFunctions.GetFunction) UpdateFunction(org.apache.pulsar.admin.cli.CmdFunctions.UpdateFunction) CreateFunction(org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction) Function(org.apache.pulsar.functions.api.Function) DefaultSerDe(org.apache.pulsar.functions.api.utils.DefaultSerDe) PulsarAdminWithFunctions(org.apache.pulsar.client.admin.PulsarAdminWithFunctions) Functions(org.apache.pulsar.client.admin.Functions) ListFunctions(org.apache.pulsar.admin.cli.CmdFunctions.ListFunctions) Matchers.anyString(org.mockito.Matchers.anyString) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

File (java.io.File)1 CreateFunction (org.apache.pulsar.admin.cli.CmdFunctions.CreateFunction)1 DeleteFunction (org.apache.pulsar.admin.cli.CmdFunctions.DeleteFunction)1 GetFunction (org.apache.pulsar.admin.cli.CmdFunctions.GetFunction)1 ListFunctions (org.apache.pulsar.admin.cli.CmdFunctions.ListFunctions)1 UpdateFunction (org.apache.pulsar.admin.cli.CmdFunctions.UpdateFunction)1 Functions (org.apache.pulsar.client.admin.Functions)1 PulsarAdminWithFunctions (org.apache.pulsar.client.admin.PulsarAdminWithFunctions)1 ClientConfigurationData (org.apache.pulsar.client.impl.conf.ClientConfigurationData)1 Function (org.apache.pulsar.functions.api.Function)1 DefaultSerDe (org.apache.pulsar.functions.api.utils.DefaultSerDe)1 Matchers.anyString (org.mockito.Matchers.anyString)1 BeforeMethod (org.testng.annotations.BeforeMethod)1