@@ -0,0 +1,1891 @@
+package com.devotedmc.ExilePearl.core;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.*;%0A%0Aimport org.apache.commons.lang.NullArgumentException;%0Aimport org.bukkit.scheduler.BukkitScheduler;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport com.devotedmc.ExilePearl.ExilePearlApi;%0Aimport com.devotedmc.ExilePearl.PearlConfig;%0A%0Apublic class PearlDecayTaskTest %7B%0A%09%0A%09private BukkitScheduler mockScheduler;%0A%09private PearlConfig pearlConfig;%0A%09private ExilePearlApi pearlApi;%0A%09private PearlDecayTask dut;%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09%0A%09%09mockScheduler = mock(BukkitScheduler.class);%0A%09%09%0A%09%09pearlConfig = mock(PearlConfig.class);%0A%09%09when(pearlConfig.getPearlHealthDecayIntervalMin()).thenReturn(60);%0A%09%09%0A%09%09pearlApi = mock(ExilePearlApi.class);%0A%09%09when(pearlApi.getPearlConfig()).thenReturn(pearlConfig);%0A%09%09when(pearlApi.getScheduler()).thenReturn(mockScheduler);%0A%09%09%0A%09%09dut = spy(new PearlDecayTask(pearlApi));%0A%09%7D%0A%0A%09@Test%0A%09public void testPlayerSuicideTask() %7B%0A%09%09// Null arguments throw exceptions%0A%09%09Throwable e = null;%0A%09%09try %7B new PearlDecayTask(null); %7D catch (Throwable ex) %7B e = ex; %7D%0A%09%09assertTrue(e instanceof NullArgumentException);%0A%09%7D%0A%0A%09@Test%0A%09public void testStartStop() %7B%0A%09%09%0A%09%09assertFalse(dut.isRunning());%0A%09%09%0A%09%09dut.start();%0A%09%09verify(mockScheduler).scheduleSyncRepeatingTask(null, dut, 72000, 72000);%0A%09%09assertTrue(dut.isRunning());%0A%09%09%0A%09%09dut.start();%0A%09%09verify(mockScheduler).scheduleSyncRepeatingTask(null, dut, 72000, 72000);%0A%09%09assertTrue(dut.isRunning());%0A%09%09%0A%09%09dut.stop();%0A%09%09verify(mockScheduler).cancelTask(anyInt());%0A%09%09assertFalse(dut.isRunning());%0A%09%7D%0A%0A%09@Test%0A%09public void testRestart() %7B%09%09%0A%09%09dut.restart();%0A%09%09verify(dut).stop();%0A%09%09verify(dut).start();%0A%09%09assertTrue(dut.isRunning());%0A%09%7D%0A%0A%09@Test%0A%09public void testRun() %7B%0A%09%09dut.run();%0A%09%09verify(pearlApi, times(0)).decayPearls();%0A%0A%09%09dut.start();%0A%09%09dut.run();%0A%09%09verify(pearlApi).decayPearls();%0A%09%7D%0A%7D%0A

Add decay task test