public class TestPlan extends GenericTestPlan<eu.stratosphere.types.Record,TestRecords>
GenericDataSources and GenericDataSinks if not explicitly specified,
getExpectedOutput(Class, Class...), and
GenericTestPlan.getActualOutput().
// build plan
GenericDataSource<Key, Value> source = ...;
MapOperator<Key, Value, Key, Value> map = new MapOperator<Key, Value, Key, Value>(IdentityMap.class, "Map");
map.setInput(source);
GenericDataSink<Key, Value> output = ...;
output.setInput(map);
// configure test
TestPlan testPlan = new TestPlan(output);
testPlan.getExpectedOutput(output).fromFile(...);
testPlan.run();
Test plan with ad-hoc source and sink
// build plan
MapOperator<Key, Value, Key, Value> map = new MapOperator<Key, Value, Key, Value>(IdentityMap.class, "Map");
// configure test
TestPlan testPlan = new TestPlan(map);
testPlan.getInput().add(pair1).add(pair2).add(pair3);
testPlan.getExpectedOutput(output).add(pair1).add(pair2).add(pair3);
testPlan.run();
Access ad-hoc source and sink of Testplan
// build plan
MapOperator<Key, Value, Key, Value> map = new MapOperator<Key, Value, Key, Value>(IdentityMap.class, "Map");
// configure test
TestPlan testPlan = new TestPlan(map);
testPlan.getInput().add(randomInput1).add(randomInput2).add(randomInput3);
testPlan.run();
// custom assertions
Assert.assertEquals(testPlan.getInput(), testPlan.getOutput());
| Constructor and Description |
|---|
TestPlan(Collection<? extends eu.stratosphere.api.common.operators.Operator> contracts)
Initializes TestPlan for the given contracts.
|
TestPlan(eu.stratosphere.api.common.operators.Operator... contracts)
Initializes TestPlan for the given contracts.
|
| Modifier and Type | Method and Description |
|---|---|
protected TestRecords |
createTestRecords(TypeConfig<eu.stratosphere.types.Record> typeConfig)
Creates the concrete implementation of
GenericTestRecords for this plan. |
TestRecords |
getActualOutput(Class<? extends eu.stratosphere.types.Value>[] schema)
Returns the first actual output
TestRecords with the given schema of the TestPlan. |
TestRecords |
getExpectedOutput(Class<? extends eu.stratosphere.types.Value> values,
Class<?>... additionalFields)
Returns the expected output
TestRecords with the given schema of the TestPlan
associated with the given sink. |
TestRecords |
getExpectedOutput(eu.stratosphere.api.common.operators.GenericDataSink sink,
Class<? extends eu.stratosphere.types.Value>[] schema)
Returns the expected output
TestRecords with the given schema of the TestPlan
associated with the given sink. |
TestRecords |
getExpectedOutput(int sink,
Class<? extends eu.stratosphere.types.Value>[] schema)
Returns the expected output
TestRecords with the given schema of the TestPlan
associated with the given sink. |
Class<? extends eu.stratosphere.types.Value>[] |
getSchema()
Returns the schema.
|
void |
run()
Compiles the plan to an
Plan and executes it. |
void |
setSchema(Class<? extends eu.stratosphere.types.Value>[] schema)
Sets the default schema of all input and outputs.
|
void |
setSchema(Class<? extends eu.stratosphere.types.Value> firstField,
Class<?>... additionalFields)
Sets the default schema of all input and outputs.
|
TestPlan |
withSchema(Class<? extends eu.stratosphere.types.Value>[] schema)
Sets the default schema of all input and outputs.
|
TestPlan |
withSchema(Class<? extends eu.stratosphere.types.Value> firstField,
Class<?>... additionalFields)
Sets the default schema of all input and outputs.
|
close, createDefaultSink, createDefaultSource, createPlan, getActualOutput, getActualOutput, getActualOutput, getActualOutput, getActualOutput, getActualOutput, getDefaultConfig, getDegreeOfParallelism, getExpectedOutput, getExpectedOutput, getExpectedOutput, getInput, getInput, getInput, getInput, getInput, getOutputOfOperator, getOutputsOfOperator, getSinks, getSources, setDefaultConfig, setDegreeOfParallelismpublic TestPlan(Collection<? extends eu.stratosphere.api.common.operators.Operator> contracts)
public TestPlan(eu.stratosphere.api.common.operators.Operator... contracts)
public TestRecords getActualOutput(Class<? extends eu.stratosphere.types.Value>[] schema)
TestRecords with the given schema of the TestPlan.TestRecords of the TestPlanpublic TestRecords getExpectedOutput(Class<? extends eu.stratosphere.types.Value> values, Class<?>... additionalFields)
TestRecords with the given schema of the TestPlan
associated with the given sink. This is the recommended method to set expected
output records for more complex TestPlans.TestRecords of the TestPlan associated
with the given sinkpublic TestRecords getExpectedOutput(eu.stratosphere.api.common.operators.GenericDataSink sink, Class<? extends eu.stratosphere.types.Value>[] schema)
TestRecords with the given schema of the TestPlan
associated with the given sink. This is the recommended method to set expected
output records for more complex TestPlans.sink - the sink of which the associated expected output TestRecords
should be returnedTestRecords of the TestPlan associated
with the given sinkpublic TestRecords getExpectedOutput(int sink, Class<? extends eu.stratosphere.types.Value>[] schema)
TestRecords with the given schema of the TestPlan
associated with the given sink. This is the recommended method to set expected
output records for more complex TestPlans.sink - the sink of which the associated expected output TestRecords
should be returnedTestRecords of the TestPlan associated
with the given sinkpublic Class<? extends eu.stratosphere.types.Value>[] getSchema()
public void run()
GenericTestPlanPlan and executes it. If
expected values have been specified, the actual outputs values are
compared to the expected values.run in class GenericTestPlan<eu.stratosphere.types.Record,TestRecords>public void setSchema(Class<? extends eu.stratosphere.types.Value> firstField, Class<?>... additionalFields)
public void setSchema(Class<? extends eu.stratosphere.types.Value>[] schema)
schema - the schema to setpublic TestPlan withSchema(Class<? extends eu.stratosphere.types.Value> firstField, Class<?>... additionalFields)
public TestPlan withSchema(Class<? extends eu.stratosphere.types.Value>[] schema)
schema - the schema to setprotected TestRecords createTestRecords(TypeConfig<eu.stratosphere.types.Record> typeConfig)
GenericTestPlanGenericTestRecords for this plan.createTestRecords in class GenericTestPlan<eu.stratosphere.types.Record,TestRecords>typeConfig - the TypeConfig to useCopyright © 2014. All rights reserved.