EasyPowerMockMockMaker implements MockerConfig.MockMaker { @SuppressWarnings("unchecked") @Override public <T> T makeMock(TypeToken<T> typeToken) { T obj = PowerMock.<T>createNiceMock((Class<T>)typeToken.getRawType()); EasyMock.replay(obj); return obj; }  @SuppressWarnings("unchecked") @Override T makeMock(TypeToken<T> typeToken);  }
@Test public void testSimpleMock() { Runnable runnable = mMockMaker.makeMock(TypeToken.of(Runnable.class)); assertThat(runnable) .isNotNull() .is(Conditions.mockCondition()); runnable.run(); }
@Test public void testGenericMock() { TypeToken<HashMap<String, Integer>> typeToken = new TypeToken<HashMap<String, Integer>>() {}; HashMap<String, Integer> hashMap = mMockMaker.makeMock(typeToken); assertThat(hashMap) .isNotNull() .is(Conditions.mockCondition()); Integer retVal = hashMap.get("sup"); assertThat(retVal).isNull(); }