Package org.talend.sdk.component.junit
Class BaseComponentsHandler
- java.lang.Object
-
- org.talend.sdk.component.junit.BaseComponentsHandler
-
- All Implemented Interfaces:
ComponentsHandler
- Direct Known Subclasses:
ComponentExtension
,SimpleComponentRule
public class BaseComponentsHandler extends Object implements ComponentsHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BaseComponentsHandler.EmbeddedComponentManager
static class
BaseComponentsHandler.Outputs
protected static class
BaseComponentsHandler.State
-
Field Summary
Fields Modifier and Type Field Description protected Collection<String>
isolatedPackages
protected String
packageName
protected static org.talend.sdk.component.junit.BaseComponentsHandler.Local<BaseComponentsHandler.State>
STATE
-
Constructor Summary
Constructors Constructor Description BaseComponentsHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ComponentManager
asManager()
<T> List<T>
collect(Class<T> recordType, String family, String component, int version, Map<String,String> configuration)
<T> Stream<T>
collect(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper, int maxRecords)
<T> Stream<T>
collect(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper, int maxRecords, int concurrency)
Collects data emitted from this mapper.BaseComponentsHandler.Outputs
collect(org.talend.sdk.component.runtime.output.Processor processor, ControllableInputFactory inputs)
BaseComponentsHandler.Outputs
collect(org.talend.sdk.component.runtime.output.Processor processor, ControllableInputFactory inputs, int bundleSize)
Collects all outputs of a processor.<T> List<T>
collectAsList(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper)
<T> List<T>
collectAsList(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper, int maxRecords)
org.talend.sdk.component.runtime.input.Mapper
createMapper(Class<?> componentType, Object configuration)
org.talend.sdk.component.runtime.output.Processor
createProcessor(Class<?> componentType, Object configuration)
<T> T
findService(Class<T> serviceClass)
<T> T
findService(String plugin, Class<T> serviceClass)
<T> List<T>
getCollectedData(Class<T> recordType)
Set<String>
getTestPlugins()
<T> T
injectServices(T instance)
<T> void
process(Iterable<T> inputs, String family, String component, int version, Map<String,String> configuration)
void
resetState()
<T> void
setInputData(Iterable<T> data)
BaseComponentsHandler.EmbeddedComponentManager
start()
BaseComponentsHandler
withIsolatedPackage(String packageName, String... packages)
-
-
-
Field Detail
-
STATE
protected static final org.talend.sdk.component.junit.BaseComponentsHandler.Local<BaseComponentsHandler.State> STATE
-
packageName
protected String packageName
-
isolatedPackages
protected Collection<String> isolatedPackages
-
-
Constructor Detail
-
BaseComponentsHandler
public BaseComponentsHandler()
-
-
Method Detail
-
injectServices
public <T> T injectServices(T instance)
- Specified by:
injectServices
in interfaceComponentsHandler
-
withIsolatedPackage
public BaseComponentsHandler withIsolatedPackage(String packageName, String... packages)
-
start
public BaseComponentsHandler.EmbeddedComponentManager start()
-
collect
public BaseComponentsHandler.Outputs collect(org.talend.sdk.component.runtime.output.Processor processor, ControllableInputFactory inputs)
- Specified by:
collect
in interfaceComponentsHandler
-
collect
public BaseComponentsHandler.Outputs collect(org.talend.sdk.component.runtime.output.Processor processor, ControllableInputFactory inputs, int bundleSize)
Collects all outputs of a processor.- Specified by:
collect
in interfaceComponentsHandler
- Parameters:
processor
- the processor to run while there are inputs.inputs
- the input factory, when an input will return null it will stop the processing.bundleSize
- the bundle size to use.- Returns:
- a map where the key is the output name and the value a stream of the output values.
-
collect
public <T> Stream<T> collect(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper, int maxRecords)
- Specified by:
collect
in interfaceComponentsHandler
-
collect
public <T> Stream<T> collect(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper, int maxRecords, int concurrency)
Collects data emitted from this mapper. If the split creates more than one mapper, it will create as much threads as mappers otherwise it will use the caller thread. IMPORTANT: don't forget to consume all the stream to ensure the underlying { @see org.talend.sdk.component.runtime.input.Input} is closed.- Specified by:
collect
in interfaceComponentsHandler
- Type Parameters:
T
- the returned type of the records of the mapper.- Parameters:
recordType
- the record type to use to type the returned type.mapper
- the mapper to go through.maxRecords
- maximum number of records, allows to stop the source when infinite.concurrency
- requested (1 can be used instead if <= 0) concurrency for the reader execution.- Returns:
- all the records emitted by the mapper.
-
collectAsList
public <T> List<T> collectAsList(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper)
- Specified by:
collectAsList
in interfaceComponentsHandler
-
collectAsList
public <T> List<T> collectAsList(Class<T> recordType, org.talend.sdk.component.runtime.input.Mapper mapper, int maxRecords)
- Specified by:
collectAsList
in interfaceComponentsHandler
-
createMapper
public org.talend.sdk.component.runtime.input.Mapper createMapper(Class<?> componentType, Object configuration)
- Specified by:
createMapper
in interfaceComponentsHandler
-
createProcessor
public org.talend.sdk.component.runtime.output.Processor createProcessor(Class<?> componentType, Object configuration)
- Specified by:
createProcessor
in interfaceComponentsHandler
-
collect
public <T> List<T> collect(Class<T> recordType, String family, String component, int version, Map<String,String> configuration)
- Specified by:
collect
in interfaceComponentsHandler
-
process
public <T> void process(Iterable<T> inputs, String family, String component, int version, Map<String,String> configuration)
- Specified by:
process
in interfaceComponentsHandler
-
asManager
public ComponentManager asManager()
- Specified by:
asManager
in interfaceComponentsHandler
-
findService
public <T> T findService(String plugin, Class<T> serviceClass)
- Specified by:
findService
in interfaceComponentsHandler
-
findService
public <T> T findService(Class<T> serviceClass)
- Specified by:
findService
in interfaceComponentsHandler
-
getTestPlugins
public Set<String> getTestPlugins()
-
setInputData
public <T> void setInputData(Iterable<T> data)
- Specified by:
setInputData
in interfaceComponentsHandler
-
getCollectedData
public <T> List<T> getCollectedData(Class<T> recordType)
- Specified by:
getCollectedData
in interfaceComponentsHandler
-
resetState
public void resetState()
-
-