I have a DTO class where they have a mapping using functional foreach.
What is the best way to test them?
Follow the method below:
public static BlockSaldDeb convertCred(MapExec mapExec) { mapExec.getBlock().forEach(b -> { BlockMapExec blockCred = (BlockMapExec) b; List<LancCred> listCred = new ArrayList<>(); List<LancDeb> listDeb = new ArrayList<>(); blockCred.getOp().forEach(op -> { if (op.getTypeOp().equals(TypeOp.CRED)) { LancCred lancCred = LancamentoCredito.newBuilder() .setNumberContPart(op.geNumberContPart().toString()) .setNameLancCont("C") .setValueLanc(op.getValue().doubleValue()) .build(); listCred.add(lancCred); } else if (op.getTypeOp().equals(TypeOp.DEB)) { LancDeb lancDeb = LancDeb.newBuilder() .setNumberContPart(operacao.getNumberContPart().toString()) .setNameLancCont("D") .setValueLanc(op.getValue().doubleValue()) .build(); listDeb.add(LancDeb); } }); return... }
The test case I need is to compare whether the set is the same as the get.
I am new to unit testing and I will be very grateful for your help.