@Test public void testMoveKeyTask() { if (I18nModule.isTransToolEnabled()) { prepareDevToolTests(); Locale testLocale = i18nMgr.getLocaleOrDefault("de"); String ktm = "key.to.move"; i18nMgr.setCachingEnabled(true); Properties sourcePropResolved = i18nMgr.getResolvedProperties(testLocale, testSourceBundle); Properties sourceProp = i18nMgr.getPropertiesWithoutResolvingRecursively(testLocale, testSourceBundle); String matchString = sourceProp.getProperty(ktm); assertTrue(sourcePropResolved.getProperty("key.to.stay2").indexOf(matchString) != -1); tDMgr.moveKeyToOtherBundle(testSourceBundle, testTargetBundle, ktm); sourceProp = i18nMgr.getPropertiesWithoutResolvingRecursively(testLocale, testSourceBundle); Properties targetProp = i18nMgr.getPropertiesWithoutResolvingRecursively(testLocale, testTargetBundle); assertNull(sourceProp.getProperty(ktm)); assertNotNull(targetProp.getProperty(ktm)); Properties sourceMetaProp = i18nMgr.getPropertiesWithoutResolvingRecursively(null, testSourceBundle); Properties targetMetaProp = i18nMgr.getPropertiesWithoutResolvingRecursively(null, testTargetBundle); assertNull(sourceMetaProp.getProperty(ktm + I18nManager.METADATA_ANNOTATION_POSTFIX)); assertNull(sourceMetaProp.getProperty(ktm + I18nManager.METADATA_KEY_PRIORITY_POSTFIX)); assertTrue(targetMetaProp.containsKey(ktm + I18nManager.METADATA_ANNOTATION_POSTFIX)); assertEquals( "100", targetMetaProp.getProperty(ktm + I18nManager.METADATA_KEY_PRIORITY_POSTFIX)); // check for changed references in value // if correctly done, should still be resolvable assertTrue(sourcePropResolved.getProperty("key.to.stay2").indexOf(matchString) != -1); } }
@Test public void testRemoveDeletedKeysTest() { // set languages that is used as reference: all keys there are the keys should not to be deleted String[] referenceLanguages = new String[] {"de", "en"}; // set the languages that should be cleaned up Set<String> targetLanguages = I18nModule.getTranslatableLanguageKeys(); // Set<String> targetLanguages = new HashSet<String>(); // targetLanguages.add("en"); tDMgr.removeDeletedKeys(false, referenceLanguages, targetLanguages); }
@Test public void testMergePackageTask() { if (I18nModule.isTransToolEnabled()) { prepareDevToolTests(); tDMgr.mergePackageTask(testSourceBundle, testTargetBundle); i18nMgr.clearCaches(); assertTrue( i18nMgr.getPropertiesWithoutResolvingRecursively(null, testSourceBundle).isEmpty()); // TODO: manipulate source/target first, merge and check if all is in target! // try to merge existing key } }
@Test public void testMovePackageByMovingSingleKeysTask() { if (I18nModule.isTransToolEnabled()) { prepareDevToolTests(); tDMgr.movePackageByMovingSingleKeysTask(testSourceBundle, testTargetBundle); i18nMgr.clearCaches(); Properties sourceProp = i18nMgr.getPropertiesWithoutResolvingRecursively(null, testSourceBundle); assertTrue(sourceProp.isEmpty()); Properties targetProp = i18nMgr.getPropertiesWithoutResolvingRecursively(null, testTargetBundle); assertFalse(targetProp.isEmpty()); } }
@Test public void testMoveLanguageTask() { if (I18nModule.isTransToolEnabled()) { prepareDevToolTests(); String srcPath = I18nModule.getTransToolApplicationLanguagesSrcDir().getAbsolutePath() + "/../../test/java/org/olat/core/util/i18n/junittestdata/devtools"; String targetPath = srcPath + "/../movetarget"; // only copy: target should exist Locale mvLocale = i18nMgr.getLocaleOrDefault("de"); // test before move Properties sourceProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(mvLocale, testSourceBundle); assertFalse(sourceProperties.isEmpty()); Properties moveProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(mvLocale, testMoveTargetBundle); assertTrue(moveProperties.isEmpty()); // copy tDMgr.moveLanguageTask(mvLocale, srcPath, targetPath, false); // test after copy sourceProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(mvLocale, testSourceBundle); assertFalse(sourceProperties.isEmpty()); moveProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(mvLocale, testMoveTargetBundle); assertFalse(moveProperties.isEmpty()); // move tDMgr.moveLanguageTask(mvLocale, srcPath, targetPath, true); // test after move sourceProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(mvLocale, testSourceBundle); assertTrue(sourceProperties.isEmpty()); moveProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(mvLocale, testMoveTargetBundle); assertFalse(moveProperties.isEmpty()); } }
@Test public void testRenameLanguageTask() { if (I18nModule.isTransToolEnabled()) { prepareDevToolTests(); // create source Locale xxLocale = new Locale("xx"); String key = "key.to.move"; I18nItem i18nItem = i18nMgr.getI18nItem(testSourceBundle, key, xxLocale); i18nMgr.saveOrUpdateI18nItem(i18nItem, "I have to go"); i18nMgr.setAnnotation(i18nItem, "an annotation"); i18nMgr.setKeyPriority(testSourceBundle, key, 100); // copy to target Locale yyLocale = new Locale("yy"); tDMgr.renameLanguageTask(xxLocale, yyLocale); i18nMgr.clearCaches(); // test Properties deletedProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(xxLocale, testSourceBundle); assertTrue(deletedProperties.isEmpty()); Properties targetProp = i18nMgr.getPropertiesWithoutResolvingRecursively(yyLocale, testSourceBundle); assertFalse(targetProp.isEmpty()); } }
// remove after execution! @Test public void testRemoveReferenceLanguageCopiesTask() { if (I18nModule.isTransToolEnabled()) { tDMgr.removeReferenceLanguageCopiesTask(false); } }
// remove after execution! @Test public void testRemoveEmptyKeysTask() { tDMgr.removeEmptyKeysTask(false); }
// remove after execution! @Test public void testRemoveTodoKeyTask() { tDMgr.removeTodoKeysTask(false); }
// TODO: RH: remove this or really test for correct finding?! @Test public void testGetDouplicateValues() { tDMgr.getDouplicateValues(); }
// TODO: RH: remove this or really test for correct finding?! @Test public void testGetDouplicateKeys() { tDMgr.getDouplicateKeys(); }