infoboxmanager: Test infoboxes with same plugin and priority
See: 406c2bc7db
This commit is contained in:
@@ -40,6 +40,7 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
@@ -60,16 +61,31 @@ public class InfoBoxManagerTest
|
|||||||
|
|
||||||
private static class TestInfobox extends InfoBox
|
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);
|
setPriority(infoBoxPriority);
|
||||||
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText()
|
public String getText()
|
||||||
{
|
{
|
||||||
return null;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,4 +105,14 @@ public class InfoBoxManagerTest
|
|||||||
List<InfoBoxPriority> order = infoBoxManager.getInfoBoxes().stream().map(InfoBox::getPriority).collect(Collectors.toList());
|
List<InfoBoxPriority> order = infoBoxManager.getInfoBoxes().stream().map(InfoBox::getPriority).collect(Collectors.toList());
|
||||||
assertEquals(Arrays.asList(InfoBoxPriority.HIGH, InfoBoxPriority.MED, InfoBoxPriority.LOW), order);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user