@Test
public void addMetadataFromProperties() throws Exception {

  Map<String, String> metadataMap = new HashMap<>();
  Props inputProps = new Props();
  inputProps.put(Constants.ConfigurationKeys.AZKABAN_EVENT_REPORTING_PROPERTIES_TO_PROPAGATE, "my.prop1,my.prop2");
  inputProps.put("my.prop1", "value1");
  inputProps.put("my.prop2", "value2");
  // Test happy path
  FlowRunner.propagateMetadataFromProps(metadataMap, inputProps, "flow", "dummyFlow",
      Logger.getLogger(FlowRunnerTest.class));
  Assert.assertEquals("Metadata not propagated correctly.", 2, metadataMap.size());
  Assert.assertEquals("Metadata not propagated correctly.", "value1", metadataMap.get("my.prop1"));
  Assert.assertEquals("Metadata not propagated correctly.", "value2", metadataMap.get("my.prop2"));
  // Test backward compatibility: pass no value for AZKABAN_EVENT_REPORTING_PROPERTIES_TO_PROPAGATE and expect
  // .. nothing
  metadataMap = new HashMap<>();
  FlowRunner.propagateMetadataFromProps(metadataMap, new Props(), "flow", "dummyFlow",
      Logger.getLogger(FlowRunnerTest.class));
  Assert.assertEquals("Metadata propagation backward compatibility has issues.", 0, metadataMap.size());
  // Test negative path
  try {
    FlowRunner.propagateMetadataFromProps(null, inputProps, "flow", "dummyFlow",
        Logger.getLogger(FlowRunnerTest.class));
    Assert.fail("Metadata propagation did not fail with bad data.");
  } catch (Exception e) {
    // Ignore exception, since its expected.
  }
}