|
@ -6,12 +6,22 @@ import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
|
|
|
|
|
|
class MenuTest { |
|
|
class MenuTest { |
|
|
|
|
|
|
|
|
|
|
|
Menu rootMenu; |
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
@BeforeEach |
|
|
void setUp() { |
|
|
void setUp() { |
|
|
|
|
|
rootMenu = new Menu("Root"); |
|
|
|
|
|
Menu menu1 = new Menu("Menu1"); |
|
|
|
|
|
Menu menu2 = new Menu("Menu2"); |
|
|
|
|
|
Menu menu1_1 = new Menu("Menu1.1"); |
|
|
|
|
|
menu1.addMenu(menu1_1); |
|
|
|
|
|
rootMenu.addMenu(menu1); |
|
|
|
|
|
rootMenu.addMenu(menu2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@AfterEach |
|
|
@AfterEach |
|
@ -19,20 +29,18 @@ class MenuTest { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void testCorrectName(){ |
|
|
|
|
|
Menu menu = new Menu("Item 1"); |
|
|
|
|
|
assertTrue(menu.getName().equals("Item 1")); |
|
|
|
|
|
|
|
|
void testCorrectName() { |
|
|
|
|
|
assertEquals("Root", rootMenu.getName()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void testAddMenuFunction(){ |
|
|
|
|
|
ArrayList<Menu> menus = new ArrayList<>(); |
|
|
|
|
|
Menu menu1 = new Menu("Menu 1"); |
|
|
|
|
|
Menu menu2 = new Menu("Menu 2"); |
|
|
|
|
|
Menu menu1_1 = new Menu("Menu 1.1"); |
|
|
|
|
|
menu1.addMenu(menu1_1); |
|
|
|
|
|
menus.add(menu1); |
|
|
|
|
|
menus.add(menu2); |
|
|
|
|
|
assertTrue(menus.get(0).equals(menu1) && menus.get(1).equals(menu2) && menus.get(0).getSubMenuList().get(0).equals(menu1_1)); |
|
|
|
|
|
|
|
|
void testAddMenuFunction() { |
|
|
|
|
|
assertTrue(rootMenu.getMenu(0).getName().equals("Menu1") && rootMenu.getMenu(1).getName().equals("Menu2") && rootMenu.getMenu(0).getMenu(0).getName().equals("Menu1.1")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testPreviousMenuFunction(){ |
|
|
|
|
|
assertTrue(rootMenu.getPreviousMenu() == null && rootMenu.getMenu(0).getPreviousMenu().getName().equals("Root") && rootMenu.getMenu(0).getMenu(0).getPreviousMenu().getName().equals("Menu1")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |