0
The variable result is returning NULL although the Object is filled.
This is my test;
@RunWith(MockitoJUnitRunner.class)
public class IndicioDAOTest {
@Mock
private IndicioDAO indicioDAO;
@Test
public void findByIdIndicio() {
IndicioEntity entity = criarIndicioEntity();
IndicioEntity result = indicioDAO.getPorId(entity.getCodigo());
assertThat(result, notNullValue());
}
private IndicioEntity criarIndicioEntity() {
TipoIndicioEntity tipoIndicio = new TipoIndicioEntity();
tipoIndicio.setCodigo(1);
NaturezaIndicioEntity naturezaIndicio = new NaturezaIndicioEntity();
naturezaIndicio.setCodigo(1);
SituacaoIndicioEntity situacaoIndicio = new SituacaoIndicioEntity();
situacaoIndicio.setCodigo(1);
PessoaJuridicaPublicaEntity pessoaJuridicaPublicaEntity = new PessoaJuridicaPublicaEntity();
pessoaJuridicaPublicaEntity.setCodigo(1);
IndicioEntity entity = new IndicioEntity();
entity.setCodigo(1);
entity.setTipoIndicio(tipoIndicio);
entity.setUnidadeJurisdicionada(pessoaJuridicaPublicaEntity);
entity.setCodigoNaturezaIndicio(naturezaIndicio.getCodigo());
entity.setCpfServidor("80445500700");
entity.setDescricao("qualquer valor dentro");
entity.setValor(1500.0);
entity.setPrazo(15);
entity.setSituacaoAtual(situacaoIndicio);
entity.setDataUltimaMovimentacao(getDataAtual());
return entity;
}
}
Note the image of a debug execution;
But my object is filled;
I need help fixing the bug!
You’re right, the test passed, but how could I check if the returned value is the value I sent to the mock?
– wladyband
I’ve seen it, you don’t have to.... Thank you very much anyway.
– wladyband