Closed averbraeck closed 3 weeks ago
The code that does not work is:
Gtu gtu = new Gtu()
{
@Override
public OrientedPoint2d getLocation()
{
// This GTU travels a circle around 100, 20, elevation 10, radius 20, angular velocity 0.1 radial / second
double timeSI = GtuDumperTest.this.simulator.getSimulatorTime().si;
double angle = timeSI / 10;
return new OrientedPoint2d(100 + 20 * Math.cos(angle), 20 + 20 * Math.sin(angle), angle + Math.PI / 2);
}
};
Gtu
needs al sorts of input parameters. It has been replaced with:
Gtu gtu = Mockito.mock(Gtu.class);
Mockito.when(gtu.getLocation()).thenAnswer((invocationOnMock) ->
{
// This GTU travels a circle around 100, 20, elevation 0, radius 20, angular velocity 0.1 radial / second
double timeSI = GtuDumperTest.this.simulator.getSimulatorTime().si;
double angle = AngleUtil.normalizeAroundPi(timeSI / 10.0);
return new OrientedPoint2d(100.0 + 20.0 * Math.cos(angle), 20.0 + 20.0 * Math.sin(angle), angle);
});
Mockito.when(gtu.getSpeed()).thenReturn(Speed.instantiateSI(2.0));
Mockito.when(gtu.toString()).thenReturn("test GTU");
The unit test works again.
GtuDumperTest
in ots-core used to have a methodcreateGTU
(nowcreateGtuDeprecated
), but most lines have been commented out. The test needs a few updates, but does not prevent an OTS release from being built right now, so it is not urgent.