@Test
public void shouldThrowValidationExceptionIfTheJsonEnvelopeContainsNoMetadata() throws Exception {

    final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class);
    when(jsonEnvelope.metadata()).thenReturn(null);
    try {
        envelopeInspector.getMetadataFor(jsonEnvelope);
        fail();
    } catch (final EnvelopeValidationException expected) {
        assertThat(expected.getMessage(), is("Metadata not set in the envelope."));
    }
}