001/**
002 * Copyright (C) 2006-2022 Talend Inc. - www.talend.com
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.talend.sdk.component.junit;
017
018import java.util.List;
019import java.util.Map;
020import java.util.stream.Stream;
021
022import org.talend.sdk.component.runtime.input.Mapper;
023import org.talend.sdk.component.runtime.manager.ComponentManager;
024import org.talend.sdk.component.runtime.output.Processor;
025
026/**
027 * Test helper allowing you to manipulate mappers/processors unitarly.
028 */
029public interface ComponentsHandler {
030
031    BaseComponentsHandler.Outputs collect(Processor processor, ControllableInputFactory inputs);
032
033    BaseComponentsHandler.Outputs collect(Processor processor, ControllableInputFactory inputs, int bundleSize);
034
035    <T> Stream<T> collect(Class<T> recordType, Mapper mapper, int maxRecords);
036
037    <T> Stream<T> collect(Class<T> recordType, Mapper mapper, int maxRecords, int concurrency);
038
039    <T> List<T> collectAsList(Class<T> recordType, Mapper mapper);
040
041    <T> List<T> collectAsList(Class<T> recordType, Mapper mapper, int maxRecords);
042
043    Mapper createMapper(Class<?> componentType, Object configuration);
044
045    Processor createProcessor(Class<?> componentType, Object configuration);
046
047    <T> List<T> collect(Class<T> recordType, String family, String component, int version,
048            Map<String, String> configuration);
049
050    <T> void process(Iterable<T> inputs, String family, String component, int version,
051            Map<String, String> configuration);
052
053    ComponentManager asManager();
054
055    <T> void setInputData(Iterable<T> data);
056
057    <T> List<T> getCollectedData(Class<T> recordType);
058
059    <T> T findService(String plugin, Class<T> serviceClass);
060
061    <T> T findService(Class<T> serviceClass);
062
063    <T> T injectServices(T instance);
064}