@Test
public void shouldConvertToShutteredCommandAndSave() throws Exception {

    final String destinationName = "destinationName";
    final String envelopeJson = "envelope json";
    final ZonedDateTime now = new UtcClock().now();
    final UUID envelopeId = randomUUID();
    final JsonEnvelope command = mock(JsonEnvelope.class);
    final Metadata metadata = mock(Metadata.class);
    when(command.metadata()).thenReturn(metadata);
    when(metadata.id()).thenReturn(envelopeId);
    when(jsonObjectEnvelopeConverter.asJsonString(command)).thenReturn(envelopeJson);
    when(clock.now()).thenReturn(now);
    shutteringStoreSender.send(command, destinationName);
    verify(storedCommandRepository).save(shutteredCommandCaptor.capture());
    final StoredCommand storedCommand = shutteredCommandCaptor.getValue();
    assertThat(storedCommand.getEnvelopeId(), is(envelopeId));
    assertThat(storedCommand.getCommandJsonEnvelope(), is(envelopeJson));
    assertThat(storedCommand.getDestination(), is(destinationName));
    assertThat(storedCommand.getDateReceived(), is(now));
}