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.

CommandTypeTest.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
  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.commandparser;
  23. import com.dmdirc.Channel;
  24. import com.dmdirc.MessageTarget;
  25. import com.dmdirc.Query;
  26. import com.dmdirc.Server;
  27. import com.dmdirc.commandparser.commands.ChannelCommand;
  28. import com.dmdirc.commandparser.commands.ChatCommand;
  29. import com.dmdirc.commandparser.commands.Command;
  30. import com.dmdirc.commandparser.commands.GlobalCommand;
  31. import com.dmdirc.commandparser.commands.QueryCommand;
  32. import com.dmdirc.commandparser.commands.ServerCommand;
  33. import com.dmdirc.ui.interfaces.InputWindow;
  34. import org.junit.Test;
  35. import static org.junit.Assert.*;
  36. public class CommandTypeTest extends junit.framework.TestCase {
  37. @Test
  38. public void testGlobal() {
  39. final Command command = new GlobalCommand() {
  40. @Override
  41. public void execute(InputWindow origin, boolean isSilent, String... args) {
  42. throw new UnsupportedOperationException("Not supported yet.");
  43. }
  44. @Override
  45. public String getName() {
  46. throw new UnsupportedOperationException("Not supported yet.");
  47. }
  48. @Override
  49. public boolean showInHelp() {
  50. throw new UnsupportedOperationException("Not supported yet.");
  51. }
  52. @Override
  53. public String getHelp() {
  54. throw new UnsupportedOperationException("Not supported yet.");
  55. }
  56. };
  57. assertEquals(CommandType.TYPE_GLOBAL, CommandType.fromCommand(command));
  58. }
  59. @Test
  60. public void testServer() {
  61. final Command command = new ServerCommand() {
  62. @Override
  63. public void execute(InputWindow origin, Server server, boolean isSilent, String... args) {
  64. throw new UnsupportedOperationException("Not supported yet.");
  65. }
  66. @Override
  67. public String getName() {
  68. throw new UnsupportedOperationException("Not supported yet.");
  69. }
  70. @Override
  71. public boolean showInHelp() {
  72. throw new UnsupportedOperationException("Not supported yet.");
  73. }
  74. @Override
  75. public String getHelp() {
  76. throw new UnsupportedOperationException("Not supported yet.");
  77. }
  78. };
  79. assertEquals(CommandType.TYPE_SERVER, CommandType.fromCommand(command));
  80. }
  81. @Test
  82. public void testChat() {
  83. final Command command = new ChatCommand() {
  84. @Override
  85. public String getName() {
  86. throw new UnsupportedOperationException("Not supported yet.");
  87. }
  88. @Override
  89. public boolean showInHelp() {
  90. throw new UnsupportedOperationException("Not supported yet.");
  91. }
  92. @Override
  93. public String getHelp() {
  94. throw new UnsupportedOperationException("Not supported yet.");
  95. }
  96. @Override
  97. public void execute(InputWindow origin, Server server,
  98. MessageTarget target, boolean isSilent, String... args) {
  99. throw new UnsupportedOperationException("Not supported yet.");
  100. }
  101. };
  102. assertEquals(CommandType.TYPE_CHAT, CommandType.fromCommand(command));
  103. }
  104. @Test
  105. public void testChannel() {
  106. final Command command = new ChannelCommand() {
  107. @Override
  108. public String getName() {
  109. throw new UnsupportedOperationException("Not supported yet.");
  110. }
  111. @Override
  112. public boolean showInHelp() {
  113. throw new UnsupportedOperationException("Not supported yet.");
  114. }
  115. @Override
  116. public String getHelp() {
  117. throw new UnsupportedOperationException("Not supported yet.");
  118. }
  119. @Override
  120. public void execute(InputWindow origin, Server server,
  121. Channel channel, boolean isSilent, String... args) {
  122. throw new UnsupportedOperationException("Not supported yet.");
  123. }
  124. };
  125. assertEquals(CommandType.TYPE_CHANNEL, CommandType.fromCommand(command));
  126. }
  127. @Test
  128. public void testQuery() {
  129. final Command command = new QueryCommand() {
  130. @Override
  131. public String getName() {
  132. throw new UnsupportedOperationException("Not supported yet.");
  133. }
  134. @Override
  135. public boolean showInHelp() {
  136. throw new UnsupportedOperationException("Not supported yet.");
  137. }
  138. @Override
  139. public String getHelp() {
  140. throw new UnsupportedOperationException("Not supported yet.");
  141. }
  142. @Override
  143. public void execute(InputWindow origin, Server server, Query query,
  144. boolean isSilent, String... args) {
  145. throw new UnsupportedOperationException("Not supported yet.");
  146. }
  147. };
  148. assertEquals(CommandType.TYPE_QUERY, CommandType.fromCommand(command));
  149. }
  150. @Test
  151. public void testOther() {
  152. assertNull(CommandType.fromCommand(null));
  153. }
  154. }