From 319dd3d510320108083f553af557b786ee5cac80 Mon Sep 17 00:00:00 2001 From: plata Date: Mon, 29 Nov 2021 17:54:50 +0100 Subject: [PATCH] Re-enable LocalisationTest --- .../localisation/LocalisationTest.java | 153 ++++++++---------- 1 file changed, 70 insertions(+), 83 deletions(-) diff --git a/phoenicis-configuration/src/test/java/org/phoenicis/configuration/localisation/LocalisationTest.java b/phoenicis-configuration/src/test/java/org/phoenicis/configuration/localisation/LocalisationTest.java index 4b008753d42..9960cce7d5f 100644 --- a/phoenicis-configuration/src/test/java/org/phoenicis/configuration/localisation/LocalisationTest.java +++ b/phoenicis-configuration/src/test/java/org/phoenicis/configuration/localisation/LocalisationTest.java @@ -23,91 +23,78 @@ public class LocalisationTest { private static I18n mockI18n; + @Before + public void setUp() { + mockI18n = mock(I18n.class); + PowerMockito.doReturn("output").when(mockI18n).tr("input"); + PowerMockito.mockStatic(I18nFactory.class); + PowerMockito.when(I18nFactory.getI18n(any(), anyString())).thenReturn(mockI18n); + } + + @PrepareForTest({ I18nFactory.class, I18n.class }) + @Test + public synchronized void testTrWithAString() { + assertEquals("output", tr("input")); + } + + @PrepareForTest({ I18nFactory.class, I18n.class }) @Test - public synchronized void dummy() { + public synchronized void testTrWithNull() { + assertNull(tr(null)); } - // TODO: re-enable - /* - * @Before - * public void setUp() { - * mockI18n = mock(I18n.class); - * PowerMockito.doReturn("output").when(mockI18n).tr("input"); - * PowerMockito.mockStatic(I18nFactory.class); - * PowerMockito.when(I18nFactory.getI18n(any(), anyString())).thenReturn(mockI18n); - * } - * - * @PrepareForTest({ I18nFactory.class, I18n.class }) - * - * @Test - * public synchronized void testTrWithAString() { - * assertEquals("output", tr("input")); - * } - * - * @PrepareForTest({ I18nFactory.class, I18n.class }) - * - * @Test - * public synchronized void testTrWithNull() { - * assertNull(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()); - * } - */ + @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()); + } }