Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ActionGroupTest.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (c) 2006-2013 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.actions;
  23. import com.dmdirc.config.prefs.PreferencesSetting;
  24. import com.dmdirc.updater.Version;
  25. import org.junit.Test;
  26. import static org.junit.Assert.*;
  27. import static org.mockito.Mockito.*;
  28. public class ActionGroupTest {
  29. @Test
  30. public void testGetAuthor() {
  31. ActionGroup instance = new ActionGroup("moo");
  32. instance.setAuthor("foo");
  33. String expResult = "foo";
  34. String result = instance.getAuthor();
  35. assertEquals(expResult, result);
  36. }
  37. @Test
  38. public void testGetDescription() {
  39. ActionGroup instance = new ActionGroup("bar");
  40. instance.setDescription("Tra-la-la-la-la");
  41. String expResult = "Tra-la-la-la-la";
  42. String result = instance.getDescription();
  43. assertEquals(expResult, result);
  44. }
  45. @Test
  46. public void testGetName() {
  47. ActionGroup instance = new ActionGroup("foobar");
  48. String expResult = "foobar";
  49. String result = instance.getName();
  50. assertEquals(expResult, result);
  51. }
  52. @Test
  53. public void testGetSettings() {
  54. ActionGroup instance = new ActionGroup("foo");
  55. assertTrue(instance.getSettings().isEmpty());
  56. instance.getSettings().put("", mock(PreferencesSetting.class));
  57. assertEquals(1, instance.getSettings().size());
  58. }
  59. @Test
  60. public void testGetVersion() {
  61. ActionGroup instance = new ActionGroup("vtest");
  62. instance.setVersion(new Version(73));
  63. Version expResult = new Version(73);
  64. Version result = instance.getVersion();
  65. assertEquals(expResult, result);
  66. }
  67. @Test
  68. public void testGetComponent() {
  69. ActionGroup instance = new ActionGroup("zzz");
  70. instance.setComponent(69);
  71. int expResult = 69;
  72. int result = instance.getComponent();
  73. assertEquals(expResult, result);
  74. }
  75. @Test
  76. public void testClear() {
  77. ActionGroup instance = new ActionGroup("zzz");
  78. instance.add(null);
  79. assertEquals(1, instance.size());
  80. instance.clear();
  81. assertEquals(0, instance.size());
  82. }
  83. @Test
  84. public void testRemove() {
  85. ActionGroup instance = new ActionGroup("zzz");
  86. instance.add(null);
  87. assertEquals(1, instance.size());
  88. instance.remove(null);
  89. assertEquals(0, instance.size());
  90. }
  91. @Test
  92. public void testContains() {
  93. ActionGroup instance = new ActionGroup("zzz");
  94. instance.add(null);
  95. assertTrue(instance.contains(null));
  96. instance.remove(null);
  97. assertFalse(instance.contains(null));
  98. }
  99. @Test
  100. public void testIsDelible() {
  101. assertTrue(new ActionGroup("foo").isDelible());
  102. }
  103. }