infoboxmanager: Test infoboxes with same plugin and priority

See: 406c2bc7db
This commit is contained in:
Jordan Atwood
2020-05-27 21:29:06 -07:00
committed by Adam
parent 50ca13f031
commit 4b4720751c

View File

@@ -40,6 +40,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
@@ -60,16 +61,31 @@ public class InfoBoxManagerTest
private static class TestInfobox extends InfoBox
{
public TestInfobox(InfoBoxPriority infoBoxPriority)
private static final Plugin PLUGIN = mock(Plugin.class);
static
{
super(null, mock(Plugin.class));
when(PLUGIN.getName()).thenReturn("");
}
private final String text;
private TestInfobox(InfoBoxPriority infoBoxPriority)
{
this(infoBoxPriority, null);
}
private TestInfobox(InfoBoxPriority infoBoxPriority, String text)
{
super(null, PLUGIN);
setPriority(infoBoxPriority);
this.text = text;
}
@Override
public String getText()
{
return null;
return text;
}
@Override
@@ -89,4 +105,14 @@ public class InfoBoxManagerTest
List<InfoBoxPriority> order = infoBoxManager.getInfoBoxes().stream().map(InfoBox::getPriority).collect(Collectors.toList());
assertEquals(Arrays.asList(InfoBoxPriority.HIGH, InfoBoxPriority.MED, InfoBoxPriority.LOW), order);
}
@Test
public void testSamePluginAndPriority()
{
infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "one"));
infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "two"));
infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "three"));
assertEquals(3, infoBoxManager.getInfoBoxes().size());
}
}