Search in sources :

Example 1 with BxmlNode

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);
}
Also used : BxmlNode(org.apache.nifi.processors.evtx.parser.bxml.BxmlNode) ValueNode(org.apache.nifi.processors.evtx.parser.bxml.ValueNode) Test(org.junit.Test)

Example 2 with BxmlNode

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);
}
Also used : RootNode(org.apache.nifi.processors.evtx.parser.bxml.RootNode) BxmlNodeVisitor(org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor) BxmlNode(org.apache.nifi.processors.evtx.parser.bxml.BxmlNode) Test(org.junit.Test)

Example 3 with BxmlNode

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();
}
Also used : AttributeNode(org.apache.nifi.processors.evtx.parser.bxml.AttributeNode) InOrder(org.mockito.InOrder) OpenStartElementNode(org.apache.nifi.processors.evtx.parser.bxml.OpenStartElementNode) BxmlNode(org.apache.nifi.processors.evtx.parser.bxml.BxmlNode) Test(org.junit.Test)

Example 4 with BxmlNode

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());
}
Also used : TemplateNode(org.apache.nifi.processors.evtx.parser.bxml.TemplateNode) RootNode(org.apache.nifi.processors.evtx.parser.bxml.RootNode) BxmlNode(org.apache.nifi.processors.evtx.parser.bxml.BxmlNode) UnsignedInteger(com.google.common.primitives.UnsignedInteger) NameStringNode(org.apache.nifi.processors.evtx.parser.bxml.NameStringNode) EndOfStreamNode(org.apache.nifi.processors.evtx.parser.bxml.EndOfStreamNode) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test) TemplateNodeTest(org.apache.nifi.processors.evtx.parser.bxml.TemplateNodeTest) NameStringNodeTest(org.apache.nifi.processors.evtx.parser.bxml.NameStringNodeTest)

Example 5 with BxmlNode

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());
}
Also used : RootNode(org.apache.nifi.processors.evtx.parser.bxml.RootNode) BxmlNode(org.apache.nifi.processors.evtx.parser.bxml.BxmlNode) EndOfStreamNode(org.apache.nifi.processors.evtx.parser.bxml.EndOfStreamNode) Test(org.junit.Test)

Aggregations

BxmlNode (org.apache.nifi.processors.evtx.parser.bxml.BxmlNode)8 Test (org.junit.Test)8 RootNode (org.apache.nifi.processors.evtx.parser.bxml.RootNode)4 EndOfStreamNode (org.apache.nifi.processors.evtx.parser.bxml.EndOfStreamNode)3 BxmlNodeVisitor (org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor)2 AttributeNode (org.apache.nifi.processors.evtx.parser.bxml.AttributeNode)2 TemplateNode (org.apache.nifi.processors.evtx.parser.bxml.TemplateNode)2 ValueNode (org.apache.nifi.processors.evtx.parser.bxml.ValueNode)2 UnsignedInteger (com.google.common.primitives.UnsignedInteger)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 NameStringNode (org.apache.nifi.processors.evtx.parser.bxml.NameStringNode)1 NameStringNodeTest (org.apache.nifi.processors.evtx.parser.bxml.NameStringNodeTest)1 OpenStartElementNode (org.apache.nifi.processors.evtx.parser.bxml.OpenStartElementNode)1 TemplateNodeTest (org.apache.nifi.processors.evtx.parser.bxml.TemplateNodeTest)1 InOrder (org.mockito.InOrder)1