Java Code Examples for org.apache.nifi.registry.VariableRegistry#ENVIRONMENT_SYSTEM_REGISTRY

The following examples show how to use org.apache.nifi.registry.VariableRegistry#ENVIRONMENT_SYSTEM_REGISTRY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationServiceManager.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
public NotificationServiceManager() {
    this(VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY);
}
 
Example 2
Source File: TestValueLookup.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreateCustomVariableRegistry() {

    final VariableRegistry variableRegistry = VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY;
    final ValueLookup initialLookup = new ValueLookup(variableRegistry, null);
    assertTrue(initialLookup.containsKey("PATH"));
    assertFalse(initialLookup.containsKey("fake.property.3"));
    assertFalse(initialLookup.containsKey("fake"));

    final Map<String, String> otherAttrs = new HashMap<>();
    otherAttrs.put("fake", "test");
    otherAttrs.put("fake.property.3", "test me out 3, test me out 4");
    final ValueLookup newLookup = new ValueLookup(variableRegistry, null, otherAttrs);
    assertTrue(newLookup.containsKey("PATH"));
    assertTrue(newLookup.containsKey("fake.property.3"));
    assertEquals("test me out 3, test me out 4", newLookup.get("fake.property.3"));
    assertEquals("test", newLookup.get("fake"));
    assertFalse(newLookup.containsKey("filename"));

    final FlowFile fakeFile = createFlowFile();
    final ValueLookup ffLookup = new ValueLookup(variableRegistry, fakeFile, otherAttrs);
    assertTrue(ffLookup.containsKey("filename"));
    assertEquals("test", ffLookup.get("fake"));
    assertEquals("1", ffLookup.get("flowFileId"));
    assertEquals("50", ffLookup.get("fileSize"));
    assertEquals("1000", ffLookup.get("entryDate"));
    assertEquals("10000", ffLookup.get("lineageStartDate"));
    assertEquals("fakefile.txt", ffLookup.get("filename"));

    final Map<String, String> overrides = new HashMap<>();
    overrides.put("fake", "the real deal");
    final ValueLookup overriddenLookup = new ValueLookup(variableRegistry, fakeFile, overrides, otherAttrs);
    assertTrue(overriddenLookup.containsKey("filename"));
    assertEquals("the real deal", overriddenLookup.get("fake"));
    assertEquals("1", overriddenLookup.get("flowFileId"));
    assertEquals("50", overriddenLookup.get("fileSize"));
    assertEquals("1000", overriddenLookup.get("entryDate"));
    assertEquals("10000", overriddenLookup.get("lineageStartDate"));
    assertEquals("fakefile.txt", overriddenLookup.get("filename"));
    assertEquals("original", overriddenLookup.get("override me"));

    final Map<String, String> newOverrides = new HashMap<>();
    newOverrides.put("fake", "the real deal");
    newOverrides.put("override me", "done you are now overridden");
    final ValueLookup newOverriddenLookup = new ValueLookup(variableRegistry, fakeFile, newOverrides, otherAttrs);
    assertTrue(newOverriddenLookup.containsKey("filename"));
    assertEquals("the real deal", newOverriddenLookup.get("fake"));
    assertEquals("1", newOverriddenLookup.get("flowFileId"));
    assertEquals("50", newOverriddenLookup.get("fileSize"));
    assertEquals("1000", newOverriddenLookup.get("entryDate"));
    assertEquals("10000", newOverriddenLookup.get("lineageStartDate"));
    assertEquals("fakefile.txt", newOverriddenLookup.get("filename"));
    assertEquals("done you are now overridden", newOverriddenLookup.get("override me"));
}
 
Example 3
Source File: NotificationServiceManager.java    From nifi with Apache License 2.0 4 votes vote down vote up
public NotificationServiceManager() {
    this(VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY);
}
 
Example 4
Source File: StandardEvaluationContext.java    From nifi with Apache License 2.0 4 votes vote down vote up
public StandardEvaluationContext(final Map<String, String> variables, final Map<String, String> stateMap, final ParameterLookup parameterLookup) {
    this(new ValueLookup(VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY, null, variables), stateMap, parameterLookup);
}
 
Example 5
Source File: TestValueLookup.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testCreateCustomVariableRegistry() {

    final VariableRegistry variableRegistry = VariableRegistry.ENVIRONMENT_SYSTEM_REGISTRY;
    final ValueLookup initialLookup = new ValueLookup(variableRegistry, null);
    assertTrue(initialLookup.containsKey("PATH"));
    assertFalse(initialLookup.containsKey("fake.property.3"));
    assertFalse(initialLookup.containsKey("fake"));

    final Map<String, String> otherAttrs = new HashMap<>();
    otherAttrs.put("fake", "test");
    otherAttrs.put("fake.property.3", "test me out 3, test me out 4");
    final ValueLookup newLookup = new ValueLookup(variableRegistry, null, otherAttrs);
    assertTrue(newLookup.containsKey("PATH"));
    assertTrue(newLookup.containsKey("fake.property.3"));
    assertEquals("test me out 3, test me out 4", newLookup.get("fake.property.3"));
    assertEquals("test", newLookup.get("fake"));
    assertFalse(newLookup.containsKey("filename"));

    final FlowFile fakeFile = createFlowFile();
    final ValueLookup ffLookup = new ValueLookup(variableRegistry, fakeFile, otherAttrs);
    assertTrue(ffLookup.containsKey("filename"));
    assertEquals("test", ffLookup.get("fake"));
    assertEquals("1", ffLookup.get("flowFileId"));
    assertEquals("50", ffLookup.get("fileSize"));
    assertEquals("1000", ffLookup.get("entryDate"));
    assertEquals("10000", ffLookup.get("lineageStartDate"));
    assertEquals("fakefile.txt", ffLookup.get("filename"));

    final Map<String, String> overrides = new HashMap<>();
    overrides.put("fake", "the real deal");
    final ValueLookup overriddenLookup = new ValueLookup(variableRegistry, fakeFile, overrides, otherAttrs);
    assertTrue(overriddenLookup.containsKey("filename"));
    assertEquals("the real deal", overriddenLookup.get("fake"));
    assertEquals("1", overriddenLookup.get("flowFileId"));
    assertEquals("50", overriddenLookup.get("fileSize"));
    assertEquals("1000", overriddenLookup.get("entryDate"));
    assertEquals("10000", overriddenLookup.get("lineageStartDate"));
    assertEquals("fakefile.txt", overriddenLookup.get("filename"));
    assertEquals("original", overriddenLookup.get("override me"));

    final Map<String, String> newOverrides = new HashMap<>();
    newOverrides.put("fake", "the real deal");
    newOverrides.put("override me", "done you are now overridden");
    final ValueLookup newOverriddenLookup = new ValueLookup(variableRegistry, fakeFile, newOverrides, otherAttrs);
    assertTrue(newOverriddenLookup.containsKey("filename"));
    assertEquals("the real deal", newOverriddenLookup.get("fake"));
    assertEquals("1", newOverriddenLookup.get("flowFileId"));
    assertEquals("50", newOverriddenLookup.get("fileSize"));
    assertEquals("1000", newOverriddenLookup.get("entryDate"));
    assertEquals("10000", newOverriddenLookup.get("lineageStartDate"));
    assertEquals("fakefile.txt", newOverriddenLookup.get("filename"));
    assertEquals("done you are now overridden", newOverriddenLookup.get("override me"));
}