### Question:
ReserveTruckCommandService { public String reserveTruck(ReserveTruckCommandDto commandDto) { String confirmationNumber = factory.make(); ReservationRequestedEvent event = new ReservationRequestedEvent( confirmationNumber, commandDto.getTruckType(), commandDto.getMetroArea(), commandDto.getPickupStoreId(), LocalDate.parse(commandDto.getPickupDate()), commandDto.getDropoffStoreId(), LocalDate.parse(commandDto.getDropoffDate()), commandDto.getCustomerName(), commandDto.getCreditCardNumber() ); eventPublisher.publish(event); return confirmationNumber; } ReserveTruckCommandService(AsyncEventPublisher<ReservationRequestedEvent> eventPublisher,
                                      ConfirmationNumberFactory factory); String reserveTruck(ReserveTruckCommandDto commandDto);  }### Answer:
@Test public void handleCommand() { String expectedConfirmationNumber = "12345"; doReturn(expectedConfirmationNumber) .when(mockFactory) .make(); ReserveTruckCommandDto commandDto = new ReserveTruckCommandDto( "some-truck-type", "some-metro-area", "some-pickup-store-id", "2018-01-01", "some-dropoff-store-id", "2018-02-01", "some-customer-name", "some-credit-card-number"); String confirmationNumber = service.reserveTruck(commandDto); assertThat(confirmationNumber).isEqualTo(expectedConfirmationNumber); InOrder inOrder = inOrder(mockPublisher, mockFactory); inOrder.verify(mockFactory).make(); ReservationRequestedEvent expectedEvent = new ReservationRequestedEvent( expectedConfirmationNumber, "some-truck-type", "some-metro-area", "some-pickup-store-id", LocalDate.of(2018, 01, 01), "some-dropoff-store-id", LocalDate.of(2018, 02, 01), "some-customer-name", "some-credit-card-number" ); inOrder.verify(mockPublisher).publish(expectedEvent); }