From 2cdcfca5e28402a56c68cab9889834b2e17d032a Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Fri, 2 Aug 2024 14:54:45 +0300 Subject: [PATCH 01/11] Add tests for MenuService --- .../org/openelisglobal/AppTestConfig.java | 2 +- .../openelisglobal/menu/MenuServiceTest.java | 94 +++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/openelisglobal/menu/MenuServiceTest.java diff --git a/src/test/java/org/openelisglobal/AppTestConfig.java b/src/test/java/org/openelisglobal/AppTestConfig.java index a5260620be..2e1b781ce4 100644 --- a/src/test/java/org/openelisglobal/AppTestConfig.java +++ b/src/test/java/org/openelisglobal/AppTestConfig.java @@ -50,7 +50,7 @@ "org.openelisglobal.systemusermodule.service", "org.openelisglobal.rolemodule.service", "org.openelisglobal.systemusermodule.daoimpl", "org.openelisglobal.systemusermodule.service", "org.openelisglobal.login.service", "org.openelisglobal.view", "org.openelisglobal.search.service", - "org.openelisglobal.sample.daoimpl", }, excludeFilters = { + "org.openelisglobal.sample.daoimpl","org.openelisglobal.menu.MenuServiceTest", "org.openelisglobal.menu" }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.dictionary.controller.*.java"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.config.*"), diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java new file mode 100644 index 0000000000..5d2d484b3f --- /dev/null +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -0,0 +1,94 @@ +package org.openelisglobal.menu; + +import org.openelisglobal.BaseWebContextSensitiveTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openelisglobal.menu.service.MenuService; +import org.openelisglobal.menu.util.MenuItem; +import org.openelisglobal.menu.valueholder.Menu; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; + +import static org.junit.Assert.*; + +public class MenuServiceTest extends BaseWebContextSensitiveTest { + @Autowired + private MenuService menuService; + + @Before + public void setUp() { + // Setup code here if needed + } + + @After + public void tearDown() { + // Tear down code here if needed + } + + @Test + public void testSaveSingleMenuItem() { + // Create and save a MenuItem + MenuItem menuItem = new MenuItem(); + Menu menu = new Menu(); + menu.setElementId("testElement"); + menuItem.setMenu(menu); + + MenuItem savedItem = menuService.save(menuItem); + + // Assertions + assertNotNull(savedItem); + + } + + @Test + public void testSaveMultipleMenuItems() { + // Create and save multiple MenuItems + MenuItem menuItem1 = new MenuItem(); + Menu menu1 = new Menu(); + menu1.setElementId("testElement1"); + menuItem1.setMenu(menu1); + + MenuItem menuItem2 = new MenuItem(); + Menu menu2 = new Menu(); + menu2.setElementId("testElement2"); + menuItem2.setMenu(menu2); + + List menuItems = List.of(menuItem1, menuItem2); + + List savedItems = menuService.save(menuItems); + + // Assertions + assertNotNull(savedItems); + assertEquals(2, savedItems.size()); + } + + @Test + public void testGetAllActiveMenus() { + // Create and save active and inactive MenuItems + MenuItem activeItem = new MenuItem(); + Menu activeMenu = new Menu(); + activeMenu.setElementId("activeElement"); + activeMenu.setIsActive(true); + activeItem.setMenu(activeMenu); + menuService.save(activeItem); + + MenuItem inactiveItem = new MenuItem(); + Menu inactiveMenu = new Menu(); + inactiveMenu.setElementId("inactiveElement"); + inactiveMenu.setIsActive(false); + inactiveItem.setMenu(inactiveMenu); + menuService.save(inactiveItem); + + // Retrieve all active menus + List activeMenus = menuService.getAllActiveMenus(); + + // Assertions + assertNotNull(activeMenus); + assertFalse(activeMenus.isEmpty()); + assertTrue(activeMenus.stream().allMatch(Menu::getIsActive)); + } + + +} + From 954f280e95a52ffac24751aaef0b30f39c4050d3 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Sat, 3 Aug 2024 22:16:17 +0300 Subject: [PATCH 02/11] Add-More-menu-service-tests --- .../org/openelisglobal/AppTestConfig.java | 3 +- .../openelisglobal/menu/MenuServiceTest.java | 144 +++++++++++++++++- 2 files changed, 139 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/openelisglobal/AppTestConfig.java b/src/test/java/org/openelisglobal/AppTestConfig.java index 2e1b781ce4..666a3a7547 100644 --- a/src/test/java/org/openelisglobal/AppTestConfig.java +++ b/src/test/java/org/openelisglobal/AppTestConfig.java @@ -50,7 +50,8 @@ "org.openelisglobal.systemusermodule.service", "org.openelisglobal.rolemodule.service", "org.openelisglobal.systemusermodule.daoimpl", "org.openelisglobal.systemusermodule.service", "org.openelisglobal.login.service", "org.openelisglobal.view", "org.openelisglobal.search.service", - "org.openelisglobal.sample.daoimpl","org.openelisglobal.menu.MenuServiceTest", "org.openelisglobal.menu" }, excludeFilters = { + "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", + "org.openelisglobal.menu" }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.dictionary.controller.*.java"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.config.*"), diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index 5d2d484b3f..8c60d880a6 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -1,16 +1,19 @@ package org.openelisglobal.menu; -import org.openelisglobal.BaseWebContextSensitiveTest; +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.openelisglobal.BaseWebContextSensitiveTest; +import org.openelisglobal.menu.form.AdminMenuForm; import org.openelisglobal.menu.service.MenuService; import org.openelisglobal.menu.util.MenuItem; +import org.openelisglobal.menu.valueholder.AdminMenuItem; import org.openelisglobal.menu.valueholder.Menu; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; - -import static org.junit.Assert.*; public class MenuServiceTest extends BaseWebContextSensitiveTest { @Autowired @@ -18,12 +21,10 @@ public class MenuServiceTest extends BaseWebContextSensitiveTest { @Before public void setUp() { - // Setup code here if needed } @After public void tearDown() { - // Tear down code here if needed } @Test @@ -89,6 +90,135 @@ public void testGetAllActiveMenus() { assertTrue(activeMenus.stream().allMatch(Menu::getIsActive)); } + @Test + public void testGetSetAdminMenuItems() { + AdminMenuForm form = new AdminMenuForm(); + + List adminMenuItems = new ArrayList<>(); + AdminMenuItem item1 = new AdminMenuItem(); + item1.setPath("/path1"); + AdminMenuItem item2 = new AdminMenuItem(); + item2.setPath("/path2"); + adminMenuItems.add(item1); + adminMenuItems.add(item2); + + form.setAdminMenuItems(adminMenuItems); + + List result = form.getAdminMenuItems(); + assertNotNull(result); + assertEquals(2, result.size()); + assertEquals("/path1", result.get(0).getPath()); + assertEquals("/path2", result.get(1).getPath()); + } + + @Test + public void testGetSetTotalRecordCount() { + AdminMenuForm form = new AdminMenuForm(); + form.setTotalRecordCount("100"); + assertEquals("100", form.getTotalRecordCount()); + } -} + @Test + public void testGetSetFromRecordCount() { + AdminMenuForm form = new AdminMenuForm(); + form.setFromRecordCount("10"); + assertEquals("10", form.getFromRecordCount()); + } + + @Test + public void testGetSetToRecordCount() { + AdminMenuForm form = new AdminMenuForm(); + form.setToRecordCount("20"); + assertEquals("20", form.getToRecordCount()); + } + + @Test + public void testGetSetPresentationOrder() { + Menu menu = new Menu(); + menu.setPresentationOrder(1); + assertEquals(1, menu.getPresentationOrder()); + } + + @Test + public void testGetSetElementId() { + Menu menu = new Menu(); + menu.setElementId("elementId"); + assertEquals("elementId", menu.getElementId()); + } + + @Test + public void testGetSetActionURL() { + Menu menu = new Menu(); + menu.setActionURL("http://example.com"); + assertEquals("http://example.com", menu.getActionURL()); + } + + @Test + public void testGetSetClickAction() { + Menu menu = new Menu(); + menu.setClickAction("clickAction"); + assertEquals("clickAction", menu.getClickAction()); + } + @Test + public void testGetSetDisplayKey() { + Menu menu = new Menu(); + menu.setDisplayKey("displayKey"); + assertEquals("displayKey", menu.getDisplayKey()); + } + + @Test + public void testGetSetToolTipKey() { + Menu menu = new Menu(); + menu.setToolTipKey("toolTipKey"); + assertEquals("toolTipKey", menu.getToolTipKey()); + } + + @Test + public void testGetSetParent() { + Menu parentMenu = new Menu(); + Menu childMenu = new Menu(); + childMenu.setParent(parentMenu); + assertEquals(parentMenu, childMenu.getParent()); + } + + @Test + public void testGetLocalizedTitle() { + Menu menu = new Menu(); + menu.setDisplayKey("testDisplayKey"); + + String title = menu.getLocalizedTitle(); + assertNotNull(title); + } + + @Test + public void testGetLocalizedTooltip() { + Menu menu = new Menu(); + menu.setToolTipKey("testToolTipKey"); + + String tooltip = menu.getLocalizedTooltip(); + assertNotNull(tooltip); + + } + + @Test + public void testSetGetOpenInNewWindow() { + Menu menu = new Menu(); + menu.setOpenInNewWindow(true); + assertTrue(menu.isOpenInNewWindow()); + } + + @Test + public void testSetGetIsActive() { + Menu menu = new Menu(); + menu.setIsActive(true); + assertTrue(menu.getIsActive()); + } + + @Test + public void testSetGetHideInOldUI() { + Menu menu = new Menu(); + menu.setHideInOldUI(true); + assertTrue(menu.isHideInOldUI()); + } +} From ac5e6a24286086740a17be9205b1433dd26b5477 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Sun, 4 Aug 2024 18:55:22 +0300 Subject: [PATCH 03/11] fix-Assertions --- .../openelisglobal/menu/MenuServiceTest.java | 101 +++++++++--------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index 8c60d880a6..90492041c6 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -1,10 +1,9 @@ package org.openelisglobal.menu; -import static org.junit.Assert.*; - import java.util.ArrayList; import java.util.List; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openelisglobal.BaseWebContextSensitiveTest; @@ -14,6 +13,7 @@ import org.openelisglobal.menu.valueholder.AdminMenuItem; import org.openelisglobal.menu.valueholder.Menu; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; public class MenuServiceTest extends BaseWebContextSensitiveTest { @Autowired @@ -28,7 +28,8 @@ public void tearDown() { } @Test - public void testSaveSingleMenuItem() { + @Transactional + public void saveSingleMenuItem_shouldSaveAndReturnMenuItem() { // Create and save a MenuItem MenuItem menuItem = new MenuItem(); Menu menu = new Menu(); @@ -37,13 +38,12 @@ public void testSaveSingleMenuItem() { MenuItem savedItem = menuService.save(menuItem); - // Assertions - assertNotNull(savedItem); - + Assert.assertNotNull(savedItem); } @Test - public void testSaveMultipleMenuItems() { + @Transactional + public void saveMultipleMenuItems_shouldSaveAndReturnMenuItems() { // Create and save multiple MenuItems MenuItem menuItem1 = new MenuItem(); Menu menu1 = new Menu(); @@ -60,12 +60,13 @@ public void testSaveMultipleMenuItems() { List savedItems = menuService.save(menuItems); // Assertions - assertNotNull(savedItems); - assertEquals(2, savedItems.size()); + Assert.assertNotNull(savedItems); + Assert.assertEquals(2, savedItems.size()); } @Test - public void testGetAllActiveMenus() { + @Transactional + public void getAllActiveMenus_shouldReturnOnlyActiveMenus() { // Create and save active and inactive MenuItems MenuItem activeItem = new MenuItem(); Menu activeMenu = new Menu(); @@ -84,14 +85,13 @@ public void testGetAllActiveMenus() { // Retrieve all active menus List activeMenus = menuService.getAllActiveMenus(); - // Assertions - assertNotNull(activeMenus); - assertFalse(activeMenus.isEmpty()); - assertTrue(activeMenus.stream().allMatch(Menu::getIsActive)); + Assert.assertNotNull(activeMenus); + Assert.assertFalse(activeMenus.isEmpty()); + Assert.assertTrue(activeMenus.stream().allMatch(Menu::getIsActive)); } @Test - public void testGetSetAdminMenuItems() { + public void getAdminMenuItems_shouldReturnAdminMenuItems() { AdminMenuForm form = new AdminMenuForm(); List adminMenuItems = new ArrayList<>(); @@ -105,120 +105,119 @@ public void testGetSetAdminMenuItems() { form.setAdminMenuItems(adminMenuItems); List result = form.getAdminMenuItems(); - assertNotNull(result); - assertEquals(2, result.size()); - assertEquals("/path1", result.get(0).getPath()); - assertEquals("/path2", result.get(1).getPath()); + Assert.assertNotNull(result); + Assert.assertEquals(2, result.size()); + Assert.assertEquals("/path1", result.get(0).getPath()); + Assert.assertEquals("/path2", result.get(1).getPath()); } @Test - public void testGetSetTotalRecordCount() { + public void setTotalRecordCount_shouldSetAndReturnTotalRecordCount() { AdminMenuForm form = new AdminMenuForm(); form.setTotalRecordCount("100"); - assertEquals("100", form.getTotalRecordCount()); + Assert.assertEquals("100", form.getTotalRecordCount()); } @Test - public void testGetSetFromRecordCount() { + public void setFromRecordCount_shouldSetAndReturnFromRecordCount() { AdminMenuForm form = new AdminMenuForm(); form.setFromRecordCount("10"); - assertEquals("10", form.getFromRecordCount()); + Assert.assertEquals("10", form.getFromRecordCount()); } @Test - public void testGetSetToRecordCount() { + public void setToRecordCount_shouldSetAndReturnToRecordCount() { AdminMenuForm form = new AdminMenuForm(); form.setToRecordCount("20"); - assertEquals("20", form.getToRecordCount()); + Assert.assertEquals("20", form.getToRecordCount()); } @Test - public void testGetSetPresentationOrder() { + public void setPresentationOrder_shouldSetAndReturnPresentationOrder() { Menu menu = new Menu(); menu.setPresentationOrder(1); - assertEquals(1, menu.getPresentationOrder()); + Assert.assertEquals(1, menu.getPresentationOrder()); } @Test - public void testGetSetElementId() { + public void setElementId_shouldSetAndReturnElementId() { Menu menu = new Menu(); menu.setElementId("elementId"); - assertEquals("elementId", menu.getElementId()); + Assert.assertEquals("elementId", menu.getElementId()); } @Test - public void testGetSetActionURL() { + public void setActionURL_shouldSetAndReturnActionURL() { Menu menu = new Menu(); menu.setActionURL("http://example.com"); - assertEquals("http://example.com", menu.getActionURL()); + Assert.assertEquals("http://example.com", menu.getActionURL()); } @Test - public void testGetSetClickAction() { + public void setClickAction_shouldSetAndReturnClickAction() { Menu menu = new Menu(); menu.setClickAction("clickAction"); - assertEquals("clickAction", menu.getClickAction()); + Assert.assertEquals("clickAction", menu.getClickAction()); } @Test - public void testGetSetDisplayKey() { + public void setDisplayKey_shouldSetAndReturnDisplayKey() { Menu menu = new Menu(); menu.setDisplayKey("displayKey"); - assertEquals("displayKey", menu.getDisplayKey()); + Assert.assertEquals("displayKey", menu.getDisplayKey()); } @Test - public void testGetSetToolTipKey() { + public void setToolTipKey_shouldSetAndReturnToolTipKey() { Menu menu = new Menu(); menu.setToolTipKey("toolTipKey"); - assertEquals("toolTipKey", menu.getToolTipKey()); + Assert.assertEquals("toolTipKey", menu.getToolTipKey()); } @Test - public void testGetSetParent() { + public void setParent_shouldSetAndReturnParent() { Menu parentMenu = new Menu(); Menu childMenu = new Menu(); childMenu.setParent(parentMenu); - assertEquals(parentMenu, childMenu.getParent()); + Assert.assertEquals(parentMenu, childMenu.getParent()); } @Test - public void testGetLocalizedTitle() { + public void getLocalizedTitle_shouldReturnLocalizedTitle() { Menu menu = new Menu(); menu.setDisplayKey("testDisplayKey"); String title = menu.getLocalizedTitle(); - assertNotNull(title); + Assert.assertNotNull(title); } @Test - public void testGetLocalizedTooltip() { + public void getLocalizedTooltip_shouldReturnLocalizedTooltip() { Menu menu = new Menu(); menu.setToolTipKey("testToolTipKey"); String tooltip = menu.getLocalizedTooltip(); - assertNotNull(tooltip); - + Assert.assertNotNull(tooltip); } @Test - public void testSetGetOpenInNewWindow() { + public void setOpenInNewWindow_shouldSetAndReturnOpenInNewWindow() { Menu menu = new Menu(); menu.setOpenInNewWindow(true); - assertTrue(menu.isOpenInNewWindow()); + Assert.assertTrue(menu.isOpenInNewWindow()); } @Test - public void testSetGetIsActive() { + public void setIsActive_shouldSetAndReturnIsActive() { Menu menu = new Menu(); menu.setIsActive(true); - assertTrue(menu.getIsActive()); + Assert.assertTrue(menu.getIsActive()); } @Test - public void testSetGetHideInOldUI() { + public void setHideInOldUI_shouldSetAndReturnHideInOldUI() { Menu menu = new Menu(); menu.setHideInOldUI(true); - assertTrue(menu.isHideInOldUI()); + Assert.assertTrue(menu.isHideInOldUI()); } -} +} \ No newline at end of file From 5c5a40a65edb2c584bf080a598a120d4f9de83b2 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Mon, 5 Aug 2024 16:09:15 +0300 Subject: [PATCH 04/11] Menu-service-tests-fix --- .../openelisglobal/menu/MenuServiceTest.java | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index 90492041c6..315ecc7fe8 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -118,27 +118,6 @@ public void setTotalRecordCount_shouldSetAndReturnTotalRecordCount() { Assert.assertEquals("100", form.getTotalRecordCount()); } - @Test - public void setFromRecordCount_shouldSetAndReturnFromRecordCount() { - AdminMenuForm form = new AdminMenuForm(); - form.setFromRecordCount("10"); - Assert.assertEquals("10", form.getFromRecordCount()); - } - - @Test - public void setToRecordCount_shouldSetAndReturnToRecordCount() { - AdminMenuForm form = new AdminMenuForm(); - form.setToRecordCount("20"); - Assert.assertEquals("20", form.getToRecordCount()); - } - - @Test - public void setPresentationOrder_shouldSetAndReturnPresentationOrder() { - Menu menu = new Menu(); - menu.setPresentationOrder(1); - Assert.assertEquals(1, menu.getPresentationOrder()); - } - @Test public void setElementId_shouldSetAndReturnElementId() { Menu menu = new Menu(); @@ -146,13 +125,6 @@ public void setElementId_shouldSetAndReturnElementId() { Assert.assertEquals("elementId", menu.getElementId()); } - @Test - public void setActionURL_shouldSetAndReturnActionURL() { - Menu menu = new Menu(); - menu.setActionURL("http://example.com"); - Assert.assertEquals("http://example.com", menu.getActionURL()); - } - @Test public void setClickAction_shouldSetAndReturnClickAction() { Menu menu = new Menu(); From 40b11eda23891f39c19f86dff2eae2ca563ddd68 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Mon, 5 Aug 2024 16:23:00 +0300 Subject: [PATCH 05/11] fix-more tests --- src/test/java/org/openelisglobal/AppTestConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/openelisglobal/AppTestConfig.java b/src/test/java/org/openelisglobal/AppTestConfig.java index 666a3a7547..cb5a4108e6 100644 --- a/src/test/java/org/openelisglobal/AppTestConfig.java +++ b/src/test/java/org/openelisglobal/AppTestConfig.java @@ -50,8 +50,8 @@ "org.openelisglobal.systemusermodule.service", "org.openelisglobal.rolemodule.service", "org.openelisglobal.systemusermodule.daoimpl", "org.openelisglobal.systemusermodule.service", "org.openelisglobal.login.service", "org.openelisglobal.view", "org.openelisglobal.search.service", - "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", - "org.openelisglobal.menu" }, excludeFilters = { + "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", "org.openelisglobal.menu", + "org.openelisglobal.panel.service", "org.openelisglobal.panel.daoimpl" }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.dictionary.controller.*.java"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.config.*"), From f8f72357cd61c9c4e385ecc80e9d9f7dd8be679a Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Mon, 5 Aug 2024 16:30:26 +0300 Subject: [PATCH 06/11] remove-elementId-test --- src/test/java/org/openelisglobal/AppTestConfig.java | 2 +- .../java/org/openelisglobal/menu/MenuServiceTest.java | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/openelisglobal/AppTestConfig.java b/src/test/java/org/openelisglobal/AppTestConfig.java index cb5a4108e6..e114fe2dd3 100644 --- a/src/test/java/org/openelisglobal/AppTestConfig.java +++ b/src/test/java/org/openelisglobal/AppTestConfig.java @@ -51,7 +51,7 @@ "org.openelisglobal.systemusermodule.daoimpl", "org.openelisglobal.systemusermodule.service", "org.openelisglobal.login.service", "org.openelisglobal.view", "org.openelisglobal.search.service", "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", "org.openelisglobal.menu", - "org.openelisglobal.panel.service", "org.openelisglobal.panel.daoimpl" }, excludeFilters = { + }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.dictionary.controller.*.java"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.config.*"), diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index 315ecc7fe8..77b9d68aab 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -118,13 +118,6 @@ public void setTotalRecordCount_shouldSetAndReturnTotalRecordCount() { Assert.assertEquals("100", form.getTotalRecordCount()); } - @Test - public void setElementId_shouldSetAndReturnElementId() { - Menu menu = new Menu(); - menu.setElementId("elementId"); - Assert.assertEquals("elementId", menu.getElementId()); - } - @Test public void setClickAction_shouldSetAndReturnClickAction() { Menu menu = new Menu(); @@ -191,5 +184,5 @@ public void setHideInOldUI_shouldSetAndReturnHideInOldUI() { Menu menu = new Menu(); menu.setHideInOldUI(true); Assert.assertTrue(menu.isHideInOldUI()); - } + } } \ No newline at end of file From 93a4e68ff56ea8a6a3adaceae19ee6ed6357f121 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Mon, 5 Aug 2024 16:42:33 +0300 Subject: [PATCH 07/11] fix --- src/test/java/org/openelisglobal/menu/MenuServiceTest.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index 77b9d68aab..d0e1b0003c 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -30,7 +30,6 @@ public void tearDown() { @Test @Transactional public void saveSingleMenuItem_shouldSaveAndReturnMenuItem() { - // Create and save a MenuItem MenuItem menuItem = new MenuItem(); Menu menu = new Menu(); menu.setElementId("testElement"); @@ -44,7 +43,6 @@ public void saveSingleMenuItem_shouldSaveAndReturnMenuItem() { @Test @Transactional public void saveMultipleMenuItems_shouldSaveAndReturnMenuItems() { - // Create and save multiple MenuItems MenuItem menuItem1 = new MenuItem(); Menu menu1 = new Menu(); menu1.setElementId("testElement1"); @@ -59,7 +57,6 @@ public void saveMultipleMenuItems_shouldSaveAndReturnMenuItems() { List savedItems = menuService.save(menuItems); - // Assertions Assert.assertNotNull(savedItems); Assert.assertEquals(2, savedItems.size()); } @@ -67,7 +64,6 @@ public void saveMultipleMenuItems_shouldSaveAndReturnMenuItems() { @Test @Transactional public void getAllActiveMenus_shouldReturnOnlyActiveMenus() { - // Create and save active and inactive MenuItems MenuItem activeItem = new MenuItem(); Menu activeMenu = new Menu(); activeMenu.setElementId("activeElement"); @@ -82,7 +78,6 @@ public void getAllActiveMenus_shouldReturnOnlyActiveMenus() { inactiveItem.setMenu(inactiveMenu); menuService.save(inactiveItem); - // Retrieve all active menus List activeMenus = menuService.getAllActiveMenus(); Assert.assertNotNull(activeMenus); @@ -184,5 +179,5 @@ public void setHideInOldUI_shouldSetAndReturnHideInOldUI() { Menu menu = new Menu(); menu.setHideInOldUI(true); Assert.assertTrue(menu.isHideInOldUI()); - } + } } \ No newline at end of file From 91ccc044972c95fcfc7a4b97f11572b7831bd940 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Thu, 8 Aug 2024 22:30:01 +0300 Subject: [PATCH 08/11] fix Menu-service-Tests --- src/test/java/org/openelisglobal/AppTestConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/openelisglobal/AppTestConfig.java b/src/test/java/org/openelisglobal/AppTestConfig.java index e114fe2dd3..a363ea2ca8 100644 --- a/src/test/java/org/openelisglobal/AppTestConfig.java +++ b/src/test/java/org/openelisglobal/AppTestConfig.java @@ -50,8 +50,8 @@ "org.openelisglobal.systemusermodule.service", "org.openelisglobal.rolemodule.service", "org.openelisglobal.systemusermodule.daoimpl", "org.openelisglobal.systemusermodule.service", "org.openelisglobal.login.service", "org.openelisglobal.view", "org.openelisglobal.search.service", - "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", "org.openelisglobal.menu", - }, excludeFilters = { + "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", + "org.openelisglobal.menu", }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.dictionary.controller.*.java"), @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.config.*"), From 2330dd06d09037ba3920ae103486e2209b382375 Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Thu, 22 Aug 2024 19:08:43 +0300 Subject: [PATCH 09/11] remove-spaces --- .../org/openelisglobal/menu/MenuServiceTest.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index d0e1b0003c..a00e6135e6 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -34,9 +34,7 @@ public void saveSingleMenuItem_shouldSaveAndReturnMenuItem() { Menu menu = new Menu(); menu.setElementId("testElement"); menuItem.setMenu(menu); - MenuItem savedItem = menuService.save(menuItem); - Assert.assertNotNull(savedItem); } @@ -47,16 +45,12 @@ public void saveMultipleMenuItems_shouldSaveAndReturnMenuItems() { Menu menu1 = new Menu(); menu1.setElementId("testElement1"); menuItem1.setMenu(menu1); - MenuItem menuItem2 = new MenuItem(); Menu menu2 = new Menu(); menu2.setElementId("testElement2"); menuItem2.setMenu(menu2); - List menuItems = List.of(menuItem1, menuItem2); - List savedItems = menuService.save(menuItems); - Assert.assertNotNull(savedItems); Assert.assertEquals(2, savedItems.size()); } @@ -70,16 +64,13 @@ public void getAllActiveMenus_shouldReturnOnlyActiveMenus() { activeMenu.setIsActive(true); activeItem.setMenu(activeMenu); menuService.save(activeItem); - MenuItem inactiveItem = new MenuItem(); Menu inactiveMenu = new Menu(); inactiveMenu.setElementId("inactiveElement"); inactiveMenu.setIsActive(false); inactiveItem.setMenu(inactiveMenu); menuService.save(inactiveItem); - List activeMenus = menuService.getAllActiveMenus(); - Assert.assertNotNull(activeMenus); Assert.assertFalse(activeMenus.isEmpty()); Assert.assertTrue(activeMenus.stream().allMatch(Menu::getIsActive)); @@ -88,7 +79,6 @@ public void getAllActiveMenus_shouldReturnOnlyActiveMenus() { @Test public void getAdminMenuItems_shouldReturnAdminMenuItems() { AdminMenuForm form = new AdminMenuForm(); - List adminMenuItems = new ArrayList<>(); AdminMenuItem item1 = new AdminMenuItem(); item1.setPath("/path1"); @@ -96,9 +86,7 @@ public void getAdminMenuItems_shouldReturnAdminMenuItems() { item2.setPath("/path2"); adminMenuItems.add(item1); adminMenuItems.add(item2); - form.setAdminMenuItems(adminMenuItems); - List result = form.getAdminMenuItems(); Assert.assertNotNull(result); Assert.assertEquals(2, result.size()); @@ -146,7 +134,6 @@ public void setParent_shouldSetAndReturnParent() { public void getLocalizedTitle_shouldReturnLocalizedTitle() { Menu menu = new Menu(); menu.setDisplayKey("testDisplayKey"); - String title = menu.getLocalizedTitle(); Assert.assertNotNull(title); } @@ -155,7 +142,6 @@ public void getLocalizedTitle_shouldReturnLocalizedTitle() { public void getLocalizedTooltip_shouldReturnLocalizedTooltip() { Menu menu = new Menu(); menu.setToolTipKey("testToolTipKey"); - String tooltip = menu.getLocalizedTooltip(); Assert.assertNotNull(tooltip); } From e15370f872f8528dc0b997e023888e085016a0bc Mon Sep 17 00:00:00 2001 From: Agaba Derrick Date: Fri, 23 Aug 2024 12:59:27 +0300 Subject: [PATCH 10/11] fix-menu-tests --- .../openelisglobal/menu/MenuServiceTest.java | 96 +------------------ 1 file changed, 1 insertion(+), 95 deletions(-) diff --git a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java index a00e6135e6..c3e2417300 100644 --- a/src/test/java/org/openelisglobal/menu/MenuServiceTest.java +++ b/src/test/java/org/openelisglobal/menu/MenuServiceTest.java @@ -1,16 +1,13 @@ package org.openelisglobal.menu; -import java.util.ArrayList; import java.util.List; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openelisglobal.BaseWebContextSensitiveTest; -import org.openelisglobal.menu.form.AdminMenuForm; import org.openelisglobal.menu.service.MenuService; import org.openelisglobal.menu.util.MenuItem; -import org.openelisglobal.menu.valueholder.AdminMenuItem; import org.openelisglobal.menu.valueholder.Menu; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -75,95 +72,4 @@ public void getAllActiveMenus_shouldReturnOnlyActiveMenus() { Assert.assertFalse(activeMenus.isEmpty()); Assert.assertTrue(activeMenus.stream().allMatch(Menu::getIsActive)); } - - @Test - public void getAdminMenuItems_shouldReturnAdminMenuItems() { - AdminMenuForm form = new AdminMenuForm(); - List adminMenuItems = new ArrayList<>(); - AdminMenuItem item1 = new AdminMenuItem(); - item1.setPath("/path1"); - AdminMenuItem item2 = new AdminMenuItem(); - item2.setPath("/path2"); - adminMenuItems.add(item1); - adminMenuItems.add(item2); - form.setAdminMenuItems(adminMenuItems); - List result = form.getAdminMenuItems(); - Assert.assertNotNull(result); - Assert.assertEquals(2, result.size()); - Assert.assertEquals("/path1", result.get(0).getPath()); - Assert.assertEquals("/path2", result.get(1).getPath()); - } - - @Test - public void setTotalRecordCount_shouldSetAndReturnTotalRecordCount() { - AdminMenuForm form = new AdminMenuForm(); - form.setTotalRecordCount("100"); - Assert.assertEquals("100", form.getTotalRecordCount()); - } - - @Test - public void setClickAction_shouldSetAndReturnClickAction() { - Menu menu = new Menu(); - menu.setClickAction("clickAction"); - Assert.assertEquals("clickAction", menu.getClickAction()); - } - - @Test - public void setDisplayKey_shouldSetAndReturnDisplayKey() { - Menu menu = new Menu(); - menu.setDisplayKey("displayKey"); - Assert.assertEquals("displayKey", menu.getDisplayKey()); - } - - @Test - public void setToolTipKey_shouldSetAndReturnToolTipKey() { - Menu menu = new Menu(); - menu.setToolTipKey("toolTipKey"); - Assert.assertEquals("toolTipKey", menu.getToolTipKey()); - } - - @Test - public void setParent_shouldSetAndReturnParent() { - Menu parentMenu = new Menu(); - Menu childMenu = new Menu(); - childMenu.setParent(parentMenu); - Assert.assertEquals(parentMenu, childMenu.getParent()); - } - - @Test - public void getLocalizedTitle_shouldReturnLocalizedTitle() { - Menu menu = new Menu(); - menu.setDisplayKey("testDisplayKey"); - String title = menu.getLocalizedTitle(); - Assert.assertNotNull(title); - } - - @Test - public void getLocalizedTooltip_shouldReturnLocalizedTooltip() { - Menu menu = new Menu(); - menu.setToolTipKey("testToolTipKey"); - String tooltip = menu.getLocalizedTooltip(); - Assert.assertNotNull(tooltip); - } - - @Test - public void setOpenInNewWindow_shouldSetAndReturnOpenInNewWindow() { - Menu menu = new Menu(); - menu.setOpenInNewWindow(true); - Assert.assertTrue(menu.isOpenInNewWindow()); - } - - @Test - public void setIsActive_shouldSetAndReturnIsActive() { - Menu menu = new Menu(); - menu.setIsActive(true); - Assert.assertTrue(menu.getIsActive()); - } - - @Test - public void setHideInOldUI_shouldSetAndReturnHideInOldUI() { - Menu menu = new Menu(); - menu.setHideInOldUI(true); - Assert.assertTrue(menu.isHideInOldUI()); - } -} \ No newline at end of file +} From 544106bd5471a4082345d5ee17771ededa79d179 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Fri, 18 Oct 2024 00:00:42 +0300 Subject: [PATCH 11/11] fix format --- src/test/java/org/openelisglobal/AppTestConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/openelisglobal/AppTestConfig.java b/src/test/java/org/openelisglobal/AppTestConfig.java index 3eb328d1fe..b594fe39fd 100644 --- a/src/test/java/org/openelisglobal/AppTestConfig.java +++ b/src/test/java/org/openelisglobal/AppTestConfig.java @@ -50,8 +50,8 @@ "org.openelisglobal.systemusermodule.service", "org.openelisglobal.rolemodule.service", "org.openelisglobal.systemusermodule.daoimpl", "org.openelisglobal.systemusermodule.service", "org.openelisglobal.login.service", "org.openelisglobal.view", "org.openelisglobal.search.service", - "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", - "org.openelisglobal.menu", "org.openelisglobal.sample.daoimpl", "org.openelisglobal.common.util", + "org.openelisglobal.sample.daoimpl", "org.openelisglobal.menu.MenuServiceTest", "org.openelisglobal.menu", + "org.openelisglobal.sample.daoimpl", "org.openelisglobal.common.util", "org.openelisglobal.role", }, excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openelisglobal.patient.controller.*"),