Search in sources :

Example 1 with BxmlNodeVisitor

use of org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor in project nifi by apache.

the class XmlBxmlNodeVisitorTest method testVisitAttributeNormalSubstitutionNode.

@Test
public void testVisitAttributeNormalSubstitutionNode() throws IOException, XMLStreamException {
    String attributeName = "attributeName";
    String attributeValue = "attributeValue";
    VariantTypeNode sub = mock(VariantTypeNode.class);
    when(sub.getValue()).thenReturn(attributeValue);
    substitutions.add(sub);
    AttributeNode attributeNode = mock(AttributeNode.class);
    NormalSubstitutionNode normalSubstitutionNode = mock(NormalSubstitutionNode.class);
    when(attributeNode.getAttributeName()).thenReturn(attributeName);
    when(attributeNode.getValue()).thenReturn(normalSubstitutionNode);
    doAnswer(invocation -> {
        ((BxmlNodeVisitor) invocation.getArguments()[0]).visit(normalSubstitutionNode);
        return null;
    }).when(normalSubstitutionNode).accept(any(BxmlNodeVisitor.class));
    when(normalSubstitutionNode.getIndex()).thenReturn(0);
    xmlBxmlNodeVisitor.visit(attributeNode);
    verify(xmlStreamWriter).writeAttribute(attributeName, attributeValue);
}
Also used : BxmlNodeVisitor(org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor) AttributeNode(org.apache.nifi.processors.evtx.parser.bxml.AttributeNode) VariantTypeNode(org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode) NormalSubstitutionNode(org.apache.nifi.processors.evtx.parser.bxml.NormalSubstitutionNode) Test(org.junit.Test)

Example 2 with BxmlNodeVisitor

use of org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor 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 BxmlNodeVisitor

use of org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor in project nifi by apache.

the class XmlBxmlNodeVisitorTest method testVisitAttributeNodeVariantType.

@Test
public void testVisitAttributeNodeVariantType() throws IOException, XMLStreamException {
    String attributeName = "attributeName";
    String attributeValue = "attributeValue";
    AttributeNode attributeNode = mock(AttributeNode.class);
    VariantTypeNode variantTypeNode = mock(VariantTypeNode.class);
    when(attributeNode.getAttributeName()).thenReturn(attributeName);
    when(attributeNode.getValue()).thenReturn(variantTypeNode);
    doAnswer(invocation -> {
        ((BxmlNodeVisitor) invocation.getArguments()[0]).visit(variantTypeNode);
        return null;
    }).when(variantTypeNode).accept(any(BxmlNodeVisitor.class));
    when(variantTypeNode.getValue()).thenReturn(attributeValue);
    xmlBxmlNodeVisitor.visit(attributeNode);
    verify(xmlStreamWriter).writeAttribute(attributeName, attributeValue);
}
Also used : BxmlNodeVisitor(org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor) AttributeNode(org.apache.nifi.processors.evtx.parser.bxml.AttributeNode) VariantTypeNode(org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode) Test(org.junit.Test)

Example 4 with BxmlNodeVisitor

use of org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor in project nifi by apache.

the class AttributeNodeTest method testVisit.

@Test
public void testVisit() throws IOException {
    BxmlNodeVisitor mock = mock(BxmlNodeVisitor.class);
    attributeNode.accept(mock);
    verify(mock).visit(attributeNode);
    verifyNoMoreInteractions(mock);
}
Also used : BxmlNodeVisitor(org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor) Test(org.junit.Test)

Example 5 with BxmlNodeVisitor

use of org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor in project nifi by apache.

the class CDataSectionNodeTest method testVisitor.

@Test
public void testVisitor() throws IOException {
    BxmlNodeVisitor mock = mock(BxmlNodeVisitor.class);
    cDataSectionNode.accept(mock);
    verify(mock).visit(cDataSectionNode);
    verifyNoMoreInteractions(mock);
}
Also used : BxmlNodeVisitor(org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor) Test(org.junit.Test)

Aggregations

BxmlNodeVisitor (org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor)23 Test (org.junit.Test)23 AttributeNode (org.apache.nifi.processors.evtx.parser.bxml.AttributeNode)4 VariantTypeNode (org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode)3 BxmlNode (org.apache.nifi.processors.evtx.parser.bxml.BxmlNode)2 ConditionalSubstitutionNode (org.apache.nifi.processors.evtx.parser.bxml.ConditionalSubstitutionNode)1 NormalSubstitutionNode (org.apache.nifi.processors.evtx.parser.bxml.NormalSubstitutionNode)1 RootNode (org.apache.nifi.processors.evtx.parser.bxml.RootNode)1 ValueNode (org.apache.nifi.processors.evtx.parser.bxml.ValueNode)1