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 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2006-2014 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. final ActionGroup instance = new ActionGroup("moo");
  32. instance.setAuthor("foo");
  33. final String expResult = "foo";
  34. final String result = instance.getAuthor();
  35. assertEquals(expResult, result);
  36. }
  37. @Test
  38. public void testGetDescription() {
  39. final ActionGroup instance = new ActionGroup("bar");
  40. instance.setDescription("Tra-la-la-la-la");
  41. final String expResult = "Tra-la-la-la-la";
  42. final String result = instance.getDescription();
  43. assertEquals(expResult, result);
  44. }
  45. @Test
  46. public void testGetName() {
  47. final ActionGroup instance = new ActionGroup("foobar");
  48. final String expResult = "foobar";
  49. final String result = instance.getName();
  50. assertEquals(expResult, result);
  51. }
  52. @Test
  53. public void testGetSettings() {
  54. final 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. final ActionGroup instance = new ActionGroup("vtest");
  62. instance.setVersion(new Version(73));
  63. final Version expResult = new Version(73);
  64. final Version result = instance.getVersion();
  65. assertEquals(expResult, result);
  66. }
  67. @Test
  68. public void testGetComponent() {
  69. final ActionGroup instance = new ActionGroup("zzz");
  70. instance.setComponent(69);
  71. final int expResult = 69;
  72. final int result = instance.getComponent();
  73. assertEquals(expResult, result);
  74. }
  75. @Test
  76. public void testClear() {
  77. final ActionGroup instance = new ActionGroup("zzz");
  78. instance.add(null);
  79. assertTrue(instance.iterator().hasNext());
  80. instance.clear();
  81. assertFalse(instance.iterator().hasNext());
  82. }
  83. @Test
  84. public void testRemove() {
  85. final ActionGroup instance = new ActionGroup("zzz");
  86. instance.add(null);
  87. assertTrue(instance.iterator().hasNext());
  88. instance.remove(null);
  89. assertFalse(instance.iterator().hasNext());
  90. }
  91. @Test
  92. public void testIsDelible() {
  93. assertTrue(new ActionGroup("foo").isDelible());
  94. }
  95. }