public class Avaliador {
//...
public void calculaValorMedio(Leilao leilao) {
double media = (leilao.getLances().stream().mapToDouble(lance -> lance.getValor()).sum())
/ leilao.getLances().size();
this.valorMedioDosLances = media;
}
}
public class TesteDoAvaliador {
@Test
public void deveEntenderLancesEmOrdemCrescente() {
//...
double mediaEsperada = 316.66;
Assert.assertEquals(mediaEsperada, leiloeiro.getValorMedioDosLances(), 0.01);
}
}