### Question:
ParseEvtx extends AbstractProcessor { protected String getBasename(FlowFile flowFile, ComponentLog logger) { String basename = flowFile.getAttribute(CoreAttributes.FILENAME.key()); if (basename.endsWith(EVTX_EXTENSION)) { return basename.substring(0, basename.length() - EVTX_EXTENSION.length()); } else { logger.warn("Trying to parse file without .evtx extension {} from flowfile {}", new Object[]{basename, flowFile}); return basename; } } 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; }### Answer:
@Test public void testGetBasenameEvtxExtension() { String basename = "basename"; FlowFile flowFile = mock(FlowFile.class); when(flowFile.getAttribute(CoreAttributes.FILENAME.key())).thenReturn(basename + ".evtx"); assertEquals(basename, parseEvtx.getBasename(flowFile, componentLog)); verifyNoMoreInteractions(componentLog); }
@Test public void testGetBasenameExtension() { String basename = "basename.wrongextension"; FlowFile flowFile = mock(FlowFile.class); ComponentLog componentLog = mock(ComponentLog.class); when(flowFile.getAttribute(CoreAttributes.FILENAME.key())).thenReturn(basename); assertEquals(basename, parseEvtx.getBasename(flowFile, componentLog)); verify(componentLog).warn(anyString(), isA(Object[].class)); }