use of org.apache.nifi.processors.evtx.parser.bxml.BxmlNode in project nifi by apache.
the class XmlBxmlNodeVisitorTest method testVisitValueNode.
@Test
public void testVisitValueNode() throws IOException {
ValueNode valueNode = mock(ValueNode.class);
BxmlNode child = mock(BxmlNode.class);
when(valueNode.getChildren()).thenReturn(Arrays.asList(child));
xmlBxmlNodeVisitor.visit(valueNode);
verify(child).accept(xmlBxmlNodeVisitor);
}
use of org.apache.nifi.processors.evtx.parser.bxml.BxmlNode in project nifi by apache.
the class XmlBxmlNodeVisitorTest method testVisitRootNode.
@Test
public void testVisitRootNode() throws IOException {
RootNode rootNode = mock(RootNode.class);
BxmlNode child = mock(BxmlNode.class);
when(rootNode.getChildren()).thenReturn(Arrays.asList(child));
xmlBxmlNodeVisitor.visit(rootNode);
ArgumentCaptor<BxmlNodeVisitor> captor = ArgumentCaptor.forClass(BxmlNodeVisitor.class);
verify(child).accept(captor.capture());
BxmlNodeVisitor value = captor.getValue();
assertTrue(value instanceof XmlBxmlNodeVisitor);
assertNotEquals(xmlBxmlNodeVisitor, value);
}
use of org.apache.nifi.processors.evtx.parser.bxml.BxmlNode in project nifi by apache.
the class XmlBxmlNodeVisitorTest method testVisitOpenStartElementNode.
@Test
public void testVisitOpenStartElementNode() throws IOException, XMLStreamException {
String tagName = "open";
OpenStartElementNode openStartElementNode = mock(OpenStartElementNode.class);
AttributeNode attributeNode = mock(AttributeNode.class);
AttributeNode attributeNode2 = mock(AttributeNode.class);
BxmlNode bxmlNode = mock(BxmlNode.class);
when(openStartElementNode.getTagName()).thenReturn(tagName);
when(openStartElementNode.getChildren()).thenReturn(Arrays.asList(attributeNode, bxmlNode, attributeNode2));
xmlBxmlNodeVisitor.visit(openStartElementNode);
InOrder inOrder = inOrder(xmlStreamWriter, attributeNode, attributeNode2, bxmlNode);
inOrder.verify(xmlStreamWriter).writeStartElement(tagName);
inOrder.verify(attributeNode).accept(xmlBxmlNodeVisitor);
inOrder.verify(attributeNode2).accept(xmlBxmlNodeVisitor);
inOrder.verify(bxmlNode).accept(xmlBxmlNodeVisitor);
inOrder.verify(xmlStreamWriter).writeEndElement();
}
use of org.apache.nifi.processors.evtx.parser.bxml.BxmlNode in project nifi by apache.
the class ChunkHeaderTest method testInit.
@Test
public void testInit() throws IOException {
int count = 0;
for (Map.Entry<Integer, NameStringNode> integerNameStringNodeEntry : new TreeMap<>(chunkHeader.getNameStrings()).entrySet()) {
assertEquals(Integer.toString(count++), integerNameStringNodeEntry.getValue().getString());
}
Iterator<String> iterator = guids.iterator();
for (Map.Entry<Integer, TemplateNode> integerTemplateNodeEntry : new TreeMap<>(chunkHeader.getTemplateNodes()).entrySet()) {
assertEquals(iterator.next(), integerTemplateNodeEntry.getValue().getGuid());
}
assertTrue(chunkHeader.hasNext());
Record next = chunkHeader.next();
assertEquals(fileLastRecordNumber, next.getRecordNum().intValue());
RootNode rootNode = next.getRootNode();
List<BxmlNode> children = rootNode.getChildren();
assertEquals(1, children.size());
assertTrue(children.get(0) instanceof EndOfStreamNode);
assertEquals(0, rootNode.getSubstitutions().size());
assertFalse(chunkHeader.hasNext());
}
use of org.apache.nifi.processors.evtx.parser.bxml.BxmlNode in project nifi by apache.
the class RecordTest method testInit.
@Test
public void testInit() {
assertEquals(recordNum, record.getRecordNum().intValue());
RootNode rootNode = record.getRootNode();
List<BxmlNode> children = rootNode.getChildren();
assertEquals(1, children.size());
assertTrue(children.get(0) instanceof EndOfStreamNode);
assertEquals(0, rootNode.getSubstitutions().size());
}
Aggregations