mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-12 14:58:26 +02:00
[Test] Improved GMTimesTest
This commit is contained in:
parent
71e2d52967
commit
1e0de6a1fe
@ -3,123 +3,117 @@ package com.djrapitops.plan.data.time;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link GMTimes}.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
public class GMTimesTest {
|
public class GMTimesTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSetAllGMTimes() {
|
public void allGMTimesAreSet() {
|
||||||
GMTimes gmTimes = new GMTimes();
|
GMTimes times = new GMTimes();
|
||||||
gmTimes.setAllGMTimes(1L, 2L, 3L, 4L);
|
times.setAllGMTimes(1L, 2L, 3L, 4L);
|
||||||
|
|
||||||
Map<String, Long> times = gmTimes.getTimes();
|
assertEquals(1L, times.getTime("SURVIVAL"));
|
||||||
|
assertEquals(2L, times.getTime("CREATIVE"));
|
||||||
assertEquals(times.size(), 4);
|
assertEquals(3L, times.getTime("ADVENTURE"));
|
||||||
assertTrue(times.get("SURVIVAL") == 1L);
|
assertEquals(4L, times.getTime("SPECTATOR"));
|
||||||
assertTrue(times.get("CREATIVE") == 2L);
|
|
||||||
assertTrue(times.get("ADVENTURE") == 3L);
|
|
||||||
assertTrue(times.get("SPECTATOR") == 4L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetAllGMTimesTooFew() {
|
public void allGMTimesAreSetWithTooFewArguments() {
|
||||||
GMTimes gmTimes = new GMTimes();
|
GMTimes times = new GMTimes();
|
||||||
gmTimes.setAllGMTimes(1L, 2L);
|
times.setAllGMTimes(1L, 2L);
|
||||||
|
|
||||||
Map<String, Long> times = gmTimes.getTimes();
|
assertEquals(1L, times.getTime("SURVIVAL"));
|
||||||
|
assertEquals(2L, times.getTime("CREATIVE"));
|
||||||
assertEquals(times.size(), 4);
|
assertEquals(0L, times.getTime("ADVENTURE"));
|
||||||
assertTrue(times.get("SURVIVAL") == 1L);
|
assertEquals(0L, times.getTime("SPECTATOR"));
|
||||||
assertTrue(times.get("CREATIVE") == 2L);
|
|
||||||
assertTrue(times.get("ADVENTURE") == 0L);
|
|
||||||
assertTrue(times.get("SPECTATOR") == 0L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetAllGMTimesTooMany() {
|
public void allGMTimesAreSetWithTooManyArguments() {
|
||||||
GMTimes gmTimes = new GMTimes();
|
GMTimes times = new GMTimes();
|
||||||
gmTimes.setAllGMTimes(1L, 2L, 3L, 4L, 5L, 6L);
|
times.setAllGMTimes(1L, 2L, 3L, 4L, 5L, 6L);
|
||||||
|
|
||||||
Map<String, Long> times = gmTimes.getTimes();
|
assertEquals(1L, times.getTime("SURVIVAL"));
|
||||||
|
assertEquals(2L, times.getTime("CREATIVE"));
|
||||||
assertEquals(times.size(), 4);
|
assertEquals(3L, times.getTime("ADVENTURE"));
|
||||||
assertTrue(times.get("SURVIVAL") == 1L);
|
assertEquals(4L, times.getTime("SPECTATOR"));
|
||||||
assertTrue(times.get("CREATIVE") == 2L);
|
|
||||||
assertTrue(times.get("ADVENTURE") == 3L);
|
|
||||||
assertTrue(times.get("SPECTATOR") == 4L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResetTimes() {
|
public void timesAreReset() {
|
||||||
GMTimes gmTimes = new GMTimes();
|
GMTimes gmTimes = new GMTimes();
|
||||||
gmTimes.setAllGMTimes(4, 3, 2, 1);
|
gmTimes.setAllGMTimes(4, 3, 2, 1);
|
||||||
gmTimes.resetTimes(10);
|
gmTimes.resetTimes(10L);
|
||||||
|
|
||||||
assertTrue(gmTimes.getTotal() == 10L);
|
assertEquals(10L, gmTimes.getTotal());
|
||||||
assertTrue(gmTimes.getTime("SURVIVAL") == 10L);
|
assertEquals(10L, gmTimes.getTime("SURVIVAL"));
|
||||||
assertTrue(gmTimes.getTime("ADVENTURE") == 0L);
|
assertEquals(0L, gmTimes.getTime("ADVENTURE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetTime() {
|
public void timeIsSet() {
|
||||||
GMTimes gmTimes = new GMTimes();
|
GMTimes gmTimes = new GMTimes();
|
||||||
gmTimes.setTime("SURVIVAL", 5L);
|
gmTimes.setTime("SURVIVAL", 5L);
|
||||||
|
|
||||||
assertTrue(gmTimes.getTime("SURVIVAL") == 5L);
|
assertEquals(5L, gmTimes.getTime("SURVIVAL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRenameState() {
|
public void stateIsRenamed() {
|
||||||
GMTimes gmTimes = new GMTimes();
|
GMTimes gmTimes = new GMTimes();
|
||||||
gmTimes.setAllGMTimes(5L);
|
gmTimes.setAllGMTimes(5L);
|
||||||
gmTimes.renameState("SURVIVAL", "Survival");
|
gmTimes.renameState("SURVIVAL", "Survival");
|
||||||
|
|
||||||
assertTrue(gmTimes.getTime("SURVIVAL") == 0L);
|
assertEquals(0L, gmTimes.getTime("SURVIVAL"));
|
||||||
assertTrue(gmTimes.getTime("Survival") == 5L);
|
assertEquals(5L, gmTimes.getTime("Survival"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeStateNormal() {
|
public void stateIsChangedAppropriately() {
|
||||||
GMTimes gmTimes = new GMTimes(new HashMap<>(), "SURVIVAL", 0);
|
GMTimes gmTimes = new GMTimes(new HashMap<>(), "SURVIVAL", 0);
|
||||||
gmTimes.changeState("CREATIVE", 5L);
|
gmTimes.changeState("CREATIVE", 5L);
|
||||||
|
|
||||||
assertTrue(gmTimes.getTime("SURVIVAL") == 5L);
|
assertEquals(5L, gmTimes.getTime("SURVIVAL"));
|
||||||
assertTrue(gmTimes.getTime("CREATIVE") == 0L);
|
assertEquals(0L, gmTimes.getTime("CREATIVE"));
|
||||||
|
|
||||||
gmTimes.changeState("ADVENTURE", 20L);
|
gmTimes.changeState("ADVENTURE", 20L);
|
||||||
|
|
||||||
assertTrue(gmTimes.getTime("SURVIVAL") == 5L);
|
assertEquals(5L, gmTimes.getTime("SURVIVAL"));
|
||||||
assertTrue(gmTimes.getTime("CREATIVE") == 15L);
|
assertEquals(15L, gmTimes.getTime("CREATIVE"));
|
||||||
assertTrue(gmTimes.getTime("ADVENTURE") == 0L);
|
assertEquals(0L, gmTimes.getTime("ADVENTURE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeStateMissingStartTime() {
|
public void stateIsChangedWhenStartTimeIsDefault() {
|
||||||
GMTimes gmTimes = new GMTimes("SURVIVAL");
|
GMTimes gmTimes = new GMTimes("SURVIVAL");
|
||||||
gmTimes.changeState("CREATIVE", 5L);
|
gmTimes.changeState("CREATIVE", 5L);
|
||||||
|
|
||||||
assertTrue(5L == gmTimes.getTime("SURVIVAL"));
|
assertEquals(5L, gmTimes.getTime("SURVIVAL"));
|
||||||
assertTrue(0L == gmTimes.getTime("CREATIVE"));
|
assertEquals(0L, gmTimes.getTime("CREATIVE"));
|
||||||
|
|
||||||
gmTimes.changeState("ADVENTURE", 20L);
|
gmTimes.changeState("ADVENTURE", 20L);
|
||||||
|
|
||||||
assertTrue(5L == gmTimes.getTime("SURVIVAL"));
|
assertEquals(5L, gmTimes.getTime("SURVIVAL"));
|
||||||
assertTrue(15L == gmTimes.getTime("CREATIVE"));
|
assertEquals(15L, gmTimes.getTime("CREATIVE"));
|
||||||
assertTrue(0L == gmTimes.getTime("ADVENTURE"));
|
assertEquals(0L, gmTimes.getTime("ADVENTURE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeStateMissingStartState() {
|
public void stateIsChangedWhenBeginStateIsDefault() {
|
||||||
GMTimes test = new GMTimes();
|
GMTimes test = new GMTimes();
|
||||||
test.changeState("CREATIVE", 5L);
|
test.changeState("CREATIVE", 5L);
|
||||||
|
|
||||||
assertTrue(5L == test.getTime("CREATIVE"));
|
assertEquals(5L, test.getTime("CREATIVE"));
|
||||||
|
|
||||||
test.changeState("ADVENTURE", 20L);
|
test.changeState("ADVENTURE", 20L);
|
||||||
|
|
||||||
assertTrue(20L == test.getTime("CREATIVE"));
|
assertEquals(20L, test.getTime("CREATIVE"));
|
||||||
assertTrue(0L == test.getTime("ADVENTURE"));
|
assertEquals(0L, test.getTime("ADVENTURE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user