Package org.apache.nifi.util
Class MockFlowFile
java.lang.Object
org.apache.nifi.util.MockFlowFile
- All Implemented Interfaces:
Comparable<org.apache.nifi.flowfile.FlowFile>
,org.apache.nifi.flowfile.FlowFile
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.nifi.flowfile.FlowFile
org.apache.nifi.flowfile.FlowFile.KeyValidator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private byte[]
private long
private final long
private final long
private long
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionMockFlowFile
(long id) MockFlowFile
(long id, org.apache.nifi.flowfile.FlowFile toCopy) -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertAttributeEquals
(String attributeName, String expectedValue) void
assertAttributeExists
(String attributeName) void
assertAttributeNotEquals
(String attributeName, String expectedValue) void
assertAttributeNotExists
(String attributeName) void
assertContentEquals
(byte[] data) Asserts that the content of this FlowFile is the same as the content of the given byte arrayvoid
assertContentEquals
(File file) Asserts that the content of this FlowFile is the same as the content of the given filevoid
Asserts that the content of this FlowFile is the same as the content of the given InputStream.void
assertContentEquals
(String data) void
assertContentEquals
(String data, boolean ignoreLineEndings) void
assertContentEquals
(String data, String charset) void
assertContentEquals
(String data, Charset charset) void
assertContentEquals
(String data, Charset charset, boolean ignoreLineEndings) void
assertContentEquals
(Path path) Asserts that the content of this FlowFile is the same as the content of the given pathint
compareTo
(org.apache.nifi.flowfile.FlowFile o) boolean
getAttribute
(String attrName) Returns the value of the internal content for this mock flowfile as a UTF-8 encoded String.Returns the value of the internal content for this mock flowfile as anInputStream
.byte[]
getData()
Returns the value of the internal content for this mock flowfile.long
long
getId()
long
long
long
long
getSize()
int
hashCode()
boolean
isAttributeEqual
(String attributeName, String expectedValue) boolean
isContentEqual
(String expected) boolean
isContentEqual
(String expected, Charset charset) boolean
void
putAttributes
(Map<String, String> attrs) void
removeAttributes
(Set<String> attrNames) void
setData
(byte[] data) Sets the value of the internal content for this mock flowfile.void
setEnqueuedIndex
(long enqueuedIndex) void
setLastEnqueuedDate
(long lastEnqueuedDate) (package private) void
setPenalized
(boolean penalized) byte[]
toString()
-
Field Details
-
attributes
-
id
private final long id -
entryDate
private final long entryDate -
creationTime
private final long creationTime -
penalized
private boolean penalized -
data
private byte[] data -
lastEnqueuedDate
private long lastEnqueuedDate -
enqueuedIndex
private long enqueuedIndex
-
-
Constructor Details
-
MockFlowFile
public MockFlowFile(long id) -
MockFlowFile
public MockFlowFile(long id, org.apache.nifi.flowfile.FlowFile toCopy)
-
-
Method Details
-
setPenalized
void setPenalized(boolean penalized) -
getLineageStartDate
public long getLineageStartDate()- Specified by:
getLineageStartDate
in interfaceorg.apache.nifi.flowfile.FlowFile
-
compareTo
public int compareTo(org.apache.nifi.flowfile.FlowFile o) - Specified by:
compareTo
in interfaceComparable<org.apache.nifi.flowfile.FlowFile>
-
getAttribute
- Specified by:
getAttribute
in interfaceorg.apache.nifi.flowfile.FlowFile
-
getAttributes
- Specified by:
getAttributes
in interfaceorg.apache.nifi.flowfile.FlowFile
-
getEntryDate
public long getEntryDate()- Specified by:
getEntryDate
in interfaceorg.apache.nifi.flowfile.FlowFile
-
getId
public long getId()- Specified by:
getId
in interfaceorg.apache.nifi.flowfile.FlowFile
-
getSize
public long getSize()- Specified by:
getSize
in interfaceorg.apache.nifi.flowfile.FlowFile
-
setData
public void setData(byte[] data) Sets the value of the internal content for this mock flowfile. Would not exist in standardFlowFile
implementations, but useful for complex test assertions.- Parameters:
data
- the flowfile content as a byte[]
-
getData
public byte[] getData()Returns the value of the internal content for this mock flowfile. Would not exist in standardFlowFile
implementations, but useful for complex test assertions.- Returns:
- the internal flowfile content as a byte[]
-
getContent
Returns the value of the internal content for this mock flowfile as a UTF-8 encoded String. Would not exist in standardFlowFile
implementations, but useful for complex test assertions.- Returns:
- the internal flowfile content as a String
-
getContentStream
Returns the value of the internal content for this mock flowfile as anInputStream
. Would not exist in standardFlowFile
implementations, but useful for complex test assertions.- Returns:
- the internal flowfile content as a stream
-
isPenalized
public boolean isPenalized()- Specified by:
isPenalized
in interfaceorg.apache.nifi.flowfile.FlowFile
-
putAttributes
-
removeAttributes
-
toString
-
hashCode
public int hashCode() -
equals
-
assertAttributeExists
-
assertAttributeNotExists
-
assertAttributeEquals
-
assertAttributeNotEquals
-
assertContentEquals
Asserts that the content of this FlowFile is the same as the content of the given file- Parameters:
file
- to compare content against- Throws:
IOException
- if fails doing IO during comparison
-
assertContentEquals
Asserts that the content of this FlowFile is the same as the content of the given path- Parameters:
path
- where to find content to compare to- Throws:
IOException
- if io error occurs while comparing content
-
assertContentEquals
Asserts that the content of this FlowFile is the same as the content of the given byte array- Parameters:
data
- the data to compare- Throws:
IOException
- if any ioe occurs while reading flowfile
-
assertContentEquals
-
assertContentEquals
-
assertContentEquals
-
assertContentEquals
-
assertContentEquals
-
assertContentEquals
Asserts that the content of this FlowFile is the same as the content of the given InputStream. This method closes the InputStream when it is finished.- Parameters:
in
- the stream to source comparison data from- Throws:
IOException
- if any issues reading from given source
-
toByteArray
public byte[] toByteArray()- Returns:
- a copy of the the contents of the FlowFile as a byte array
-
getLastQueueDate
- Specified by:
getLastQueueDate
in interfaceorg.apache.nifi.flowfile.FlowFile
-
setLastEnqueuedDate
public void setLastEnqueuedDate(long lastEnqueuedDate) -
getLineageStartIndex
public long getLineageStartIndex()- Specified by:
getLineageStartIndex
in interfaceorg.apache.nifi.flowfile.FlowFile
-
getQueueDateIndex
public long getQueueDateIndex()- Specified by:
getQueueDateIndex
in interfaceorg.apache.nifi.flowfile.FlowFile
-
setEnqueuedIndex
public void setEnqueuedIndex(long enqueuedIndex) -
isAttributeEqual
-
isContentEqual
-
isContentEqual
-