public class MockProcessSession extends Object implements ProcessSession
Modifier and Type | Field and Description |
---|---|
private Set<Long> |
beingProcessed |
private boolean |
committed |
private Map<String,Long> |
counterMap |
private Map<Long,MockFlowFile> |
currentVersions |
private Map<Long,MockFlowFile> |
originalVersions |
private List<MockFlowFile> |
penalized |
private MockFlowFileQueue |
processorQueue |
private MockProvenanceReporter |
provenanceReporter |
private int |
removedCount |
private boolean |
rolledback |
private SharedSessionState |
sharedState |
private Map<Relationship,List<MockFlowFile>> |
transferMap |
Constructor and Description |
---|
MockProcessSession(SharedSessionState sharedState,
Processor processor) |
Modifier and Type | Method and Description |
---|---|
void |
adjustCounter(String name,
long delta,
boolean immediate) |
FlowFile |
append(FlowFile flowFile,
OutputStreamCallback callback) |
void |
assertAllFlowFilesTransferred(Relationship relationship)
Asserts that all FlowFiles that were transferred were transferred to the
given relationship
|
void |
assertAllFlowFilesTransferred(Relationship relationship,
int count)
Asserts that all FlowFiles that were transferred were transferred to the
given relationship and that the number of FlowFiles transferred is equal
to
count |
void |
assertAllFlowFilesTransferred(String relationship)
Asserts that all FlowFiles that were transferred were transferred to the
given relationship
|
void |
assertAllFlowFilesTransferred(String relationship,
int count)
Asserts that all FlowFiles that were transferred were transferred to the
given relationship and that the number of FlowFiles transferred is equal
to
count |
void |
assertCommitted()
Assert that
commit() has been called |
void |
assertNotCommitted()
Assert that
commit() has not been called |
void |
assertNotRolledBack()
Assert that
rollback() has not been called |
void |
assertQueueEmpty()
Assert that there are no FlowFiles left on the input queue.
|
void |
assertQueueNotEmpty()
Assert that at least one FlowFile is on the input queue
|
void |
assertRolledBack()
Assert that
rollback() has been called |
void |
assertTransferCount(Relationship relationship,
int count)
Assert that the number of FlowFiles transferred to the given relationship
is equal to the given count
|
void |
assertTransferCount(String relationship,
int count)
Assert that the number of FlowFiles transferred to the given relationship
is equal to the given count
|
void |
clearCommited()
Clear the 'committed' flag so that we can test that the next iteration of
Processor.onTrigger(org.apache.nifi.processor.ProcessContext, org.apache.nifi.processor.ProcessSessionFactory) commits or rolls back the
session |
void |
clearRollback()
Clear the 'rolledBack' flag so that we can test that the next iteration
of
Processor.onTrigger(org.apache.nifi.processor.ProcessContext, org.apache.nifi.processor.ProcessSessionFactory) commits or rolls back the
session |
void |
clearTransferState()
Removes all state information about FlowFiles that have been transferred
|
MockFlowFile |
clone(FlowFile flowFile) |
MockFlowFile |
clone(FlowFile flowFile,
long offset,
long size) |
void |
commit() |
MockFlowFile |
create() |
MockFlowFile |
create(Collection<FlowFile> flowFiles) |
MockFlowFile |
create(FlowFile flowFile) |
MockFlowFile |
createFlowFile(byte[] data) |
MockFlowFile |
createFlowFile(byte[] data,
Map<String,String> attrs) |
MockFlowFile |
createFlowFile(File file) |
void |
exportTo(FlowFile flowFile,
OutputStream out) |
void |
exportTo(FlowFile flowFile,
Path path,
boolean append) |
MockFlowFile |
get() |
List<FlowFile> |
get(FlowFileFilter filter) |
List<FlowFile> |
get(int maxResults) |
byte[] |
getContentAsByteArray(MockFlowFile flowFile) |
List<MockFlowFile> |
getFlowFilesForRelationship(Relationship relationship) |
List<MockFlowFile> |
getFlowFilesForRelationship(String relationship) |
List<MockFlowFile> |
getPenalizedFlowFiles() |
ProvenanceReporter |
getProvenanceReporter() |
QueueSize |
getQueueSize() |
int |
getRemovedCount() |
MockFlowFile |
importFrom(InputStream in,
FlowFile flowFile) |
MockFlowFile |
importFrom(Path path,
boolean keepSourceFile,
FlowFile flowFile) |
private FlowFile |
inheritAttributes(Collection<FlowFile> sources,
FlowFile destination)
Inherits the attributes from the given source flow files into the
destination flow file.
|
private FlowFile |
inheritAttributes(FlowFile source,
FlowFile destination)
Inherits the attributes from the given source flow file into another flow
file.
|
private static Map<String,String> |
intersectAttributes(Collection<FlowFile> flowFileList)
Returns the attributes that are common to every flow file given.
|
(package private) boolean |
isFlowFileKnown(FlowFile flowFile)
Checks if a FlowFile is known in this session.
|
MockFlowFile |
merge(Collection<FlowFile> sources,
FlowFile destination) |
MockFlowFile |
merge(Collection<FlowFile> sources,
FlowFile destination,
byte[] header,
byte[] footer,
byte[] demarcator) |
MockFlowFile |
penalize(FlowFile flowFile) |
MockFlowFile |
putAllAttributes(FlowFile flowFile,
Map<String,String> attrs) |
MockFlowFile |
putAttribute(FlowFile flowFile,
String attrName,
String attrValue) |
void |
read(FlowFile flowFile,
boolean allowSessionStreamManagement,
InputStreamCallback callback) |
void |
read(FlowFile flowFile,
InputStreamCallback callback) |
private byte[] |
readFully(InputStream in) |
void |
remove(Collection<FlowFile> flowFiles) |
void |
remove(FlowFile flowFile) |
MockFlowFile |
removeAllAttributes(FlowFile flowFile,
Pattern keyPattern) |
MockFlowFile |
removeAllAttributes(FlowFile flowFile,
Set<String> attrNames) |
MockFlowFile |
removeAttribute(FlowFile flowFile,
String attrName) |
void |
rollback() |
void |
rollback(boolean penalize) |
void |
transfer(Collection<FlowFile> flowFiles) |
void |
transfer(Collection<FlowFile> flowFiles,
Relationship relationship) |
void |
transfer(FlowFile flowFile) |
void |
transfer(FlowFile flowFile,
Relationship relationship) |
private void |
validateState(FlowFile flowFile) |
MockFlowFile |
write(FlowFile flowFile,
OutputStreamCallback callback) |
MockFlowFile |
write(FlowFile flowFile,
StreamCallback callback) |
private final Map<Relationship,List<MockFlowFile>> transferMap
private final MockFlowFileQueue processorQueue
private final List<MockFlowFile> penalized
private final Map<Long,MockFlowFile> currentVersions
private final Map<Long,MockFlowFile> originalVersions
private final SharedSessionState sharedState
private final MockProvenanceReporter provenanceReporter
private boolean committed
private boolean rolledback
private int removedCount
public MockProcessSession(SharedSessionState sharedState, Processor processor)
public void adjustCounter(String name, long delta, boolean immediate)
adjustCounter
in interface ProcessSession
public MockFlowFile clone(FlowFile flowFile)
clone
in interface ProcessSession
public MockFlowFile clone(FlowFile flowFile, long offset, long size)
clone
in interface ProcessSession
public void commit()
commit
in interface ProcessSession
public void clearCommited()
Processor.onTrigger(org.apache.nifi.processor.ProcessContext, org.apache.nifi.processor.ProcessSessionFactory)
commits or rolls back the
sessionpublic void clearRollback()
Processor.onTrigger(org.apache.nifi.processor.ProcessContext, org.apache.nifi.processor.ProcessSessionFactory)
commits or rolls back the
sessionpublic MockFlowFile create()
create
in interface ProcessSession
public MockFlowFile create(FlowFile flowFile)
create
in interface ProcessSession
public MockFlowFile create(Collection<FlowFile> flowFiles)
create
in interface ProcessSession
public void exportTo(FlowFile flowFile, OutputStream out)
exportTo
in interface ProcessSession
public void exportTo(FlowFile flowFile, Path path, boolean append)
exportTo
in interface ProcessSession
public MockFlowFile get()
get
in interface ProcessSession
public List<FlowFile> get(int maxResults)
get
in interface ProcessSession
public List<FlowFile> get(FlowFileFilter filter)
get
in interface ProcessSession
public QueueSize getQueueSize()
getQueueSize
in interface ProcessSession
public MockFlowFile importFrom(InputStream in, FlowFile flowFile)
importFrom
in interface ProcessSession
public MockFlowFile importFrom(Path path, boolean keepSourceFile, FlowFile flowFile)
importFrom
in interface ProcessSession
public MockFlowFile merge(Collection<FlowFile> sources, FlowFile destination)
merge
in interface ProcessSession
public MockFlowFile putAllAttributes(FlowFile flowFile, Map<String,String> attrs)
putAllAttributes
in interface ProcessSession
public MockFlowFile putAttribute(FlowFile flowFile, String attrName, String attrValue)
putAttribute
in interface ProcessSession
public void read(FlowFile flowFile, InputStreamCallback callback)
read
in interface ProcessSession
public void read(FlowFile flowFile, boolean allowSessionStreamManagement, InputStreamCallback callback)
read
in interface ProcessSession
public void remove(FlowFile flowFile)
remove
in interface ProcessSession
public void remove(Collection<FlowFile> flowFiles)
remove
in interface ProcessSession
public MockFlowFile removeAllAttributes(FlowFile flowFile, Set<String> attrNames)
removeAllAttributes
in interface ProcessSession
public MockFlowFile removeAllAttributes(FlowFile flowFile, Pattern keyPattern)
removeAllAttributes
in interface ProcessSession
public MockFlowFile removeAttribute(FlowFile flowFile, String attrName)
removeAttribute
in interface ProcessSession
public void rollback()
rollback
in interface ProcessSession
public void rollback(boolean penalize)
rollback
in interface ProcessSession
public void transfer(FlowFile flowFile)
transfer
in interface ProcessSession
public void transfer(Collection<FlowFile> flowFiles)
transfer
in interface ProcessSession
public void transfer(FlowFile flowFile, Relationship relationship)
transfer
in interface ProcessSession
public void transfer(Collection<FlowFile> flowFiles, Relationship relationship)
transfer
in interface ProcessSession
public MockFlowFile write(FlowFile flowFile, OutputStreamCallback callback)
write
in interface ProcessSession
public FlowFile append(FlowFile flowFile, OutputStreamCallback callback)
append
in interface ProcessSession
public MockFlowFile write(FlowFile flowFile, StreamCallback callback)
write
in interface ProcessSession
private byte[] readFully(InputStream in) throws IOException
IOException
public List<MockFlowFile> getFlowFilesForRelationship(Relationship relationship)
public List<MockFlowFile> getPenalizedFlowFiles()
public List<MockFlowFile> getFlowFilesForRelationship(String relationship)
relationship
- to get flowfiles forpublic MockFlowFile createFlowFile(File file) throws IOException
IOException
public MockFlowFile createFlowFile(byte[] data)
public MockFlowFile createFlowFile(byte[] data, Map<String,String> attrs)
public MockFlowFile merge(Collection<FlowFile> sources, FlowFile destination, byte[] header, byte[] footer, byte[] demarcator)
merge
in interface ProcessSession
private void validateState(FlowFile flowFile)
private FlowFile inheritAttributes(FlowFile source, FlowFile destination)
source
- the FlowFile from which to copy attributesdestination
- the FlowFile to which to copy attributesprivate FlowFile inheritAttributes(Collection<FlowFile> sources, FlowFile destination)
sources
- to inherit common attributes fromprivate static Map<String,String> intersectAttributes(Collection<FlowFile> flowFileList)
flowFileList
- a list of flow filespublic void assertCommitted()
commit()
has been calledpublic void assertNotCommitted()
commit()
has not been calledpublic void assertRolledBack()
rollback()
has been calledpublic void assertNotRolledBack()
rollback()
has not been calledpublic void assertTransferCount(Relationship relationship, int count)
relationship
- to validate transfer count ofcount
- items transfer to given relationshippublic void assertTransferCount(String relationship, int count)
relationship
- to validate transfer count ofcount
- items transfer to given relationshippublic void assertQueueEmpty()
public void assertQueueNotEmpty()
public void assertAllFlowFilesTransferred(String relationship)
relationship
- to check for transferred flow filespublic void assertAllFlowFilesTransferred(Relationship relationship)
relationship
- to validatepublic void clearTransferState()
public void assertAllFlowFilesTransferred(Relationship relationship, int count)
count
relationship
- to validatecount
- number of items sent to that relationship (expected)public void assertAllFlowFilesTransferred(String relationship, int count)
count
relationship
- to validatecount
- number of items sent to that relationship (expected)public int getRemovedCount()
public ProvenanceReporter getProvenanceReporter()
getProvenanceReporter
in interface ProcessSession
public MockFlowFile penalize(FlowFile flowFile)
penalize
in interface ProcessSession
public byte[] getContentAsByteArray(MockFlowFile flowFile)
boolean isFlowFileKnown(FlowFile flowFile)
flowFile
- the FlowFile to checktrue
if the FlowFile is known in this session,
false
otherwise.Copyright © 2016 Apache NiFi Project. All rights reserved.