Example #1
0
  @Test(expected = IllegalStateException.class)
  public void activateActiveVehicle() throws Exception {

    // Given
    vehicle.applyEvent(new Activated(vehicle.id));

    // When
    vehicle.activate();

    // Should throw IllegalStateException
  }
Example #2
0
  @Test
  public void activateVehicleTest() throws Exception {

    // When
    vehicle.activate();

    // Then
    List<Event> events = vehicle.getPendingEvents();
    assertTrue(events.size() == 1);
    assertTrue(events.get(0).equals(new Activated(vehicle.id)));
  }