Search in sources :

Example 1 with AttributeNode

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

use of org.apache.nifi.processors.evtx.parser.bxml.AttributeNode 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 3 with AttributeNode

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

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

the class XmlBxmlNodeVisitorTest method testVisitAttributeConditionalSubstitutionNode.

@Test
public void testVisitAttributeConditionalSubstitutionNode() 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);
    ConditionalSubstitutionNode conditionalSubstitutionNode = mock(ConditionalSubstitutionNode.class);
    when(attributeNode.getAttributeName()).thenReturn(attributeName);
    when(attributeNode.getValue()).thenReturn(conditionalSubstitutionNode);
    doAnswer(invocation -> {
        ((BxmlNodeVisitor) invocation.getArguments()[0]).visit(conditionalSubstitutionNode);
        return null;
    }).when(conditionalSubstitutionNode).accept(any(BxmlNodeVisitor.class));
    when(conditionalSubstitutionNode.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) ConditionalSubstitutionNode(org.apache.nifi.processors.evtx.parser.bxml.ConditionalSubstitutionNode) Test(org.junit.Test)

Example 5 with AttributeNode

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

the class XmlBxmlNodeVisitorTest method testVisitAttributeNodeValueType.

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

Aggregations

AttributeNode (org.apache.nifi.processors.evtx.parser.bxml.AttributeNode)5 Test (org.junit.Test)5 BxmlNodeVisitor (org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor)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 OpenStartElementNode (org.apache.nifi.processors.evtx.parser.bxml.OpenStartElementNode)1 ValueNode (org.apache.nifi.processors.evtx.parser.bxml.ValueNode)1 InOrder (org.mockito.InOrder)1