Search in sources :

Example 1 with MockControllerServiceInitializationContext

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

the class ControllerServiceInitializer method initialize.

@Override
public void initialize(ConfigurableComponent component) throws InitializationException {
    ControllerService controllerService = (ControllerService) component;
    ControllerServiceInitializationContext context = new MockControllerServiceInitializationContext();
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), context.getIdentifier())) {
        controllerService.initialize(context);
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) ControllerServiceInitializationContext(org.apache.nifi.controller.ControllerServiceInitializationContext) MockControllerServiceInitializationContext(org.apache.nifi.mock.MockControllerServiceInitializationContext) MockControllerServiceInitializationContext(org.apache.nifi.mock.MockControllerServiceInitializationContext) ControllerService(org.apache.nifi.controller.ControllerService)

Example 2 with MockControllerServiceInitializationContext

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

the class HtmlDocumentationWriterTest method testControllerServiceWithLogger.

@Test
public void testControllerServiceWithLogger() throws InitializationException, IOException {
    ControllerService controllerService = new ControllerServiceWithLogger();
    controllerService.initialize(new MockControllerServiceInitializationContext());
    DocumentationWriter writer = new HtmlDocumentationWriter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.write(controllerService, baos, false);
    String results = new String(baos.toByteArray());
    XmlValidator.assertXmlValid(results);
}
Also used : MockControllerServiceInitializationContext(org.apache.nifi.mock.MockControllerServiceInitializationContext) ControllerServiceWithLogger(org.apache.nifi.documentation.example.ControllerServiceWithLogger) DocumentationWriter(org.apache.nifi.documentation.DocumentationWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ControllerService(org.apache.nifi.controller.ControllerService) FullyDocumentedControllerService(org.apache.nifi.documentation.example.FullyDocumentedControllerService) Test(org.junit.Test)

Example 3 with MockControllerServiceInitializationContext

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

the class ControllerServiceInitializer method initialize.

@Override
public void initialize(ConfigurableComponent component) throws InitializationException {
    ControllerService controllerService = (ControllerService) component;
    ControllerServiceInitializationContext context = new MockControllerServiceInitializationContext();
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), context.getIdentifier())) {
        controllerService.initialize(context);
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) ControllerServiceInitializationContext(org.apache.nifi.controller.ControllerServiceInitializationContext) MockControllerServiceInitializationContext(org.apache.nifi.mock.MockControllerServiceInitializationContext) MockControllerServiceInitializationContext(org.apache.nifi.mock.MockControllerServiceInitializationContext) ControllerService(org.apache.nifi.controller.ControllerService)

Aggregations

ControllerService (org.apache.nifi.controller.ControllerService)3 MockControllerServiceInitializationContext (org.apache.nifi.mock.MockControllerServiceInitializationContext)3 ControllerServiceInitializationContext (org.apache.nifi.controller.ControllerServiceInitializationContext)2 NarCloseable (org.apache.nifi.nar.NarCloseable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DocumentationWriter (org.apache.nifi.documentation.DocumentationWriter)1 ControllerServiceWithLogger (org.apache.nifi.documentation.example.ControllerServiceWithLogger)1 FullyDocumentedControllerService (org.apache.nifi.documentation.example.FullyDocumentedControllerService)1 Test (org.junit.Test)1