I'm having a problem with my Unit Test that implies my Service class in my application involing the Dao.
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private AvisDao avisDao;
@InjectMocks
private ApiPortalsService service = new ApiPortalsServiceImpl();
@Before
public void initMocksWS() throws Exception{
MockitoAnnotations.initMocks(this);
}
Factory factoria = FactoryImpl.getInstance();
@Test
public void testGuardarAvisos() throws Exception{
Mockito.when(avisDao.existsPortalContingut(AvisPortal.class.cast(Matchers.anyObject()))).thenAnswer(new Answer<boolean>(){
@Override
public boolean answer(InvocationOnMock invocation) throws Throwable{
return true;
}
});
}
Here is the Test class, the error is occuring when I try to set the thenAnswer
with a boolean. The method existsPortalContingut
that contains an object returns a boolean. This is the first time I'm trying to create a Test class if I forget something, please tell me and I'll edit it.
What I am declaring wrong?
boolean existsPortalContingut(final AvisPortal portalContenido);
This is the method I'm trying to call in the Dao
Aucun commentaire:
Enregistrer un commentaire