JobDirecotry { public File convertInputFile(File jobInputFile) { String jobInputFileStr = jobInputFile.getAbsolutePath().replaceAll("\\\\", "/"); File jobInputBaseDir = new File(getJobDir(), "input"); String jobInputBaseDirStr = jobInputBaseDir.getAbsolutePath().replaceAll("\\\\", "/"); if (!jobInputFileStr.startsWith(jobInputBaseDirStr)) { return null; } if (jobInputBaseDirStr.length() == jobInputFileStr.length()) { return new File(getJobDir(), "input"); } String relativePath = jobInputFileStr.substring(jobInputBaseDirStr.length()); if (relativePath.equals("/")) { return new File(getJobDir(), "input"); } if (relativePath.startsWith("/")) { relativePath = relativePath.substring(1); } int index = relativePath.indexOf("/"); if (index == -1) { return new File(WareHouse.getInstance().getWarehouseDir(), relativePath); } String projectName = relativePath.substring(0, index); relativePath = relativePath.substring(index); return new File(WareHouse.getInstance().getWarehouseDir(), projectName + File.separator + Constants.TABLES_DIR + File.separator + relativePath); }  File getJobDir(); File getJobFile(); File getInputBaseDir(); File getOutputBaseDir(); File getInputDir(String relativePath); File convertInputFile(File jobInputFile); File getOutputDir(String label); File getResourceDir(); boolean hasResource(String resourceName);  }
@Test public void testConvertInputFile() { asertTrue("temp/mr_20150212083126_505_21462/input"); asertTrue("temp/mr_20150212083126_505_21462/input/"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2/"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2/p1=1"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2/p1=1/"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2/p1=1/p2=2"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2/p1=1/p2=2/"); asertTrue("temp/mr_20150212083126_505_21462/input/project_name/wc_in2/p1=1/p2=2/data"); }