Class ProcessingUtil
- java.lang.Object
-
- org.hansken.plugin.extraction.test.base.ProcessingUtil
-
public final class ProcessingUtil extends Object
Utility functions for use when running anExtractionPluginProcessor.
-
-
Field Summary
Fields Modifier and Type Field Description static StringSEARCH_TRACES_DIR_NAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PathcreateDataStreamPath(Path rootTracePath, String tracePath, String dataType)Create aPathwhich points to the data stream file of the expected trace and type.static byte[]dataStream(nl.minvenj.nfi.flits.api.Trace trace, String dataType)Extract adata streamsof given type from given trace.static Set<String>dataTypes(nl.minvenj.nfi.flits.api.Trace trace)Extract all data types of thedata streamsof given trace.static StringextractFileExtension(Path filePath)Return extension of file at provided path.static StringextractFileName(Path path)Return filename without extension from a given path.static PathgetSearchTracesPath(Path tracePath)Return folder containing search traces given provided path to test trace.static booleanhasDataStreamOfType(nl.minvenj.nfi.flits.api.Trace trace, String dataType)Validate that givenTracecontains a data stream of given type.static booleanisFileWithExtension(Path filePath, String extension)Return true if the extension filename located at path equals the provided extension.static SearchTracesearchTraceFromPath(Path tracePath)Create a search trace given the path to the file representing the search trace.
-
-
-
Field Detail
-
SEARCH_TRACES_DIR_NAME
public static final String SEARCH_TRACES_DIR_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
dataTypes
public static Set<String> dataTypes(nl.minvenj.nfi.flits.api.Trace trace)
Extract all data types of thedata streamsof given trace. It does this by filtering for all properties which start with theConstants.DATA_STREAM_NAME_PREFIXmarker.- Parameters:
trace- the trace to extract the data types- Returns:
- all data types of the contained data streams
-
hasDataStreamOfType
public static boolean hasDataStreamOfType(nl.minvenj.nfi.flits.api.Trace trace, String dataType)Validate that givenTracecontains a data stream of given type.- Parameters:
trace- the trace to testdataType- the type of the data stream to check for- Returns:
trueif the trace contains the requested stream, otherwisefalse
-
dataStream
public static byte[] dataStream(nl.minvenj.nfi.flits.api.Trace trace, String dataType)Extract adata streamsof given type from given trace.- Parameters:
trace- the trace to read the data stream fromdataType- the type of the data to read- Returns:
- the data stream as a byte array
-
createDataStreamPath
public static Path createDataStreamPath(Path rootTracePath, String tracePath, String dataType)
Create aPathwhich points to the data stream file of the expected trace and type. ThetracePathis a path which uniquely defines a single (child) trace.- Parameters:
rootTracePath- the path of the root trace JSONtracePath- a uniquely identifying path for current tracedataType- the data type of the stream- Returns:
- a new path for given data stream file
-
extractFileName
public static String extractFileName(Path path)
Return filename without extension from a given path.- Parameters:
path- path to a file- Returns:
- filename without extension
-
getSearchTracesPath
public static Path getSearchTracesPath(Path tracePath)
Return folder containing search traces given provided path to test trace.- Parameters:
tracePath- path to the trace being tested- Returns:
- traces returned when querying
-
isFileWithExtension
public static boolean isFileWithExtension(Path filePath, String extension)
Return true if the extension filename located at path equals the provided extension.- Parameters:
filePath- path to file to checkextension- extension to match- Returns:
- true if matches
-
extractFileExtension
public static String extractFileExtension(Path filePath)
Return extension of file at provided path.- Parameters:
filePath- path to file- Returns:
- extension of file
-
searchTraceFromPath
public static SearchTrace searchTraceFromPath(Path tracePath)
Create a search trace given the path to the file representing the search trace.- Parameters:
tracePath- Path to the search trace- Returns:
- New SearchTrace
-
-