use of org.apache.nifi.atlas.provenance.DataSetRefs in project nifi by apache.
the class TestUnknownDataSet method testGenerateFlowFile.
@Test
public void testGenerateFlowFile() {
final String processorName = "GenerateFlowFile";
final String processorId = "processor-1234";
final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class);
when(record.getComponentType()).thenReturn(processorName);
when(record.getComponentId()).thenReturn(processorId);
when(record.getEventType()).thenReturn(ProvenanceEventType.CREATE);
final ClusterResolvers clusterResolvers = Mockito.mock(ClusterResolvers.class);
when(clusterResolvers.fromHostNames(matches(".+\\.example\\.com"))).thenReturn("cluster1");
final List<ConnectionStatus> connections = new ArrayList<>();
final AnalysisContext context = Mockito.mock(AnalysisContext.class);
when(context.getClusterResolver()).thenReturn(clusterResolvers);
when(context.findConnectionTo(processorId)).thenReturn(connections);
when(context.getNiFiClusterName()).thenReturn("nifi-cluster");
final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(processorName, null, record.getEventType());
assertNotNull(analyzer);
final DataSetRefs refs = analyzer.analyze(context, record);
assertEquals(1, refs.getInputs().size());
assertEquals(0, refs.getOutputs().size());
Referenceable ref = refs.getInputs().iterator().next();
assertEquals("nifi_data", ref.getTypeName());
assertEquals("GenerateFlowFile", ref.get(ATTR_NAME));
assertEquals("processor-1234@nifi-cluster", ref.get(ATTR_QUALIFIED_NAME));
}
Aggregations