Search in sources :

Example 1 with ConditionalSubstitutionNode

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

the class XmlBxmlNodeVisitorTest method testVisitConditionalSubstitutionNode.

@Test
public void testVisitConditionalSubstitutionNode() throws IOException {
    ConditionalSubstitutionNode conditionalSubstitutionNode = mock(ConditionalSubstitutionNode.class);
    VariantTypeNode sub = mock(VariantTypeNode.class);
    substitutions.add(sub);
    when(conditionalSubstitutionNode.getIndex()).thenReturn(0);
    xmlBxmlNodeVisitor.visit(conditionalSubstitutionNode);
    verify(sub).accept(xmlBxmlNodeVisitor);
}
Also used : VariantTypeNode(org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode) ConditionalSubstitutionNode(org.apache.nifi.processors.evtx.parser.bxml.ConditionalSubstitutionNode) Test(org.junit.Test)

Example 2 with ConditionalSubstitutionNode

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

Aggregations

ConditionalSubstitutionNode (org.apache.nifi.processors.evtx.parser.bxml.ConditionalSubstitutionNode)2 VariantTypeNode (org.apache.nifi.processors.evtx.parser.bxml.value.VariantTypeNode)2 Test (org.junit.Test)2 BxmlNodeVisitor (org.apache.nifi.processors.evtx.parser.BxmlNodeVisitor)1 AttributeNode (org.apache.nifi.processors.evtx.parser.bxml.AttributeNode)1