View Javadoc
1   package org.opentrafficsim.core.mock;
2   
3   import org.mockito.Mockito;
4   import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
5   import org.opentrafficsim.core.gtu.GTU;
6   
7   /**
8    * MockGTU.java. <br>
9    * <br>
10   * Copyright (c) 2003-2019 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
11   * for project information <a href="https://www.simulation.tudelft.nl/" target="_blank">www.simulation.tudelft.nl</a>. The
12   * source code and binary code of this software is proprietary information of Delft University of Technology.
13   * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a>
14   */
15  public class MockGTU
16  {
17      /** mocked GTU. */
18      private GTU mockGTU;
19  
20      /** name. */
21      private String name;
22  
23      /** mocked simulator. */
24      private OTSSimulatorInterface simulator = MockDEVSSimulator.createMock();
25  
26      /**
27       * @param name the name
28       */
29      public MockGTU(final String name)
30      {
31          super();
32          this.name = name;
33          this.mockGTU = Mockito.mock(GTU.class);
34          Mockito.when(this.mockGTU.getSimulator()).thenReturn(this.simulator);
35          Mockito.when(this.mockGTU.getId()).thenReturn(this.name);
36      }
37  
38      /**
39       * @return mocked DEVSSimulator
40       */
41      public GTU getMock()
42      {
43          return this.mockGTU;
44      }
45  
46  }