Example #1
0
  private void infoModuleTest(final Player player) {
    cmd.onCommand(player, "info", "t");
    Mockito.verify(player).sendMessage("Module info here");

    cmd.onCommand(player, "t");
    Mockito.verify(player, Mockito.times(2)).sendMessage("Module info here");
  }
Example #2
0
  @Test
  public void playerInfoModule() {
    Player player = Mockito.mock(Player.class);

    cmd.onCommand(player, "info", "t");
    Mockito.verify(player).sendMessage("Module info here");

    cmd.onCommand(player, "info", "d");
    Mockito.verify(player).sendMessage("§6[EC] §eNo module found");
  }
Example #3
0
  @Test
  public void senderInfoModule() {
    CommandSender sender = Mockito.mock(CommandSender.class);
    cmd.onCommand(sender, "info", "t");
    senderInfoCheck(sender);

    sender = Mockito.mock(CommandSender.class);
    cmd.onCommand(sender, "info", "t", "2");
    senderInfoCheck(sender);
  }
Example #4
0
 @Test
 public void playerOpNothing() {
   Player player = Mockito.mock(Player.class);
   Mockito.when(player.isOp()).thenReturn(true);
   cmd.onCommand(player);
   playerOpInfoCheck(player);
 }
Example #5
0
  @Test
  public void playerNoOpSetLvl() {
    Player player = Mockito.mock(Player.class);

    cmd.onCommand(player, "setlvl");
    Mockito.verify(player)
        .sendMessage("§6[EC] §eSyntax: /level setLevel <Module> <Value> [Player]");

    cmd.onCommand(player, "setlvl", "t");
    Mockito.verify(player, Mockito.times(2))
        .sendMessage("§6[EC] §eSyntax: /level setLevel <Module> <Value> [Player]");

    cmd.onCommand(player, "setlevel", "t", "5");
    Mockito.verify(player).sendMessage("§6[EC] §cYou cannot execute that command.");

    player = Mockito.mock(Player.class);
    cmd.onCommand(player, "setlevel", "t", "asd");
    Mockito.verify(player)
        .sendMessage("§6[EC] §eSyntax: /level setLevel <Module> <Value> [Player]");
    Mockito.verify(player).sendMessage("§6[EC] §e<Value> has to be a natural number");

    cmd.onCommand(player, "setlvl", "t", "5", "cryxli");
    Mockito.verify(player).sendMessage("§6[EC] §cYou cannot execute that command.");

    Mockito.when(server.getPlayer(player.getName())).thenReturn(player);
    cmd.onCommand(player, "setlvl", "t", "5", "cryxli");
    Mockito.verify(player, Mockito.times(2))
        .sendMessage("§6[EC] §cYou cannot execute that command.");

    cmd.onCommand(player, "setlvl", "d", "15", "cryxli");
    Mockito.verify(player, Mockito.times(3))
        .sendMessage("§6[EC] §cYou cannot execute that command.");
  }
Example #6
0
  @Test
  public void playerOpAll() {
    Player player = Mockito.mock(Player.class);
    Mockito.when(player.getName()).thenReturn("cryxli");
    Mockito.when(player.isOp()).thenReturn(true);
    core.getPersistence().setExp(testModule, player, 0);

    cmd.onCommand(player, "all");
    Mockito.verify(player).sendMessage("§6[EC] --- ExpCraftPlugin ---");
    Mockito.verify(player).sendMessage("§6[EC] §eTest (T): 1");

    cmd.onCommand(player, "all", "cryxli");
    Mockito.verify(player).sendMessage("§6[EC] §ePlayer cryxli is offline");

    Mockito.when(server.getPlayer(player.getName())).thenReturn(player);
    cmd.onCommand(player, "all", "cryxli");
    Mockito.verify(player, Mockito.times(2)).sendMessage("§6[EC] --- ExpCraftPlugin ---");
    Mockito.verify(player, Mockito.times(2)).sendMessage("§6[EC] §eTest (T): 1");
  }
Example #7
0
  @Test
  public void playerNoOpGetExp() {
    Player player = Mockito.mock(Player.class);
    Mockito.when(player.getName()).thenReturn("cryxli");

    cmd.onCommand(player, "getexp");
    Mockito.verify(player).sendMessage("§6[EC] §eSyntax: /level getExp <Module> [Player]");

    core.getPersistence().setExp(testModule, player, 0);
    cmd.onCommand(player, "getexp", "t");
    Mockito.verify(player).sendMessage("§6[EC] §eTest (T): lv1 at 0 points");

    cmd.onCommand(player, "getexp", "t", "cryxli");
    Mockito.verify(player).sendMessage("§6[EC] §cYou cannot execute that command.");

    cmd.onCommand(player, "getexp", "d", "cryxli");
    Mockito.verify(player, Mockito.times(2))
        .sendMessage("§6[EC] §cYou cannot execute that command.");
  }
