Search in sources :

Example 1 with TaskApplication

use of org.apache.samza.application.TaskApplication in project samza by apache.

the class TestTaskApplicationDescriptorImpl method testProcessorLifecycleListener.

@Test
public void testProcessorLifecycleListener() {
    ProcessorLifecycleListenerFactory mockFactory = mock(ProcessorLifecycleListenerFactory.class);
    TaskApplication testApp = appDesc -> {
        appDesc.withProcessorLifecycleListenerFactory(mockFactory);
    };
    TaskApplicationDescriptorImpl appDesc = new TaskApplicationDescriptorImpl(testApp, config);
    assertEquals(appDesc.getProcessorLifecycleListenerFactory(), mockFactory);
}
Also used : InputDescriptor(org.apache.samza.system.descriptors.InputDescriptor) ApplicationContainerContextFactory(org.apache.samza.context.ApplicationContainerContextFactory) SystemDescriptor(org.apache.samza.system.descriptors.SystemDescriptor) TaskApplication(org.apache.samza.application.TaskApplication) TableDescriptor(org.apache.samza.table.descriptors.TableDescriptor) Set(java.util.Set) Test(org.junit.Test) TaskFactory(org.apache.samza.task.TaskFactory) Mockito.when(org.mockito.Mockito.when) ApplicationTaskContextFactory(org.apache.samza.context.ApplicationTaskContextFactory) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) HashSet(java.util.HashSet) List(java.util.List) BaseTableDescriptor(org.apache.samza.table.descriptors.BaseTableDescriptor) Optional(java.util.Optional) ProcessorLifecycleListenerFactory(org.apache.samza.runtime.ProcessorLifecycleListenerFactory) Config(org.apache.samza.config.Config) OutputDescriptor(org.apache.samza.system.descriptors.OutputDescriptor) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ProcessorLifecycleListenerFactory(org.apache.samza.runtime.ProcessorLifecycleListenerFactory) TaskApplication(org.apache.samza.application.TaskApplication) Test(org.junit.Test)

Example 2 with TaskApplication

use of org.apache.samza.application.TaskApplication in project samza by apache.

the class TestTaskApplicationDescriptorImpl method testApplicationContainerContextFactory.

@Test
public void testApplicationContainerContextFactory() {
    ApplicationContainerContextFactory factory = mock(ApplicationContainerContextFactory.class);
    TaskApplication testApp = appDesc -> appDesc.withApplicationContainerContextFactory(factory);
    TaskApplicationDescriptorImpl appSpec = new TaskApplicationDescriptorImpl(testApp, mock(Config.class));
    assertEquals(appSpec.getApplicationContainerContextFactory(), Optional.of(factory));
}
Also used : InputDescriptor(org.apache.samza.system.descriptors.InputDescriptor) ApplicationContainerContextFactory(org.apache.samza.context.ApplicationContainerContextFactory) SystemDescriptor(org.apache.samza.system.descriptors.SystemDescriptor) TaskApplication(org.apache.samza.application.TaskApplication) TableDescriptor(org.apache.samza.table.descriptors.TableDescriptor) Set(java.util.Set) Test(org.junit.Test) TaskFactory(org.apache.samza.task.TaskFactory) Mockito.when(org.mockito.Mockito.when) ApplicationTaskContextFactory(org.apache.samza.context.ApplicationTaskContextFactory) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) HashSet(java.util.HashSet) List(java.util.List) BaseTableDescriptor(org.apache.samza.table.descriptors.BaseTableDescriptor) Optional(java.util.Optional) ProcessorLifecycleListenerFactory(org.apache.samza.runtime.ProcessorLifecycleListenerFactory) Config(org.apache.samza.config.Config) OutputDescriptor(org.apache.samza.system.descriptors.OutputDescriptor) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ApplicationContainerContextFactory(org.apache.samza.context.ApplicationContainerContextFactory) Config(org.apache.samza.config.Config) TaskApplication(org.apache.samza.application.TaskApplication) Test(org.junit.Test)

Example 3 with TaskApplication

use of org.apache.samza.application.TaskApplication in project samza by apache.

the class TestTaskApplicationDescriptorImpl method testAddInputStreams.

