Search in sources :

Example 6 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class StandardFlowSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    final FlowFileEventRepository flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    final AuditService auditService = Mockito.mock(AuditService.class);
    final Map<String, String> otherProps = new HashMap<>();
    otherProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    otherProps.put("nifi.remote.input.socket.port", "");
    otherProps.put("nifi.remote.input.secure", "");
    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    final StringEncryptor encryptor = StringEncryptor.createEncryptor(nifiProperties);
    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    final AbstractPolicyBasedAuthorizer authorizer = new MockPolicyBasedAuthorizer();
    final VariableRegistry variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
    final BulletinRepository bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer, auditService, encryptor, bulletinRepo, variableRegistry, Mockito.mock(FlowRegistryClient.class));
    serializer = new StandardFlowSerializer(encryptor);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) HashMap(java.util.HashMap) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) VariableRegistry(org.apache.nifi.registry.VariableRegistry) AbstractPolicyBasedAuthorizer(org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) StringEncryptor(org.apache.nifi.encrypt.StringEncryptor) MockPolicyBasedAuthorizer(org.apache.nifi.authorization.MockPolicyBasedAuthorizer) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 7 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class TestFileBasedVariableRegistry method testCreateCustomVariableRegistry.

@Test
public void testCreateCustomVariableRegistry() {
    final Path fooPath = Paths.get("src/test/resources/TestVariableRegistry/foobar.properties");
    final Path testPath = Paths.get("src/test/resources/TestVariableRegistry/test.properties");
    Path[] paths = { fooPath, testPath };
    final String vendorUrl = System.getProperty("java.vendor.url");
    VariableRegistry variableRegistry = new FileBasedVariableRegistry(paths);
    final Map<VariableDescriptor, String> variables = variableRegistry.getVariableMap();
    assertTrue(variables.containsKey(new VariableDescriptor("fake.property.3")));
    assertEquals(vendorUrl, variableRegistry.getVariableValue("java.vendor.url"));
    assertEquals("test me out 3, test me out 4", variableRegistry.getVariableValue("fake.property.3"));
}
Also used : Path(java.nio.file.Path) VariableRegistry(org.apache.nifi.registry.VariableRegistry) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) VariableDescriptor(org.apache.nifi.registry.VariableDescriptor) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Test(org.junit.Test)

Aggregations

FileBasedVariableRegistry (org.apache.nifi.registry.variable.FileBasedVariableRegistry)7 AuditService (org.apache.nifi.admin.service.AuditService)5 FlowFileEventRepository (org.apache.nifi.controller.repository.FlowFileEventRepository)5 HashMap (java.util.HashMap)4 MockProvenanceRepository (org.apache.nifi.provenance.MockProvenanceRepository)4 Before (org.junit.Before)4 MockPolicyBasedAuthorizer (org.apache.nifi.authorization.MockPolicyBasedAuthorizer)3 BulletinRepository (org.apache.nifi.reporting.BulletinRepository)3 LinkedHashSet (java.util.LinkedHashSet)2 AccessPolicy (org.apache.nifi.authorization.AccessPolicy)2 Authorizer (org.apache.nifi.authorization.Authorizer)2 Group (org.apache.nifi.authorization.Group)2 User (org.apache.nifi.authorization.User)2 VolatileBulletinRepository (org.apache.nifi.events.VolatileBulletinRepository)2 VariableRegistry (org.apache.nifi.registry.VariableRegistry)2 FlowRegistryClient (org.apache.nifi.registry.flow.FlowRegistryClient)2 NiFiProperties (org.apache.nifi.util.NiFiProperties)2 Path (java.nio.file.Path)1 LinkedHashMap (java.util.LinkedHashMap)1 AbstractPolicyBasedAuthorizer (org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer)1