Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added giant, non One Assert Per Test integration test just to stress …

…various usages and serve as starting point for documentation
  • Loading branch information...
commit a4c0c53154351e92eb4b3dcd5d610eda2e2acf67 1 parent 7621e73
@leadVisionary authored
Showing with 67 additions and 0 deletions.
  1. +67 −0 test/com/visionarysoftwaresolutions/menu/MenuIntegrationTest.java
View
67 test/com/visionarysoftwaresolutions/menu/MenuIntegrationTest.java
@@ -0,0 +1,67 @@
+package com.visionarysoftwaresolutions.menu;
+
+import static org.junit.Assert.*;
+
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.visionarysoftwaresolutions.menu.composite.MenuComponent;
+import com.visionarysoftwaresolutions.menu.composite.MenuLeaf;
+
+public class MenuIntegrationTest {
+ private MenuFactory factory;
+
+ @Before
+ public void setup() {
+ factory = new MenuFactory();
+ }
+
+ @Test
+ public void testBuildSimpleMenu() {
+ String THE_MAN = "The man";
+ String THE_MYTH = "The myth";
+ String THE_GOODS = "The goods";
+ String[] options = { "Green Eggs", "Ham", "Bacon", "Chocolate", "Sexual Innuendo"};
+
+ MenuComponent menu =factory.createMenu("nav");
+ factory.addItemToMenu(menu, THE_MAN);
+ assertTrue(menu.hasChildren());
+ factory.addItemToMenu(menu, THE_MYTH);
+ MenuComponent myth = menu.getChild(THE_MYTH);
+ assertNotNull(myth);
+ MenuComponent goods = factory.createMenu(THE_GOODS);
+ for(String opt : options){
+ factory.addItemToMenu(goods, opt);
+ }
+ menu.remove(myth);
+ assertNull(menu.getChild(THE_MYTH));
+ factory.addSubMenu(menu, goods);
+ MenuIterator it = menu.createIterator();
+ while(it.hasNext()){
+ MenuComponent dance = it.next();
+ System.out.println(dance.getText());
+ if(!dance.hasChildren()){
+ assertTrue(dance.getText().equalsIgnoreCase(THE_MAN));
+ }
+ else{
+ Set<MenuComponent> submissive = factory.getSubMenus(menu);
+ assertTrue(submissive.contains(dance));
+ }
+ }
+ menu.add(new MenuLeaf("THE LEGEND!"));
+ MenuComponent legend = menu.getChild(THE_MAN);
+ assertFalse(legend.hasChildren());
+ try{
+ legend.createIterator();
+ legend.getChild("FANTASY");
+ legend.remove(null);
+ legend.add(null);
+ }
+ catch(UnsupportedOperationException e){
+ assertNotNull(e);
+ }
+
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.