@Test public void ex4_killAward() { when(observer.getLogLine()).thenReturn(EX4_0); test.onApplicationEvent(observer); MatchPlayers player = Utils.searchFor(EX4_RIGHT, match); assertNotNull(player); assertEquals(false, player.isAward()); when(observer.getLogLine()).thenReturn(EX4_1); test.onApplicationEvent(observer); when(observer.getLogLine()).thenReturn(EX4_2); test.onApplicationEvent(observer); when(observer.getLogLine()).thenReturn(EX4_3); test.onApplicationEvent(observer); when(observer.getLogLine()).thenReturn(EX4_4); test.onApplicationEvent(observer); player = Utils.searchFor(EX4_RIGHT, match); assertNotNull(player); assertEquals(true, player.isAward()); }
private void insertWeapons(MatchData match) { Set<MatchPlayers> players = match.getPlayers(); for (MatchPlayers p : players) { Set<KillWeapon> list = buildWeaponList(); p.setListKillWeapon(list); } }
@Test public void ex2_IncrementStreak() { when(observer.getLogLine()).thenReturn(EX2); test.onApplicationEvent(observer); MatchPlayers player = Utils.searchFor(EX2_RIGHT, match); assertNotNull(player); assertEquals(1, player.getCurrentStreak()); }
@Test public void ex1_CountKill() { when(observer.getLogLine()).thenReturn(EX1); test.onApplicationEvent(observer); MatchPlayers player = Utils.searchFor(EX1_RIGHT, match); assertNotNull(player); assertEquals(1, player.getKill()); }
private void insertPlayers(MatchData match) { Set<MatchPlayers> list = new TreeSet<MatchPlayers>(); match.setPlayers(list); MatchPlayers player; player = new MatchPlayers(); player.setName("Name1"); player.setKill(1); list.add(player); player = new MatchPlayers(); player.setName("Name2"); player.setKill(2); list.add(player); player = new MatchPlayers(); player.setName("Name3"); player.setKill(3); list.add(player); player = new MatchPlayers(); player.setName("Name4"); player.setKill(4); list.add(player); }
@Test public void ex2_endMatchConsolidate() throws MatchException { MatchData match = test.newMatch(ID); insertPlayers(match); insertWeapons(match); MatchData data = test.endMatch(); MatchPlayers player = data.getPlayers().iterator().next(); assertTrue(player.getBestWeapon().getName().equals("weapon4")); assertTrue(player.getName().equals("Name4")); assertTrue(player.isAward()); }
@Test public void ex3_IncrementAndMaintainMaxStreak() { MatchPlayers player = ex3_partCount(); assertEquals(1, player.getMaxStreak()); player = ex3_partCount(); assertEquals(2, player.getMaxStreak()); player.setCurrentStreak(0); player = ex3_partCount(); assertEquals(2, player.getMaxStreak()); player = ex3_partCount(); assertEquals(2, player.getMaxStreak()); player = ex3_partCount(); assertEquals(3, player.getMaxStreak()); }