SoftwareHeritageOriginsImporter implements eu.dnetlib.iis.common.java.Process { protected static void storeNextElementIndex(int nextElementIndex) throws IOException { File file = new File(System.getProperty(OOZIE_ACTION_OUTPUT_FILENAME)); Properties props = new Properties(); if (file.exists()) { FileInputStream is = new FileInputStream(file); try { props.load(is); } finally { is.close(); } } props.put(OUTPUT_PROPERTY_NEXT_RECORD_INDEX, String.valueOf(nextElementIndex)); OutputStream os = new FileOutputStream(file); try { props.store(os, ""); } finally { os.close(); } } SoftwareHeritageOriginsImporter(); @Override Map<String, PortType> getInputPorts(); @Override Map<String, PortType> getOutputPorts(); @Override void run(PortBindings portBindings, Configuration conf, Map<String, String> parameters); static final String DEFAULT_METAFILE_NAME; }
@Test public void testStoreNextElementIndex() throws Exception { File propertyFile = tempFolder.newFile(); System.setProperty(WorkflowRuntimeParameters.OOZIE_ACTION_OUTPUT_FILENAME, propertyFile.getAbsolutePath()); int nextElementIndex = 2; SoftwareHeritageOriginsImporter.storeNextElementIndex(nextElementIndex); Properties props = new Properties(); try (FileInputStream fis = new FileInputStream(propertyFile)) { props.load(fis); assertEquals(String.valueOf(nextElementIndex), props.getProperty(SoftwareHeritageOriginsImporter.OUTPUT_PROPERTY_NEXT_RECORD_INDEX)); } }