@Test public void chunkGranularityLifecycleTest() throws IOException, ParserConfigurationException, SAXException { String baseName = "testFileName"; String name = baseName + ".evtx"; TestRunner testRunner = TestRunners.newTestRunner(ParseEvtx.class); Map<String, String> attributes = new HashMap<>(); attributes.put(CoreAttributes.FILENAME.key(), name); testRunner.enqueue(this.getClass().getClassLoader().getResourceAsStream("application-logs.evtx"), attributes); testRunner.run(); List<MockFlowFile> originalFlowFiles = testRunner.getFlowFilesForRelationship(ParseEvtx.REL_ORIGINAL); assertEquals(1, originalFlowFiles.size()); MockFlowFile originalFlowFile = originalFlowFiles.get(0); originalFlowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), name); originalFlowFile.assertContentEquals(this.getClass().getClassLoader().getResourceAsStream("application-logs.evtx")); List<MockFlowFile> badChunkFlowFiles = testRunner.getFlowFilesForRelationship(ParseEvtx.REL_BAD_CHUNK); assertEquals(2, badChunkFlowFiles.size()); badChunkFlowFiles.get(0).assertAttributeEquals(CoreAttributes.FILENAME.key(), parseEvtx.getName(baseName, 1, null, ParseEvtx.EVTX_EXTENSION)); badChunkFlowFiles.get(1).assertAttributeEquals(CoreAttributes.FILENAME.key(), parseEvtx.getName(baseName, 2, null, ParseEvtx.EVTX_EXTENSION)); List<MockFlowFile> failureFlowFiles = testRunner.getFlowFilesForRelationship(ParseEvtx.REL_FAILURE); assertEquals(1, failureFlowFiles.size()); List<MockFlowFile> successFlowFiles = testRunner.getFlowFilesForRelationship(ParseEvtx.REL_SUCCESS); assertEquals(8, successFlowFiles.size()); assertEquals(960, validateFlowFiles(successFlowFiles) + validateFlowFiles(failureFlowFiles)); }
protected String getName(String basename, Object chunkNumber, Object recordNumber, String extension) { StringBuilder stringBuilder = new StringBuilder(basename); if (chunkNumber != null) { stringBuilder.append("-chunk"); stringBuilder.append(chunkNumber); } if (recordNumber != null) { stringBuilder.append("-record"); stringBuilder.append(recordNumber); } stringBuilder.append(extension); return stringBuilder.toString(); }
ParseEvtx extends AbstractProcessor { protected String getName(String basename, Object chunkNumber, Object recordNumber, String extension) { StringBuilder stringBuilder = new StringBuilder(basename); if (chunkNumber != null) { stringBuilder.append("-chunk"); stringBuilder.append(chunkNumber); } if (recordNumber != null) { stringBuilder.append("-record"); stringBuilder.append(recordNumber); } stringBuilder.append(extension); return stringBuilder.toString(); } }
ParseEvtx extends AbstractProcessor { protected String getName(String basename, Object chunkNumber, Object recordNumber, String extension) { StringBuilder stringBuilder = new StringBuilder(basename); if (chunkNumber != null) { stringBuilder.append("-chunk"); stringBuilder.append(chunkNumber); } if (recordNumber != null) { stringBuilder.append("-record"); stringBuilder.append(recordNumber); } stringBuilder.append(extension); return stringBuilder.toString(); } ParseEvtx();  ParseEvtx(FileHeaderFactory fileHeaderFactory, MalformedChunkHandler malformedChunkHandler, RootNodeHandlerFactory rootNodeHandlerFactory, ResultProcessor resultProcessor); }
ParseEvtx extends AbstractProcessor { protected String getName(String basename, Object chunkNumber, Object recordNumber, String extension) { StringBuilder stringBuilder = new StringBuilder(basename); if (chunkNumber != null) { stringBuilder.append("-chunk"); stringBuilder.append(chunkNumber); } if (recordNumber != null) { stringBuilder.append("-record"); stringBuilder.append(recordNumber); } stringBuilder.append(extension); return stringBuilder.toString(); } ParseEvtx();  ParseEvtx(FileHeaderFactory fileHeaderFactory, MalformedChunkHandler malformedChunkHandler, RootNodeHandlerFactory rootNodeHandlerFactory, ResultProcessor resultProcessor); @Override void onTrigger(ProcessContext context, ProcessSession session); @Override Set<Relationship> getRelationships(); }
ParseEvtx extends AbstractProcessor { protected String getName(String basename, Object chunkNumber, Object recordNumber, String extension) { StringBuilder stringBuilder = new StringBuilder(basename); if (chunkNumber != null) { stringBuilder.append("-chunk"); stringBuilder.append(chunkNumber); } if (recordNumber != null) { stringBuilder.append("-record"); stringBuilder.append(recordNumber); } stringBuilder.append(extension); return stringBuilder.toString(); } ParseEvtx();  ParseEvtx(FileHeaderFactory fileHeaderFactory, MalformedChunkHandler malformedChunkHandler, RootNodeHandlerFactory rootNodeHandlerFactory, ResultProcessor resultProcessor); @Override void onTrigger(ProcessContext context, ProcessSession session); @Override Set<Relationship> getRelationships(); static final String RECORD; static final String CHUNK; static final String FILE; static final String EVTX_EXTENSION; static final String XML_EXTENSION; }