generator.facet.test.ProcessorTest.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of component-starter-server Show documentation
Show all versions of component-starter-server Show documentation
Web application allowing to generate maven or gradle project skeleton to speed up component
development.
package {{classPackage}};
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
{{#outputBranches.size}}
import java.util.List;
{{/outputBranches.size}}
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
{{#isGeneric}}
import org.talend.sdk.component.api.record.Record;
{{/isGeneric}}
import org.talend.sdk.component.junit.JoinInputFactory;
import org.talend.sdk.component.junit.SimpleComponentRule;
import org.talend.sdk.component.runtime.output.Processor;
public class {{testClassName}} {
@ClassRule
public static final SimpleComponentRule COMPONENT_FACTORY = new SimpleComponentRule("{{rootPackage}}");
@Test
@Ignore("You need to complete this test")
public void map() throws IOException {
// {{#isOutput}}Output{{/isOutput}}{{^isOutput}}Processor{{/isOutput}} configuration
// Setup your component configuration for the test here
final {{configurationClassName}} configuration = new {{configurationClassName}}(){{^hasConfig}};{{/hasConfig}}
{{#configFields}}
{{#first}}/* {{/first}}{{^first}} {{/first}}.set{{value}}(){{#last}} */;{{/last}}
{{/configFields}}
// We create the component processor instance using the configuration filled above
final Processor processor = COMPONENT_FACTORY.createProcessor({{processorClassName}}.class, configuration);
// The join input factory construct inputs test data for every input branch you have defined for this component
// Make sure to fil in some test data for the branches you want to test
// You can also remove the branches that you don't need from the factory below
final JoinInputFactory joinInputFactory = new JoinInputFactory()
{{#inputBranches}}
.withInput("{{value.key}}", asList(/* TODO - list of your input data for this branch. Instances of {{value.value}}.class */)){{#last}};{{/last}}
{{/inputBranches}}
// Run the flow and get the outputs
final SimpleComponentRule.Outputs outputs = COMPONENT_FACTORY.collect(processor, joinInputFactory);
// TODO - Test Asserts
assertEquals({{outputBranches.size}}, outputs.size()); // test of the output branches count of the component
{{^isOutput}}
// Here you have all your processor output branches
// You can fill in the expected data for every branch to test them
{{#outputBranches}}
final List<{{value.value}}> value_{{value.key}} = outputs.get({{value.value}}.class, "{{value.key}}");
assertEquals(asList(/* TODO - give a list of your expected values here. Instances of {{value.value}}.class */), value_{{value.key}});
{{/outputBranches}}
{{/isOutput}}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy