use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testEscaped.
@Test
public void testEscaped() {
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 testGetValueAsIntegerAfterSubstitute.
@Test
public void testGetValueAsIntegerAfterSubstitute() {
final PropertyValue value = new StandardPropertyValue("1${value}", lookup);
final Map<String, String> attributes = new HashMap<>();
attributes.put("value", "39");
assertEquals(139, value.evaluateAttributeExpressions(createFlowFile(attributes)).asInteger().intValue());
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testFlowFileEntryYear.
@Test
public void testFlowFileEntryYear() {
final Calendar now = Calendar.getInstance();
final int year = now.get(Calendar.YEAR);
final PropertyValue value = new StandardPropertyValue("${entryDate:toNumber():toDate():format('yyyy')}", lookup);
final FlowFile flowFile = new StandardFlowFileRecord.Builder().entryDate(now.getTimeInMillis()).build();
final int val = value.evaluateAttributeExpressions(flowFile).asInteger().intValue();
assertEquals(year, val);
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testSubstituteAttributesWithOneMatchingArg.
@Test
public void testSubstituteAttributesWithOneMatchingArg() {
final PropertyValue value = new StandardPropertyValue("Hello, ${audience}!", lookup);
final Map<String, String> attributes = new HashMap<>();
attributes.put("audience", "World");
assertEquals("Hello, World!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue());
}
use of org.apache.nifi.attribute.expression.language.StandardPropertyValue in project nifi by apache.
the class TestStandardPropertyValue method testFileSize.
@Test
public void testFileSize() {
final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup);
final FlowFile flowFile = new StandardFlowFileRecord.Builder().size(1024 * 1024L).build();
final long val = value.evaluateAttributeExpressions(flowFile).asLong().longValue();
assertEquals(1024 * 1024L, val);
}
Aggregations