Java Code Examples for org.apache.nifi.components.PropertyValue#evaluateAttributeExpressions()

The following examples show how to use org.apache.nifi.components.PropertyValue#evaluateAttributeExpressions() . 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: ParametersIT.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testSensitivePropertyReferenceParameterSupportsEL() {
    final ProcessorNode usernamePassword = createProcessorNode(UsernamePasswordProcessor.class);

    final ParameterReferenceManager referenceManager = new StandardParameterReferenceManager(getFlowController().getFlowManager());
    final ParameterContext parameterContext = new StandardParameterContext(UUID.randomUUID().toString(), "param-context", referenceManager, null);
    parameterContext.setParameters(Collections.singletonMap("pass", new Parameter(new ParameterDescriptor.Builder().name("pass").sensitive(true).build(), "secret")));

    getRootGroup().setParameterContext(parameterContext);

    final Map<String, String> properties = new HashMap<>();
    properties.put("password", "#{pass}");
    usernamePassword.setProperties(properties);

    final ProcessContext processContext = new StandardProcessContext(usernamePassword, getFlowController().getControllerServiceProvider(), getFlowController().getEncryptor(),
        getFlowController().getStateManagerProvider().getStateManager(usernamePassword.getIdentifier()), () -> false);
    final PropertyDescriptor descriptor = usernamePassword.getPropertyDescriptor("password");
    final PropertyValue propertyValue = processContext.getProperty(descriptor);
    final PropertyValue evaluatedPropertyValue = propertyValue.evaluateAttributeExpressions();
    final String evaluatedPassword = evaluatedPropertyValue.getValue();
    assertEquals("secret", evaluatedPassword);
}
 
Example 2
Source File: TestStandardPropertyValue.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test(expected = NumberFormatException.class)
public void testGetValueAsIntegerAfterSubstitutingWithNonInteger() {
    final PropertyValue value = new StandardPropertyValue("1${value}", lookup);
    final Map<String, String> attributes = new HashMap<>();
    attributes.put("value", "Yes");
    final PropertyValue substituted = value.evaluateAttributeExpressions(createFlowFile(attributes));
    substituted.asInteger();
}
 
Example 3
Source File: TestStandardPropertyValue.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test(expected = NumberFormatException.class)
public void testGetValueAsIntegerAfterSubstitutingWithNonInteger() {
    final PropertyValue value = new StandardPropertyValue("1${value}", lookup, ParameterLookup.EMPTY);
    final Map<String, String> attributes = new HashMap<>();
    attributes.put("value", "Yes");
    final PropertyValue substituted = value.evaluateAttributeExpressions(createFlowFile(attributes));
    substituted.asInteger();
}