1 26 package org.objectweb.util.explorer.core.menu; 27 28 import org.objectweb.util.explorer.core.code.api.CodeDescription; 29 import org.objectweb.util.explorer.core.code.lib.BasicCodeDescription; 30 import org.objectweb.util.explorer.core.menu.api.ItemDescription; 31 import org.objectweb.util.explorer.core.menu.api.MenuDescription; 32 import org.objectweb.util.explorer.core.menu.api.MenuSeparator; 33 import org.objectweb.util.explorer.core.menu.lib.BasicItemDescription; 34 import org.objectweb.util.explorer.core.menu.lib.BasicMenuDescription; 35 import org.objectweb.util.explorer.core.menu.lib.BasicMenuSeparator; 36 37 import junit.framework.Assert; 38 import junit.framework.TestCase; 39 40 48 public class MenuDescriptionTest 49 extends TestCase 50 { 51 52 58 protected ItemDescription itemDesc1_ = null, itemDesc2_ = null, sameAsItemDesc1_ = null; 59 protected MenuSeparator menuSeparator_ = null; 60 61 67 73 76 protected void setUp() throws Exception { 77 CodeDescription codeDesc = new BasicCodeDescription(); 78 codeDesc.setLanguage("Java"); 79 codeDesc.setCode("java.lang.Object"); 80 81 itemDesc1_ = new BasicItemDescription(); 82 itemDesc1_.setLabel("item 1"); 83 itemDesc1_.setCodeDescription(codeDesc); 84 85 itemDesc2_ = new BasicItemDescription(); 86 itemDesc2_.setLabel("item 2"); 87 itemDesc2_.setCodeDescription(codeDesc); 88 89 sameAsItemDesc1_ = new BasicItemDescription(); 90 sameAsItemDesc1_.setLabel("item 1"); 91 sameAsItemDesc1_.setCodeDescription(codeDesc); 92 93 menuSeparator_ = new BasicMenuSeparator(); 94 } 95 96 102 public void testEqualsMethod(){ 103 MenuDescription menuDesc = new BasicMenuDescription(); 104 MenuDescription expected = new BasicMenuDescription(); 105 MenuDescription notExpected = new BasicMenuDescription(); 106 107 menuDesc.addMenuElement(itemDesc1_); 108 menuDesc.addMenuElement(menuSeparator_); 109 menuDesc.addMenuElement(itemDesc1_); 110 menuDesc.addMenuElement(itemDesc2_); 111 ItemDescription id = null; 112 menuDesc.addMenuElement(id); 113 menuDesc.addMenuElement(new BasicItemDescription()); 114 menuDesc.addMenuElement(sameAsItemDesc1_); 115 116 notExpected.addMenuElement(itemDesc1_); 117 notExpected.addMenuElement(itemDesc2_); 118 notExpected.addMenuElement(menuSeparator_); 119 Assert.assertNotSame(notExpected, menuDesc); 120 121 expected.addMenuElement(itemDesc1_); 122 expected.addMenuElement(menuSeparator_); 123 expected.addMenuElement(itemDesc2_); 124 Assert.assertEquals(expected, menuDesc); 125 } 126 127 public void testIsEmptyMethod(){ 128 MenuDescription menuDesc = new BasicMenuDescription(); 129 Assert.assertTrue(menuDesc.isEmpty()); 130 menuDesc.addMenuElement(new BasicItemDescription()); 131 Assert.assertTrue(menuDesc.isEmpty()); 132 menuDesc.addMenuElement(itemDesc1_); 133 Assert.assertFalse(menuDesc.isEmpty()); 134 } 135 136 } 137 138 | Popular Tags |