PGETaskInstance implements WorkflowTaskInstance { protected void runPropertyAdders() throws PGEException { try { logger.info("Loading/Running property adders..."); List<String> propertyAdders = pgeMetadata.getAllMetadata(PROPERTY_ADDERS); if (propertyAdders != null) { for (String propertyAdder : propertyAdders) { runPropertyAdder(loadPropertyAdder(propertyAdder)); } } else { logger.info("No property adders specified"); } } catch (Exception e) { logger.error("Error occurred when running property adders", e); throw new PGEException("Failed to instantiate/run Property Adders : " + e.getMessage(), e); } } protected  PGETaskInstance(); @Override void run(Metadata metadata, WorkflowTaskConfiguration config); String getWorkflowInstId(); void setWorkflowInstId(String workflowInstId); void setWmClient(WorkflowManagerClient wmClient); @Override void finalize();  }
@Test public void testRunPropertyAdders() throws Exception { PGETaskInstance pgeTask = createTestInstance(); pgeTask.pgeMetadata.replaceMetadata(PROPERTY_ADDERS, MockConfigFilePropertyAdder.class.getCanonicalName()); pgeTask.pgeConfig.setPropertyAdderCustomArgs(new Object[] { "key", "value" }); pgeTask.runPropertyAdders(); assertEquals("value", pgeTask.pgeMetadata.getMetadata("key")); pgeTask.pgeMetadata.replaceMetadata( MockConfigFilePropertyAdder.RUN_COUNTER, "0"); pgeTask.pgeMetadata.replaceMetadata(PROPERTY_ADDERS, Lists.newArrayList( MockConfigFilePropertyAdder.class.getCanonicalName(), MockConfigFilePropertyAdder.class.getCanonicalName())); pgeTask.runPropertyAdders(); assertEquals("value", pgeTask.pgeMetadata.getMetadata("key")); assertEquals("2", pgeTask.pgeMetadata .getMetadata(MockConfigFilePropertyAdder.RUN_COUNTER)); pgeTask.pgeMetadata.replaceMetadata( MockConfigFilePropertyAdder.RUN_COUNTER, "0"); System.setProperty(PgeTaskMetKeys.USE_LEGACY_PROPERTY, "true"); pgeTask.pgeMetadata.replaceMetadata(PROPERTY_ADDERS.getName(), MockConfigFilePropertyAdder.class.getCanonicalName()); pgeTask.runPropertyAdders(); assertEquals("value", pgeTask.pgeMetadata.getMetadata("key")); assertEquals("1", pgeTask.pgeMetadata .getMetadata(MockConfigFilePropertyAdder.RUN_COUNTER)); System.getProperties().remove(PgeTaskMetKeys.USE_LEGACY_PROPERTY); }