1
I know exactly what I need to mock about the object data, but I have no idea how to implement a test when it comes to a list of objects, I just need an example, someone could only show me an example by which I can have a brief notion of how to implement my unit test in relation to the context of that method below which is in the service class?
@Service
@TransactionalEntrada
public class IndicioService extends AbstractService<IndicioEntity, IndicioDAO> {
@Autowired
private HistoricoSituacaoService historicoSituacaoService;
@Autowired
private IndicioDAO indicioDAO;
@Override
protected IndicioDAO getDao() {
return indicioDAO;
}
public void importarIndicios(List<IndicioEntity> indicios,
UsuarioLogadoExterno usuarioLogado) throws PrincipalException {
for (final IndicioEntity indicio : indicios) {
indicio.setDataUltimaMovimentacao(getDataAtual());
final SituacaoIndicioEntity situacao = new SituacaoIndicioEntity();
situacao.setCodigo(1);
indicio.setSituacaoAtual(situacao);
this.inserir(indicio);// salvar indicios
final HistoricoSituacaoEntity historicoSituacao =
new HistoricoSituacaoEntity();
historicoSituacao.setCodigoUsuario(usuarioLogado.getCodigo());
historicoSituacao.setCodigoIndicio(indicio.getCodigo());
historicoSituacao.setCodigoSituacaoIndicio(
indicio.getSituacaoAtual().getCodigo());
historicoSituacao
.setDataMovimentacao(indicio.getDataUltimaMovimentacao());
historicoSituacaoService.inserir(historicoSituacao);
}
}
}
I understood perfectly your suggestion, I put your code and bumped into two things , line 5 the syntax for was not recognised as valid, and in line 16 of the code the method assertEquals the eclipse said that it accepts in the signature of the method an int and then an integer, maybe I should use another method. because the return is an integer and then another integer.
– wladyband
I apologize, I made the head code :) the correct is
ArgumentCaptor.forClass
– nullptr