Search in sources :

Example 1 with MockReportingInitializationContext

use of org.apache.nifi.mock.MockReportingInitializationContext in project nifi by apache.

the class ReportingTaskingInitializer method initialize.

@Override
public void initialize(ConfigurableComponent component) throws InitializationException {
    ReportingTask reportingTask = (ReportingTask) component;
    ReportingInitializationContext context = new MockReportingInitializationContext();
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), context.getIdentifier())) {
        reportingTask.initialize(context);
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) ReportingInitializationContext(org.apache.nifi.reporting.ReportingInitializationContext) MockReportingInitializationContext(org.apache.nifi.mock.MockReportingInitializationContext) MockReportingInitializationContext(org.apache.nifi.mock.MockReportingInitializationContext) ReportingTask(org.apache.nifi.reporting.ReportingTask)

Example 2 with MockReportingInitializationContext

use of org.apache.nifi.mock.MockReportingInitializationContext in project nifi by apache.

the class HtmlDocumentationWriterTest method testReportingTaskWithLogger.

@Test
public void testReportingTaskWithLogger() throws InitializationException, IOException {
    ReportingTask controllerService = new ReportingTaskWithLogger();
    controllerService.initialize(new MockReportingInitializationContext());
    DocumentationWriter writer = new HtmlDocumentationWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(controllerService, baos, false);
    String results = new String(baos.toByteArray());
    XmlValidator.assertXmlValid(results);
}
Also used : ReportingTaskWithLogger(org.apache.nifi.documentation.example.ReportingTaskWithLogger) MockReportingInitializationContext(org.apache.nifi.mock.MockReportingInitializationContext) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FullyDocumentedReportingTask(org.apache.nifi.documentation.example.FullyDocumentedReportingTask) ReportingTask(org.apache.nifi.reporting.ReportingTask) Test(org.junit.Test)

Example 3 with MockReportingInitializationContext

use of org.apache.nifi.mock.MockReportingInitializationContext in project nifi-minifi by apache.

the class ReportingTaskingInitializer method initialize.

@Override
public void initialize(ConfigurableComponent component) throws InitializationException {
    ReportingTask reportingTask = (ReportingTask) component;
    ReportingInitializationContext context = new MockReportingInitializationContext();
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), context.getIdentifier())) {
        reportingTask.initialize(context);
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) ReportingInitializationContext(org.apache.nifi.reporting.ReportingInitializationContext) MockReportingInitializationContext(org.apache.nifi.mock.MockReportingInitializationContext) MockReportingInitializationContext(org.apache.nifi.mock.MockReportingInitializationContext) ReportingTask(org.apache.nifi.reporting.ReportingTask)

Aggregations

MockReportingInitializationContext (org.apache.nifi.mock.MockReportingInitializationContext)3 ReportingTask (org.apache.nifi.reporting.ReportingTask)3 NarCloseable (org.apache.nifi.nar.NarCloseable)2 ReportingInitializationContext (org.apache.nifi.reporting.ReportingInitializationContext)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DocumentationWriter (org.apache.nifi.documentation.DocumentationWriter)1 FullyDocumentedReportingTask (org.apache.nifi.documentation.example.FullyDocumentedReportingTask)1 ReportingTaskWithLogger (org.apache.nifi.documentation.example.ReportingTaskWithLogger)1 Test (org.junit.Test)1