Example #8
0
  @Test
  public void senderAll() {
    CommandSender sender = Mockito.mock(CommandSender.class);

    cmd.onCommand(sender, "all");
    Mockito.verify(sender).sendMessage("§6[EC] §eSyntax: /level all <Player>");

    cmd.onCommand(sender, "all", "cryxli");
    Mockito.verify(sender).sendMessage("§6[EC] §ePlayer cryxli is offline");

    Player player = Mockito.mock(Player.class);
    Mockito.when(player.getName()).thenReturn("cryxli");
    Mockito.when(server.getPlayer(player.getName())).thenReturn(player);
    sender = Mockito.mock(CommandSender.class);
    core.getPersistence().setExp(testModule, player, 0);
    cmd.onCommand(sender, "all", "cryxli");
    Mockito.verify(sender).sendMessage("§6[EC] --- ExpCraftPlugin ---");
    Mockito.verify(sender).sendMessage("§6[EC] §eTest (T): 1");
    Mockito.verify(sender, Mockito.times(2)).sendMessage(Mockito.anyString());
  }
Example #9
0
  @Test
  public void playerNoOpAll() {
    Player player = Mockito.mock(Player.class);
    Mockito.when(player.getName()).thenReturn("cryxli");

    core.getPersistence().setExp(testModule, player, 0);
    cmd.onCommand(player, "all");
    Mockito.verify(player).sendMessage("§6[EC] --- ExpCraftPlugin ---");
    Mockito.verify(player).sendMessage("§6[EC] §eTest (T): 1");
    Mockito.verify(player, Mockito.times(2)).sendMessage(Mockito.anyString());
  }
Example #10
0
  @Test
  public void playerOpGetExp() {
    Player player = Mockito.mock(Player.class);
    Mockito.when(player.getName()).thenReturn("cryxli");
    Mockito.when(player.isOp()).thenReturn(true);

    cmd.onCommand(player, "getexp");
    Mockito.verify(player).sendMessage("§6[EC] §eSyntax: /level getExp <Module> [Player]");

    core.getPersistence().setExp(testModule, player, 0);
    cmd.onCommand(player, "getexp", "t");
    Mockito.verify(player).sendMessage("§6[EC] §eTest (T): lv1 at 0 points");

    cmd.onCommand(player, "getexp", "t", "cryxli");
    Mockito.verify(player).sendMessage("§6[EC] §ePlayer cryxli is offline");

    Mockito.when(server.getPlayer(player.getName())).thenReturn(player);
    cmd.onCommand(player, "getexp", "t", "cryxli");
    Mockito.verify(player, Mockito.times(2)).sendMessage("§6[EC] §eTest (T): lv1 at 0 points");

    cmd.onCommand(player, "getexp", "d", "cryxli");
    Mockito.verify(player).sendMessage("§6[EC] §eNo module found");
  }
Example #11
0
  @Test
  public void playerOpSetLvl() {
    Player player = Mockito.mock(Player.class);
    Mockito.when(player.getName()).thenReturn("cryxli");
    Mockito.when(player.isOp()).thenReturn(true);

    cmd.onCommand(player, "setlvl");
    Mockito.verify(player)
        .sendMessage("§6[EC] §eSyntax: /level setLevel <Module> <Value> [Player]");

    cmd.onCommand(player, "setlvl", "t");
    Mockito.verify(player, Mockito.times(2))
        .sendMessage("§6[EC] §eSyntax: /level setLevel <Module> <Value> [Player]");

    cmd.onCommand(player, "setlevel", "t", "5");
    Mockito.verify(player).sendMessage("§6[EC] §eTest (T): lv5");
    Assert.assertEquals(5, core.getPersistence().getLevel(testModule, player));

    player = Mockito.mock(Player.class);
    Mockito.when(player.isOp()).thenReturn(true);
    cmd.onCommand(player, "setlevel", "t", "asd");
    Mockito.verify(player)
        .sendMessage("§6[EC] §eSyntax: /level setLevel <Module> <Value> [Player]");
    Mockito.verify(player).sendMessage("§6[EC] §e<Value> has to be a natural number");
    Mockito.verify(player, Mockito.times(2)).sendMessage(Mockito.anyString());

    cmd.onCommand(player, "setlvl", "t", "10", "testus");
    Mockito.verify(player).sendMessage("§6[EC] §ePlayer testus is offline");

    Player testus = Mockito.mock(Player.class);
    Mockito.when(testus.getName()).thenReturn("testus");
    Mockito.when(server.getPlayer(testus.getName())).thenReturn(testus);
    cmd.onCommand(player, "setlvl", "t", "10", "testus");
    Mockito.verify(player).sendMessage("§6[EC] §eTest (T): lv10");
    Assert.assertEquals(10, core.getPersistence().getLevel(testModule, testus));

    cmd.onCommand(player, "setlvl", "d", "15", "testus");
    Mockito.verify(player).sendMessage("§6[EC] §eNo module found");
  }
Example #12
0
 @Test
 public void senderNothing() {
   CommandSender sender = Mockito.mock(CommandSender.class);
   cmd.onCommand(sender);
   senderInfoCheck(sender);
 }
Example #13
0
 @Test
 public void playerNoOpNothing() {
   Player player = Mockito.mock(Player.class);
   cmd.onCommand(player);
   playerInfoCheck(player);
 }
Example #14
0
 @Test
 public void playerNoOpInfo() {
   Player player = Mockito.mock(Player.class);
   cmd.onCommand(player, "info");
   playerInfoCheck(player);
 }