T - the record typepublic class GenericTestRecords<T> extends Object implements Closeable, Iterable<T>
GenericTestPlan. The class is
especially important when setting the expected values in the GenericTestPlan.load(Class, Configuration) and load(Class, String, Configuration) the
location, format, and configuration of the data can be specified. The file is lazily loaded and thus can be
comparable large.
add(Object...), add(Iterable), and
add(GenericTestRecords). Please note that the actual amount of records for a test case as the
GenericTestPlan already involves a certain degree of overhead.hashCode() or to compare two
instances with equals(Object) can become quite long. Currently, the comparison result is order-dependent as
GenericTestRecords are interpreted as a bags.| Modifier | Constructor and Description |
|---|---|
protected |
GenericTestRecords()
Initializes GenericTestRecords.
|
|
GenericTestRecords(TypeConfig<T> typeConfig)
Initializes GenericTestRecords with the given
TypeConfig. |
| Modifier and Type | Method and Description |
|---|---|
GenericTestRecords<T> |
add(GenericTestRecords<T> records)
Adds several records at once.
|
GenericTestRecords<T> |
add(Iterable<? extends T> records)
Adds several records at once.
|
GenericTestRecords<T> |
add(T... records)
Adds several records at once.
|
void |
assertEquals(GenericTestRecords<T> expectedValues)
Asserts that the contained set of records is equal to the set of records of the given
GenericTestRecords. |
void |
close() |
boolean |
equals(Object obj) |
protected List<T> |
getRecords()
Returns the records.
|
TypeConfig<T> |
getTypeConfig()
Returns the typeConfig.
|
int |
hashCode() |
boolean |
isAdhoc()
Returns true if any add method has been called at least one.
|
boolean |
isInitialized()
Returns true if either records were added manually or with
load(Class, Configuration). |
Iterator<T> |
iterator() |
Iterator<T> |
iterator(TypeConfig<T> typeConfig)
Retrieves an iterator over all entries sorted according to the provided
TypeConfig. |
GenericTestRecords<T> |
load(Class<? extends eu.stratosphere.api.common.io.FileInputFormat> inputFormatClass,
String file,
eu.stratosphere.configuration.Configuration configuration)
Initializes this
GenericTestRecords from the given file. |
GenericTestRecords<T> |
load(Class<? extends eu.stratosphere.api.common.io.GenericInputFormat> inputFormatClass,
eu.stratosphere.configuration.Configuration configuration)
Initializes this
GenericTestRecords from the given generic input. |
void |
saveToFile(String path)
Saves the data to the given path in an internal format.
|
void |
setEmpty()
Specifies that the set of key/value records is empty.
|
void |
setTypeConfig(TypeConfig<T> typeConfig)
Sets the typeConfig to the specified value.
|
String |
toString() |
Iterator<T> |
unsortedIterator()
Returns an Iterator that iterates through the records as they are provided by the ad hoc expression or the file.
|
public GenericTestRecords(TypeConfig<T> typeConfig)
TypeConfig.typeConfig - protected GenericTestRecords()
public GenericTestRecords<T> add(GenericTestRecords<T> records)
records - the records to addpublic GenericTestRecords<T> add(Iterable<? extends T> records)
records - the records to addpublic GenericTestRecords<T> add(T... records)
records - the records to addpublic void assertEquals(GenericTestRecords<T> expectedValues) throws AssertionError
GenericTestRecords.expectedValues - the other GenericTestRecords defining the expected resultAssertionError - if the sets differpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic TypeConfig<T> getTypeConfig()
public boolean isAdhoc()
public boolean isInitialized()
load(Class, Configuration).load(Class, Configuration).public Iterator<T> iterator(TypeConfig<T> typeConfig)
TypeConfig.typeConfig - public GenericTestRecords<T> load(Class<? extends eu.stratosphere.api.common.io.FileInputFormat> inputFormatClass, String file, eu.stratosphere.configuration.Configuration configuration)
GenericTestRecords from the given file.inputFormatClass - the class of the FileInputFormatfile - the path to the file, can be relativeconfiguration - the configuration for the FileInputFormat.public GenericTestRecords<T> load(Class<? extends eu.stratosphere.api.common.io.GenericInputFormat> inputFormatClass, eu.stratosphere.configuration.Configuration configuration)
GenericTestRecords from the given generic input.inputFormatClass - the class of the FileInputFormatconfiguration - the configuration for the FileInputFormat.public void saveToFile(String path) throws IOException
path - the path to write to, may be relativeIOException - if an I/O error occurredpublic void setEmpty()
add(Object...) will reset the
effect of this method invocation and vice-versa.public void setTypeConfig(TypeConfig<T> typeConfig)
typeConfig - the typeConfig to setpublic Iterator<T> unsortedIterator()
iterator().
It simply skips the sorting step, it will not shuffle sorted records.Copyright © 2014. All rights reserved.