use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestWriteAheadLocalStateProvider method setup.
@Before
public void setup() throws IOException {
provider = new WriteAheadLocalStateProvider();
final Map<PropertyDescriptor, PropertyValue> properties = new HashMap<>();
properties.put(WriteAheadLocalStateProvider.PATH, new StandardPropertyValue("target/local-state-provider/" + UUID.randomUUID().toString(), null));
properties.put(WriteAheadLocalStateProvider.ALWAYS_SYNC, new StandardPropertyValue("false", null));
properties.put(WriteAheadLocalStateProvider.CHECKPOINT_INTERVAL, new StandardPropertyValue("2 mins", null));
properties.put(WriteAheadLocalStateProvider.NUM_PARTITIONS, new StandardPropertyValue("16", null));
provider.initialize(new StateProviderInitializationContext() {
@Override
public String getIdentifier() {
return "Unit Test Provider Initialization Context";
}
@Override
public Map<PropertyDescriptor, PropertyValue> getProperties() {
return Collections.unmodifiableMap(properties);
}
@Override
public Map<String, String> getAllProperties() {
final Map<String, String> propValueMap = new LinkedHashMap<>();
for (final Map.Entry<PropertyDescriptor, PropertyValue> entry : getProperties().entrySet()) {
propValueMap.put(entry.getKey().getName(), entry.getValue().getValue());
}
return propValueMap;
}
@Override
public PropertyValue getProperty(final PropertyDescriptor property) {
final PropertyValue prop = properties.get(property);
if (prop == null) {
return new StandardPropertyValue(null, null);
}
return prop;
}
@Override
public SSLContext getSSLContext() {
return null;
}
@Override
public ComponentLog getLogger() {
return null;
}
});
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testSubstituteAttributesWithNoMatch.
@Test
public void testSubstituteAttributesWithNoMatch() {
final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question:replaceNull('')}!", lookup);
final Map<String, String> attributes = new HashMap<>();
assertEquals("Hello, !", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue());
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testMissingEndBraceEvaluatesToStringLiteral.
@Test
public void testMissingEndBraceEvaluatesToStringLiteral() {
final PropertyValue value = new StandardPropertyValue("Hello, ${audience!", lookup);
final Map<String, String> attributes = new HashMap<>();
attributes.put("audience", "World");
assertEquals("Hello, ${audience!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue());
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testSubstituteAttributesWithMultipleMatchingArgs.
@Test
public void testSubstituteAttributesWithMultipleMatchingArgs() {
final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question}!", lookup);
final Map<String, String> attributes = new HashMap<>();
attributes.put("audience", "World");
attributes.put("comma", ",");
attributes.put("question", " how are you?");
assertEquals("Hello, World, how are you?!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue());
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class StandardManagedAuthorizerTest method getStandardManagedAuthorizer.
private StandardManagedAuthorizer getStandardManagedAuthorizer(final AccessPolicyProvider accessPolicyProvider) {
final StandardManagedAuthorizer managedAuthorizer = new StandardManagedAuthorizer();
final AuthorizerConfigurationContext configurationContext = mock(AuthorizerConfigurationContext.class);
when(configurationContext.getProperty("Access Policy Provider")).thenReturn(new StandardPropertyValue("access-policy-provider", null));
final AccessPolicyProviderLookup accessPolicyProviderLookup = mock(AccessPolicyProviderLookup.class);
when(accessPolicyProviderLookup.getAccessPolicyProvider("access-policy-provider")).thenReturn(accessPolicyProvider);
final AuthorizerInitializationContext initializationContext = mock(AuthorizerInitializationContext.class);
when(initializationContext.getAccessPolicyProviderLookup()).thenReturn(accessPolicyProviderLookup);
managedAuthorizer.initialize(initializationContext);
managedAuthorizer.onConfigured(configurationContext);
return managedAuthorizer;
}
Aggregations