private NormalizedPath findConflictFilename(NormalizedPath conflictingPath) throws Exception { String conflictUserName = (config.getDisplayName() != null) ? config.getDisplayName() : config.getMachineName(); boolean conflictUserNameEndsWithS = conflictUserName.endsWith("s"); String conflictDate = new SimpleDateFormat("d MMM yy, h-mm a").format(new Date()); String conflictFilenameSuffix; if (conflictUserNameEndsWithS) { conflictFilenameSuffix = String.format("%s' conflicted copy, %s", conflictUserName, conflictDate); } else { conflictFilenameSuffix = String.format("%s's conflicted copy, %s", conflictUserName, conflictDate); } return conflictingPath.withSuffix(conflictFilenameSuffix, false); }
@Test public void testConfigHelperLoadConfigTO() throws Exception { // Setup Config testConfig = TestConfigUtil.createTestLocalConfig(); // Run ConfigTO loadedConfigTO = ConfigHelper.loadConfigTO(testConfig.getLocalDir()); // Test assertNotNull(loadedConfigTO); assertEquals(testConfig.getDisplayName(), loadedConfigTO.getDisplayName()); assertEquals(testConfig.getMachineName(), loadedConfigTO.getMachineName()); assertEquals(testConfig.getMasterKey(), loadedConfigTO.getMasterKey()); // Tear down TestConfigUtil.deleteTestLocalConfigAndData(testConfig); }
@Test public void testConfigHelperLoadConfig() throws Exception { // Setup Config testConfig = TestConfigUtil.createTestLocalConfig(); // Run Config loadedConfig = ConfigHelper.loadConfig(testConfig.getLocalDir()); // Test assertNotNull(loadedConfig); assertEquals(testConfig.getAppDir(), loadedConfig.getAppDir()); assertEquals(testConfig.getCacheDir(), loadedConfig.getCacheDir()); assertNotNull(loadedConfig.getChunker()); assertEquals(testConfig.getChunker().toString(), loadedConfig.getChunker().toString()); assertNotNull(loadedConfig.getCache()); assertNotNull(loadedConfig.getConnection()); assertEquals(testConfig.getDatabaseDir(), loadedConfig.getDatabaseDir()); assertEquals(testConfig.getDatabaseFile(), loadedConfig.getDatabaseFile()); assertEquals(testConfig.getDisplayName(), loadedConfig.getDisplayName()); assertEquals(testConfig.getLocalDir(), loadedConfig.getLocalDir()); assertEquals(testConfig.getLogDir(), loadedConfig.getLogDir()); assertEquals(testConfig.getMachineName(), loadedConfig.getMachineName()); assertEquals(testConfig.getMasterKey(), loadedConfig.getMasterKey()); assertNotNull(loadedConfig.getMultiChunker()); assertNotNull(loadedConfig.getRepoId()); assertNotNull(loadedConfig.getTransformer()); // Tear down TestConfigUtil.deleteTestLocalConfigAndData(testConfig); }