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);
}
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();
}
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);
}
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);
}
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));
}
Aggregations