You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ActionGroupTest.java 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2006-2015 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 org.junit.runner.RunWith;
  27. import org.mockito.Mock;
  28. import org.mockito.runners.MockitoJUnitRunner;
  29. import static org.junit.Assert.assertEquals;
  30. import static org.junit.Assert.assertFalse;
  31. import static org.junit.Assert.assertTrue;
  32. import static org.mockito.Mockito.mock;
  33. @RunWith(MockitoJUnitRunner.class)
  34. public class ActionGroupTest {
  35. @Mock private ActionManager actionManager;
  36. @Test
  37. public void testGetAuthor() {
  38. final ActionGroup instance = new ActionGroup(actionManager, "moo");
  39. instance.setAuthor("foo");
  40. final String expResult = "foo";
  41. final String result = instance.getAuthor();
  42. assertEquals(expResult, result);
  43. }
  44. @Test
  45. public void testGetDescription() {
  46. final ActionGroup instance = new ActionGroup(actionManager, "bar");
  47. instance.setDescription("Tra-la-la-la-la");
  48. final String expResult = "Tra-la-la-la-la";
  49. final String result = instance.getDescription();
  50. assertEquals(expResult, result);
  51. }
  52. @Test
  53. public void testGetName() {
  54. final ActionGroup instance = new ActionGroup(actionManager, "foobar");
  55. final String expResult = "foobar";
  56. final String result = instance.getName();
  57. assertEquals(expResult, result);
  58. }
  59. @Test
  60. public void testGetSettings() {
  61. final ActionGroup instance = new ActionGroup(actionManager, "foo");
  62. assertTrue(instance.getSettings().isEmpty());
  63. instance.getSettings().put("", mock(PreferencesSetting.class));
  64. assertEquals(1, instance.getSettings().size());
  65. }
  66. @Test
  67. public void testGetVersion() {
  68. final ActionGroup instance = new ActionGroup(actionManager, "vtest");
  69. instance.setVersion(new Version(73));
  70. final Version expResult = new Version(73);
  71. final Version result = instance.getVersion();
  72. assertEquals(expResult, result);
  73. }
  74. @Test
  75. public void testGetComponent() {
  76. final ActionGroup instance = new ActionGroup(actionManager, "zzz");
  77. instance.setComponent(69);
  78. final int expResult = 69;
  79. final int result = instance.getComponent();
  80. assertEquals(expResult, result);
  81. }
  82. @Test
  83. public void testClear() {
  84. final ActionGroup instance = new ActionGroup(actionManager, "zzz");
  85. instance.add(null);
  86. assertTrue(instance.iterator().hasNext());
  87. instance.clear();
  88. assertFalse(instance.iterator().hasNext());
  89. }
  90. @Test
  91. public void testRemove() {
  92. final ActionGroup instance = new ActionGroup(actionManager, "zzz");
  93. instance.add(null);
  94. assertTrue(instance.iterator().hasNext());
  95. instance.remove(null);
  96. assertFalse(instance.iterator().hasNext());
  97. }
  98. @Test
  99. public void testIsDelible() {
  100. assertTrue(new ActionGroup(actionManager, "foo").isDelible());
  101. }
  102. }