Java - Testing Simulation With Mockito

I'm not very well-versed with Mockito but am trying to use mocks to test behaviour of a simulation, this is the class:

package simulator;

import java.util.Map;

import org.apache.commons.lang3.Validate;

import simulator.enums.Team;

import simulator.fixtures.Fixture;

public class SimulateBasketballMatchResult implements Simulation {

private final Fixture fixture;

public SimulateBasketballMatchResult(Fixture fixture) {

Validate.notNull(fixture, "fixture cannot be null");

this.fixture = fixture;

}

@Override

public Team simulate(Map outcomeProbabilityMap) {

Validate.notNull(outcomeProbabilityMap, "outcomeProbabilityMap cannot be null");

final Team homeTeam = fixture.getHomeTeam();

final Team awayTeam = fixture.getAwayTeam();

double random = randomDoubleGenerator();

double homeWinProbability = outcomeProbabilityMap.get(homeTeam);

return random < homeWinProbability ? homeTeam : awayTeam;

}

public Double randomDoubleGenerator() {

return Math.random();

}

}

Below is the test class:

@RunWith(MockitoJUnitRunner.class)

public class SimulateBasketballMatchResultTest {

@Rule

public ExpectedException expectedException = ExpectedException.none();

private static...

Read More »

By: StackOverFlow - Tuesday, 20 November

Related Posts