package io.github.kongeor.mocking.anonymous.service;

import static org.fest.assertions.api.Assertions.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import io.github.kongeor.mocking.anonymous.filter.HeroWormFilter;
import io.github.kongeor.mocking.anonymous.model.Worm;

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

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareEverythingForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareEverythingForTest
public class WormServiceTest {

	private List<Worm> worms;
	private @Mock Worm worm;
	private @Mock RemoteService remoteService;
	private @Mock HeroWormFilter heroWormFilter;
	
	private WormService wormService;

	@Before
	public void setUp() throws Exception {
		worms = new ArrayList<>();
		worms.add(worm);
		
		whenNew(HeroWormFilter.class).withArguments(worm, remoteService)
				.thenReturn(heroWormFilter);

		wormService = new WormService(worms, remoteService);
	}
	
	@Test
	public void testGetHeroes() {
		when(heroWormFilter.isHero()).thenReturn(true);
		assertThat(wormService.getHeroes()).containsExactly(worm);
	}

}

@@ -562,34 +562,24 @@
 ions.Prepare
-Everything
 ForTest;%0Aimp
@@ -673,25 +673,96 @@
 pare
-EverythingForTest
+ForTest(fullyQualifiedNames=%22io.github.kongeor.mocking.anonymous.service.WormService$1%22)
 %0Apub

Prepare for test only the class that is required.