Search in sources :

Example 81 with Colony

use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.

the class CommandEntryPointTest method setUp.

@Before
public void setUp() {
    final Colony colony1 = mock(Colony.class);
    when(colony1.getID()).thenReturn(1);
    final Colony colony2 = mock(Colony.class);
    when(colony2.getID()).thenReturn(2);
    @SuppressWarnings("unchecked") final List<Colony> colonyList = Arrays.asList(new Colony[] { colony1, colony2 });
    final ICitizenManager citizenManager1 = mock(ICitizenManager.class);
    when(colony1.getCitizenManager()).thenReturn(citizenManager1);
    final ICitizenManager citizenManager2 = mock(ICitizenManager.class);
    when(colony2.getCitizenManager()).thenReturn(citizenManager2);
    final List<CitizenData> citizenDataList1 = new ArrayList<>();
    when(citizenManager1.getCitizens()).thenReturn(citizenDataList1);
    final CitizenData citizenJohnSSmith = mock(CitizenData.class);
    when(citizenJohnSSmith.getId()).thenReturn(1);
    when(citizenJohnSSmith.getName()).thenReturn("John S. Smith");
    citizenDataList1.add(citizenJohnSSmith);
    when(citizenManager1.getCitizen(1)).thenReturn(citizenJohnSSmith);
    final CitizenData citizenJohnSJones = mock(CitizenData.class);
    when(citizenJohnSJones.getId()).thenReturn(4);
    when(citizenJohnSJones.getName()).thenReturn("John S. Jones");
    citizenDataList1.add(citizenJohnSJones);
    when(citizenManager1.getCitizen(4)).thenReturn(citizenJohnSJones);
    final CitizenData citizenJohnAJones = mock(CitizenData.class);
    when(citizenJohnAJones.getId()).thenReturn(2);
    when(citizenJohnAJones.getName()).thenReturn("John A. Jones");
    citizenDataList1.add(citizenJohnAJones);
    when(citizenManager1.getCitizen(2)).thenReturn(citizenJohnAJones);
    final CitizenData citizenJennaQBar = mock(CitizenData.class);
    when(citizenJennaQBar.getId()).thenReturn(3);
    when(citizenJennaQBar.getName()).thenReturn("Jenna Q. Bar");
    citizenDataList1.add(citizenJennaQBar);
    when(citizenManager1.getCitizen(3)).thenReturn(citizenJennaQBar);
    PowerMockito.mockStatic(ColonyManager.class);
    BDDMockito.given(ColonyManager.getColonies()).willReturn(colonyList);
    BDDMockito.given(ColonyManager.getColony(1)).willReturn(colony1);
    BDDMockito.given(ColonyManager.getColony(2)).willReturn(colony2);
    PowerMockito.mockStatic(PermissionAPI.class);
    BDDMockito.given(PermissionAPI.hasPermission(any(), any())).willReturn(true);
    final EntityPlayerMP playerBob = mock(EntityPlayerMP.class);
    when(playerBob.getName()).thenReturn("Bob");
    final EntityPlayerMP playerSally = mock(EntityPlayerMP.class);
    when(playerSally.getName()).thenReturn("Sally");
    final PlayerList serverPlayerList = mock(PlayerList.class);
    when(serverPlayerList.getPlayerByUsername("Bob")).thenReturn(playerBob);
    when(serverPlayerList.getPlayerByUsername("Sally")).thenReturn(playerSally);
    server = mock(MinecraftServer.class);
    when(server.getOnlinePlayerNames()).thenReturn(new String[] { "Bob", "Sally" });
    when(server.getPlayerList()).thenReturn(serverPlayerList);
    sender = mock(MinecraftServer.class);
    instance = new CommandEntryPointNew();
    pos = new BlockPos(1, 2, 3);
}
Also used : PlayerList(net.minecraft.server.management.PlayerList) ICitizenManager(com.minecolonies.coremod.colony.managers.ICitizenManager) ArrayList(java.util.ArrayList) Colony(com.minecolonies.coremod.colony.Colony) CitizenData(com.minecolonies.coremod.colony.CitizenData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) MinecraftServer(net.minecraft.server.MinecraftServer) Before(org.junit.Before)

Aggregations

Colony (com.minecolonies.coremod.colony.Colony)81 TextComponentString (net.minecraft.util.text.TextComponentString)29 IColony (com.minecolonies.api.colony.IColony)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 BlockPos (net.minecraft.util.math.BlockPos)19 Nullable (org.jetbrains.annotations.Nullable)16 CitizenData (com.minecolonies.coremod.colony.CitizenData)13 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)13 NotNull (org.jetbrains.annotations.NotNull)11 ItemStack (net.minecraft.item.ItemStack)9 Entity (net.minecraft.entity.Entity)8 TileEntity (net.minecraft.tileentity.TileEntity)8 World (net.minecraft.world.World)6 List (java.util.List)5 UUID (java.util.UUID)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)4 Delivery (com.minecolonies.api.colony.requestsystem.requestable.Delivery)4 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)4 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)4