@Test(expected = IllegalStateException.class) public void activateActiveVehicle() throws Exception { // Given vehicle.applyEvent(new Activated(vehicle.id)); // When vehicle.activate(); // Should throw IllegalStateException }
@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))); }