Localisation { public static String tr(String text, Object o1) { return text == null ? null : getI18n().tr(text, o1); } private  Localisation(); static void setAdditionalTranslations(PropertiesResourceBundle resourceBundle); static String tr(String text, Object o1); static String tr(String text, Object o1, Object o2); static String tr(String text, Object o1, Object o2, Object o3); static String tr(String text, Object o1, Object o2, Object o3, Object o4); static String tr(String text, Object[] objects); static T tr(T translatable); static boolean isTranslatable(Class<?> clazz);  }
@PrepareForTest({ I18nFactory.class, I18n.class }) @Test public synchronized void testTrWithAString() { assertEquals("output", tr("input")); }
@PrepareForTest({ I18nFactory.class, I18n.class }) @Test public synchronized void testTrWithNull() { assertEquals(null, tr(null)); }
@PrepareForTest({ I18nFactory.class, I18n.class }) @Test public synchronized void testSimpleTranslatableObject() { final SimpleTranslatableObject translatableObject = new SimpleTranslatableObject("input", "input"); assertEquals("input", translatableObject.getItemNotToBeTranslated()); assertEquals("input", translatableObject.getItemToBeTranslated()); final SimpleTranslatableObject translatedObject = tr(translatableObject); assertEquals("input", translatedObject.getItemNotToBeTranslated()); assertEquals("output", translatedObject.getItemToBeTranslated()); }
@PrepareForTest({ I18nFactory.class, I18n.class }) @Test public synchronized void testSimpleTranslatableObjectWithBuilder() { final SimpleTranslatableObjectBuilder translatableObject = new SimpleTranslatableObjectBuilder.Builder() .withItemNotToBeTranslated("input").withItemToBeTranslated("input").build(); assertEquals("input", translatableObject.getItemNotToBeTranslated()); assertEquals("input", translatableObject.getItemToBeTranslated()); final SimpleTranslatableObjectBuilder translatedObject = tr(translatableObject); assertEquals("input", translatedObject.getItemNotToBeTranslated()); assertEquals("output", translatedObject.getItemToBeTranslated()); }
@PrepareForTest({ I18nFactory.class, I18n.class }) @Test public synchronized void testTreeTranslatableObject() { final TreeTranslatableObject treeTranslatableObject = new TreeTranslatableObject( new SimpleTranslatableObject("input", "input"), new SimpleTranslatableObject("input", "input")); assertEquals("input", treeTranslatableObject.getItemNotToBeTranslated().getItemToBeTranslated()); assertEquals("input", treeTranslatableObject.getItemNotToBeTranslated().getItemNotToBeTranslated()); assertEquals("input", treeTranslatableObject.getItemToBeTranslated().getItemToBeTranslated()); assertEquals("input", treeTranslatableObject.getItemToBeTranslated().getItemNotToBeTranslated()); final TreeTranslatableObject translatedObject = tr(treeTranslatableObject); assertEquals("input", translatedObject.getItemNotToBeTranslated().getItemToBeTranslated()); assertEquals("input", translatedObject.getItemNotToBeTranslated().getItemNotToBeTranslated()); assertEquals("output", translatedObject.getItemToBeTranslated().getItemToBeTranslated()); assertEquals("input", translatedObject.getItemToBeTranslated().getItemNotToBeTranslated()); }
@PrepareForTest({ I18nFactory.class, I18n.class }) @Test public synchronized void testTreeTranslatableCollectionObject() { final CollectionsOfTranslatableObject collectionsOfTranslatableObject = new CollectionsOfTranslatableObject( Arrays.asList("input", "input"), Arrays.asList("input", "input")); final CollectionsOfTranslatableObject translatedObject = tr(collectionsOfTranslatableObject); assertEquals(Arrays.asList("input", "input"), translatedObject.getItemNotToBeTranslated()); assertEquals(Arrays.asList("output", "output"), translatedObject.getItemToBeTranslated()); }