@Test
public void testAddInputStreams() {
    TaskApplication testApp = appDesc -> {
        mockInputs.forEach(appDesc::withInputStream);
    };
    TaskApplicationDescriptorImpl appDesc = new TaskApplicationDescriptorImpl(testApp, config);
    assertEquals(mockInputs.toArray(), appDesc.getInputDescriptors().values().toArray());
}
Also used : InputDescriptor(org.apache.samza.system.descriptors.InputDescriptor) ApplicationContainerContextFactory(org.apache.samza.context.ApplicationContainerContextFactory) SystemDescriptor(org.apache.samza.system.descriptors.SystemDescriptor) TaskApplication(org.apache.samza.application.TaskApplication) TableDescriptor(org.apache.samza.table.descriptors.TableDescriptor) Set(java.util.Set) Test(org.junit.Test) TaskFactory(org.apache.samza.task.TaskFactory) Mockito.when(org.mockito.Mockito.when) ApplicationTaskContextFactory(org.apache.samza.context.ApplicationTaskContextFactory) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) HashSet(java.util.HashSet) List(java.util.List) BaseTableDescriptor(org.apache.samza.table.descriptors.BaseTableDescriptor) Optional(java.util.Optional) ProcessorLifecycleListenerFactory(org.apache.samza.runtime.ProcessorLifecycleListenerFactory) Config(org.apache.samza.config.Config) OutputDescriptor(org.apache.samza.system.descriptors.OutputDescriptor) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) TaskApplication(org.apache.samza.application.TaskApplication) Test(org.junit.Test)

Example 4 with TaskApplication

use of org.apache.samza.application.TaskApplication in project samza by apache.

the class TestTaskApplicationDescriptorImpl method testConstructor.

@Test
public void testConstructor() {
    TaskApplication mockApp = mock(TaskApplication.class);
    TaskApplicationDescriptorImpl appDesc = new TaskApplicationDescriptorImpl(mockApp, config);
    verify(mockApp).describe(appDesc);
    assertEquals(config, appDesc.getConfig());
}
Also used : TaskApplication(org.apache.samza.application.TaskApplication) Test(org.junit.Test)

Example 5 with TaskApplication

use of org.apache.samza.application.TaskApplication in project samza by apache.

the class TestTaskApplicationDescriptorImpl method testApplicationTaskContextFactory.

@Test
public void testApplicationTaskContextFactory() {
    ApplicationTaskContextFactory factory = mock(ApplicationTaskContextFactory.class);
    TaskApplication testApp = appDesc -> appDesc.withApplicationTaskContextFactory(factory);
    TaskApplicationDescriptorImpl appSpec = new TaskApplicationDescriptorImpl(testApp, mock(Config.class));
    assertEquals(appSpec.getApplicationTaskContextFactory(), Optional.of(factory));
}
Also used : InputDescriptor(org.apache.samza.system.descriptors.InputDescriptor) ApplicationContainerContextFactory(org.apache.samza.context.ApplicationContainerContextFactory) SystemDescriptor(org.apache.samza.system.descriptors.SystemDescriptor) TaskApplication(org.apache.samza.application.TaskApplication) TableDescriptor(org.apache.samza.table.descriptors.TableDescriptor) Set(java.util.Set) Test(org.junit.Test) TaskFactory(org.apache.samza.task.TaskFactory) Mockito.when(org.mockito.Mockito.when) ApplicationTaskContextFactory(org.apache.samza.context.ApplicationTaskContextFactory) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) HashSet(java.util.HashSet) List(java.util.List) BaseTableDescriptor(org.apache.samza.table.descriptors.BaseTableDescriptor) Optional(java.util.Optional) ProcessorLifecycleListenerFactory(org.apache.samza.runtime.ProcessorLifecycleListenerFactory) Config(org.apache.samza.config.Config) OutputDescriptor(org.apache.samza.system.descriptors.OutputDescriptor) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ApplicationTaskContextFactory(org.apache.samza.context.ApplicationTaskContextFactory) Config(org.apache.samza.config.Config) TaskApplication(org.apache.samza.application.TaskApplication) Test(org.junit.Test)

Aggregations

TaskApplication (org.apache.samza.application.TaskApplication)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)9 List (java.util.List)9 Optional (java.util.Optional)9 Set (java.util.Set)9 Config (org.apache.samza.config.Config)9 ApplicationContainerContextFactory (org.apache.samza.context.ApplicationContainerContextFactory)9 ApplicationTaskContextFactory (org.apache.samza.context.ApplicationTaskContextFactory)9 ProcessorLifecycleListenerFactory (org.apache.samza.runtime.ProcessorLifecycleListenerFactory)9 InputDescriptor (org.apache.samza.system.descriptors.InputDescriptor)9 OutputDescriptor (org.apache.samza.system.descriptors.OutputDescriptor)9 SystemDescriptor (org.apache.samza.system.descriptors.SystemDescriptor)9 BaseTableDescriptor (org.apache.samza.table.descriptors.BaseTableDescriptor)9 TableDescriptor (org.apache.samza.table.descriptors.TableDescriptor)9 TaskFactory (org.apache.samza.task.TaskFactory)9 Assert.assertEquals (org.junit.Assert.assertEquals)9 Before (org.junit.Before)9 Mockito.mock (org.mockito.Mockito.mock)9