PGETaskInstance implements WorkflowTaskInstance { protected void createDynamicConfigFile(DynamicConfigFile dynamicConfigFile) throws PGEException, IOException { Validate.notNull(dynamicConfigFile, "dynamicConfigFile cannot be null"); logger.debug("Starting creation of sci pge config file: {}", dynamicConfigFile.getFilePath()); File parentDir = new File(dynamicConfigFile.getFilePath()).getParentFile(); if (!(parentDir.exists() || parentDir.mkdirs())) { logger.warn("Unable to create directory({}) with sci pge config file", dynamicConfigFile.getFilePath()); throw new PGEException("Failed to create directory where sci pge config file [" + dynamicConfigFile.getFilePath() + "] was to be written"); } logger.debug("Loading writer class for sci pge config file [{}]", dynamicConfigFile.getFilePath()); SciPgeConfigFileWriter writer = createSciPgeConfigFileWriter(dynamicConfigFile.getWriterClass(), logger); logger.debug("Loaded writer [{}] for sci pge config file [{}]", writer.getClass().getCanonicalName(),dynamicConfigFile.getFilePath()); logger.info("Writing sci pge config file [{}]", dynamicConfigFile.getFilePath()); File configFile = writer.createConfigFile(dynamicConfigFile.getFilePath(), pgeMetadata.asMetadata(), dynamicConfigFile.getArgs()); if (!configFile.exists()) { logger.warn("Failed to create config file '{}'. File doesn't exist", configFile); throw new PGEException("Writer failed to create config file [" + configFile + "], exists returned false"); } } 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 testCreateDynamicConfigFile() throws Exception { File tmpDir = createTmpDir(); FileUtils.forceDelete(tmpDir); assertFalse(tmpDir.exists()); PGETaskInstance pgeTask = createTestInstance(); File dynamicConfigFile = new File(tmpDir, "DynamicConfig.xml"); assertFalse(dynamicConfigFile.exists()); pgeTask.createDynamicConfigFile(new DynamicConfigFile(dynamicConfigFile.getAbsolutePath(), MockDynamicConfigFileWriter.class.getCanonicalName(), new Object[] {})); assertTrue(dynamicConfigFile.exists()); }