package com.corwinjv.mobtotems.blocks.tiles.TotemLogic;

import com.corwinjv.mobtotems.utils.testingstaticmock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.init.Blocks;
import net.minecraft.init.Bootstrap;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.Level;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;

/**
 * Created by CorwinJV on 3/14/2017.
 */
@SuppressStaticInitializationFor({"net.minecraft.init.Blocks", "net.minecraft.init.Items"})
@PowerMockIgnore({"javax.management.*"})
@PrepareForTest({BlazeLogic.class, Bootstrap.class, Items.class, Blocks.class, testingstaticmock.class})
@RunWith(PowerMockRunner.class)
public class BlazeLogicTest {
    BlazeLogic blazeLogic = null;
    @Mock
    World world;
    @Mock
    BlockPos blockPos;
    @Mock
    Modifiers modifiers;
    @Mock
    Block retBlock;

    // Hack to get around isImmuneToFire() (a minecraft method) being final
    class TestEntityMob extends EntityMob {
        public TestEntityMob(World worldIn) {
            super(worldIn);
            isImmuneToFire = false;
        }
    }

    @Mock
    TestEntityMob entityTargetInRange;
    @Mock
    TestEntityMob entityTargetOutOfRange;

    @Before
    public void setUp() throws Exception {
        // Powermock wizardry
        mockStatic(Bootstrap.class);
        Mockito.when(Bootstrap.isRegistered()).thenReturn(true);

        mockStatic(Items.class);
        PowerMockito.spy(Items.class);

        mockStatic(Blocks.class);
        PowerMockito.spy(Blocks.class);

        // Normal mockito stuff
        blazeLogic = new BlazeLogic();

        when(blockPos.getX()).thenReturn(100);
        when(blockPos.getY()).thenReturn(64);
        when(blockPos.getZ()).thenReturn(100);

        when(entityTargetInRange.getPosition()).thenReturn(new BlockPos(102, 64, 102));
        when(entityTargetOutOfRange.getPosition()).thenReturn(new BlockPos(182, 64, 182));

        List<Entity> entityList = new ArrayList<>();
        entityList.add(entityTargetInRange);
        entityList.add(entityTargetOutOfRange);

        when(world.getEntitiesWithinAABB(eq(Entity.class), any(AxisAlignedBB.class))).thenReturn(entityList);
    }


    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void getCost() throws Exception {
        //PowerMockito.when(retBlock.getRegistryName()).thenReturn(new ResourceLocation("minecraft:retBlock"));
        //PowerMockito.when(Blocks.class, "getRegisteredBlock", any()).thenReturn(retBlock);
        List<ItemStack> items = blazeLogic.getCost();
        assertEquals(1, items.size());
        //FMLLog.log(Level.INFO, "%s", items.get(0).toString());
    }

    @Test
    public void getEffectType() throws Exception {
        assertEquals(TotemLogic.EffectType.EFFECT, blazeLogic.getEffectType());
    }

    @Test
    public void performEffect() throws Exception {
        blazeLogic.performEffect(world, blockPos, modifiers);

        verify(entityTargetInRange).setFire(anyInt());
        verify(entityTargetOutOfRange, never()).setFire(anyInt());
    }
}

@@ -61,209 +61,33 @@
 ort 
-com.corwinjv.mobtotems.utils.testingstaticmock;%0Aimport net.minecraft.block.Block;%0Aimport net.minecraft.block.BlockAir;%0Aimport net.minecraft.block.BlockDirt;%0Aimport net.minecraft.block.material.Material
+net.minecraft.block.Block
 ;%0Aim
@@ -312,52 +312,8 @@
 ck;%0A
-import net.minecraft.util.ResourceLocation;%0A
 impo
@@ -395,16 +395,16 @@
 ockPos;%0A
+
 import n
@@ -433,92 +433,8 @@
 ld;%0A
-import net.minecraftforge.fml.common.FMLLog;%0Aimport org.apache.logging.log4j.Level;%0A
 impo
@@ -1584,33 +1584,8 @@
 lass
-, testingstaticmock.class
 %7D)%0A@

Fix missing references