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 byte[]private longprivate final longprivate final longprivate longprivate boolean -
Constructor Summary
ConstructorsConstructorDescriptionMockFlowFile(long id) MockFlowFile(long id, org.apache.nifi.flowfile.FlowFile toCopy) -
Method Summary
Modifier and TypeMethodDescriptionvoidassertAttributeEquals(String attributeName, String expectedValue) voidassertAttributeExists(String attributeName) voidassertAttributeNotEquals(String attributeName, String expectedValue) voidassertAttributeNotExists(String attributeName) voidassertContentEquals(byte[] data) Asserts that the content of this FlowFile is the same as the content of the given byte arrayvoidassertContentEquals(File file) Asserts that the content of this FlowFile is the same as the content of the given filevoidAsserts that the content of this FlowFile is the same as the content of the given InputStream.voidassertContentEquals(String data) voidassertContentEquals(String data, boolean ignoreLineEndings) voidassertContentEquals(String data, String charset) voidassertContentEquals(String data, Charset charset) voidassertContentEquals(String data, Charset charset, boolean ignoreLineEndings) voidassertContentEquals(Path path) Asserts that the content of this FlowFile is the same as the content of the given pathintcompareTo(org.apache.nifi.flowfile.FlowFile o) booleangetAttribute(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.longlonggetId()longlonglonglonggetSize()inthashCode()booleanisAttributeEqual(String attributeName, String expectedValue) booleanisContentEqual(String expected) booleanisContentEqual(String expected, Charset charset) booleanvoidputAttributes(Map<String, String> attrs) voidremoveAttributes(Set<String> attrNames) voidsetData(byte[] data) Sets the value of the internal content for this mock flowfile.voidsetEnqueuedIndex(long enqueuedIndex) voidsetLastEnqueuedDate(long lastEnqueuedDate) (package private) voidsetPenalized(boolean penalized) byte[]toString()
-
Field Details
-
attributes
-
id
private final long id -
entryDate
private final long entryDate -
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:
getLineageStartDatein interfaceorg.apache.nifi.flowfile.FlowFile
-
compareTo
public int compareTo(org.apache.nifi.flowfile.FlowFile o) - Specified by:
compareToin interfaceComparable<org.apache.nifi.flowfile.FlowFile>
-
getAttribute
- Specified by:
getAttributein interfaceorg.apache.nifi.flowfile.FlowFile
-
getAttributes
- Specified by:
getAttributesin interfaceorg.apache.nifi.flowfile.FlowFile
-
getEntryDate
public long getEntryDate()- Specified by:
getEntryDatein interfaceorg.apache.nifi.flowfile.FlowFile
-
getId
public long getId()- Specified by:
getIdin interfaceorg.apache.nifi.flowfile.FlowFile
-
getSize
public long getSize()- Specified by:
getSizein 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 standardFlowFileimplementations, 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 standardFlowFileimplementations, 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 standardFlowFileimplementations, 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 standardFlowFileimplementations, but useful for complex test assertions.- Returns:
- the internal flowfile content as a stream
-
isPenalized
public boolean isPenalized()- Specified by:
isPenalizedin 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:
getLastQueueDatein interfaceorg.apache.nifi.flowfile.FlowFile
-
setLastEnqueuedDate
public void setLastEnqueuedDate(long lastEnqueuedDate) -
getLineageStartIndex
public long getLineageStartIndex()- Specified by:
getLineageStartIndexin interfaceorg.apache.nifi.flowfile.FlowFile
-
getQueueDateIndex
public long getQueueDateIndex()- Specified by:
getQueueDateIndexin interfaceorg.apache.nifi.flowfile.FlowFile
-
setEnqueuedIndex
public void setEnqueuedIndex(long enqueuedIndex) -
isAttributeEqual
-
isContentEqual
-
isContentEqual
-