Class MockFlowFile

java.lang.Object
org.apache.nifi.util.MockFlowFile
All Implemented Interfaces:
Comparable<org.apache.nifi.flowfile.FlowFile>, org.apache.nifi.flowfile.FlowFile

public class MockFlowFile extends Object implements org.apache.nifi.flowfile.FlowFile
  • Field Details

    • attributes

      private final Map<String,String> 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 interface org.apache.nifi.flowfile.FlowFile
    • compareTo

      public int compareTo(org.apache.nifi.flowfile.FlowFile o)
      Specified by:
      compareTo in interface Comparable<org.apache.nifi.flowfile.FlowFile>
    • getAttribute

      public String getAttribute(String attrName)
      Specified by:
      getAttribute in interface org.apache.nifi.flowfile.FlowFile
    • getAttributes

      public Map<String,String> getAttributes()
      Specified by:
      getAttributes in interface org.apache.nifi.flowfile.FlowFile
    • getEntryDate

      public long getEntryDate()
      Specified by:
      getEntryDate in interface org.apache.nifi.flowfile.FlowFile
    • getId

      public long getId()
      Specified by:
      getId in interface org.apache.nifi.flowfile.FlowFile
    • getSize

      public long getSize()
      Specified by:
      getSize in interface org.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 standard FlowFile 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 standard FlowFile implementations, but useful for complex test assertions.
      Returns:
      the internal flowfile content as a byte[]
    • getContent

      public String getContent()
      Returns the value of the internal content for this mock flowfile as a UTF-8 encoded String. Would not exist in standard FlowFile implementations, but useful for complex test assertions.
      Returns:
      the internal flowfile content as a String
    • getContentStream

      public InputStream getContentStream()
      Returns the value of the internal content for this mock flowfile as an InputStream. Would not exist in standard FlowFile implementations, but useful for complex test assertions.
      Returns:
      the internal flowfile content as a stream
    • isPenalized

      public boolean isPenalized()
      Specified by:
      isPenalized in interface org.apache.nifi.flowfile.FlowFile
    • putAttributes

      public void putAttributes(Map<String,String> attrs)
    • removeAttributes

      public void removeAttributes(Set<String> attrNames)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • assertAttributeExists

      public void assertAttributeExists(String attributeName)
    • assertAttributeNotExists

      public void assertAttributeNotExists(String attributeName)
    • assertAttributeEquals

      public void assertAttributeEquals(String attributeName, String expectedValue)
    • assertAttributeNotEquals

      public void assertAttributeNotEquals(String attributeName, String expectedValue)
    • assertContentEquals

      public void assertContentEquals(File file) throws IOException
      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

      public void assertContentEquals(Path path) throws IOException
      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

      public void assertContentEquals(byte[] data) throws IOException
      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

      public void assertContentEquals(String data)
    • assertContentEquals

      public void assertContentEquals(String data, boolean ignoreLineEndings)
    • assertContentEquals

      public void assertContentEquals(String data, String charset)
    • assertContentEquals

      public void assertContentEquals(String data, Charset charset)
    • assertContentEquals

      public void assertContentEquals(String data, Charset charset, boolean ignoreLineEndings)
    • assertContentEquals

      public void assertContentEquals(InputStream in) throws IOException
      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

      public Long getLastQueueDate()
      Specified by:
      getLastQueueDate in interface org.apache.nifi.flowfile.FlowFile
    • setLastEnqueuedDate

      public void setLastEnqueuedDate(long lastEnqueuedDate)
    • getLineageStartIndex

      public long getLineageStartIndex()
      Specified by:
      getLineageStartIndex in interface org.apache.nifi.flowfile.FlowFile
    • getQueueDateIndex

      public long getQueueDateIndex()
      Specified by:
      getQueueDateIndex in interface org.apache.nifi.flowfile.FlowFile
    • setEnqueuedIndex

      public void setEnqueuedIndex(long enqueuedIndex)
    • isAttributeEqual

      public boolean isAttributeEqual(String attributeName, String expectedValue)
    • isContentEqual

      public boolean isContentEqual(String expected)
    • isContentEqual

      public boolean isContentEqual(String expected, Charset charset)