Package org.terasology.logic.inventory.action

Examples of org.terasology.logic.inventory.action.RemoveItemAction


        ItemComponent itemCompCopy = new ItemComponent();
        setupItemRef(itemCopy, itemCompCopy, 2, 10);

        Mockito.when(entityManager.copy(item)).thenReturn(itemCopy);

        RemoveItemAction action = new RemoveItemAction(instigator, item, false, 1);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertEquals(1, itemComp.stackCount);
        assertEquals(1, itemCompCopy.stackCount);

        Mockito.verify(item, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item, new AtLeast(0)).iterateComponents();
        Mockito.verify(item).saveComponent(itemComp);
        Mockito.verify(itemCopy, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(itemCopy, new AtLeast(0)).iterateComponents();
        Mockito.verify(itemCopy).saveComponent(itemCompCopy);
        Mockito.verify(inventory, new AtLeast(0)).getComponent(InventoryComponent.class);
        Mockito.verify(inventory).send(Matchers.any(InventorySlotStackSizeChangedEvent.class));
        Mockito.verify(entityManager).copy(item);

        Mockito.verifyNoMoreInteractions(instigator, inventory, entityManager, item, itemCopy);

        assertTrue(action.isConsumed());
        assertEquals(itemCopy, action.getRemovedItem());
    }
View Full Code Here


        EntityRef item = Mockito.mock(EntityRef.class);
        setupItemRef(item, itemComp, 2, 10);

        inventoryComp.itemSlots.set(0, item);

        RemoveItemAction action = new RemoveItemAction(instigator, item, false, 2);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertTrue(action.isConsumed());
        assertEquals(item, action.getRemovedItem());

        assertEquals(EntityRef.NULL, inventoryComp.itemSlots.get(0));

        Mockito.verify(item, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item, new AtLeast(0)).exists();
View Full Code Here

        EntityRef item = Mockito.mock(EntityRef.class);
        setupItemRef(item, itemComp, 2, 10);

        inventoryComp.itemSlots.set(0, item);

        RemoveItemAction action = new RemoveItemAction(instigator, item, true, 1);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertEquals(1, itemComp.stackCount);

        Mockito.verify(item, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item).saveComponent(itemComp);
        Mockito.verify(inventory, new AtLeast(0)).getComponent(InventoryComponent.class);
        Mockito.verify(inventory).send(Matchers.any(InventorySlotStackSizeChangedEvent.class));

        Mockito.verifyNoMoreInteractions(instigator, inventory, entityManager, item);

        assertTrue(action.isConsumed());
        assertNull(action.getRemovedItem());
    }
View Full Code Here

        EntityRef item = Mockito.mock(EntityRef.class);
        setupItemRef(item, itemComp, 2, 10);

        inventoryComp.itemSlots.set(0, item);

        RemoveItemAction action = new RemoveItemAction(instigator, item, true, 2);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertTrue(action.isConsumed());
        assertNull(action.getRemovedItem());

        assertEquals(EntityRef.NULL, inventoryComp.itemSlots.get(0));

        Mockito.verify(item, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item, new AtLeast(0)).exists();
View Full Code Here

        ItemComponent itemComp2 = new ItemComponent();
        setupItemRef(item2, itemComp2, 2, 10);

        inventoryComp.itemSlots.set(1, item2);

        RemoveItemAction action = new RemoveItemAction(instigator, Arrays.asList(item1, item2), false, 3);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertEquals(EntityRef.NULL, inventoryComp.itemSlots.get(0));
        assertEquals(3, itemComp1.stackCount);
        assertEquals(1, itemComp2.stackCount);
        assertTrue(action.isConsumed());
        assertEquals(item1, action.getRemovedItem());

        Mockito.verify(item1, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item1, new AtLeast(0)).exists();
        Mockito.verify(item1, new AtLeast(0)).iterateComponents();
        Mockito.verify(item1).saveComponent(itemComp1);
View Full Code Here

        ItemComponent itemComp2 = new ItemComponent();
        setupItemRef(item2, itemComp2, 2, 10);

        inventoryComp.itemSlots.set(1, item2);

        RemoveItemAction action = new RemoveItemAction(instigator, Arrays.asList(item1, item2), true, 3);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertEquals(EntityRef.NULL, inventoryComp.itemSlots.get(0));
        assertEquals(1, itemComp2.stackCount);
        assertTrue(action.isConsumed());
        assertNull(action.getRemovedItem());

        Mockito.verify(item1, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item1, new AtLeast(0)).exists();
        Mockito.verify(item1, new AtLeast(0)).iterateComponents();
        Mockito.verify(item1).destroy();
View Full Code Here

                        return null;
                    }
                }
        );

        RemoveItemAction action = new RemoveItemAction(instigator, item, true, 2);
        inventoryAuthoritySystem.removeItem(action, inventory);

        assertFalse(action.isConsumed());
        assertNull(action.getRemovedItem());

        Mockito.verify(item, new AtLeast(0)).getComponent(ItemComponent.class);
        Mockito.verify(item, new AtLeast(0)).exists();
        Mockito.verify(inventory, new AtLeast(0)).getComponent(InventoryComponent.class);
        Mockito.verify(inventory).send(Matchers.any(BeforeItemRemovedFromInventory.class));
View Full Code Here

TOP

Related Classes of org.terasology.logic.inventory.action.RemoveItemAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.