@Test
public void shouldSerializeMessageCorrectly() {

  // Given:
  when(log4jMessage.getParameters()).thenReturn(new Object[]{logMessage});
  final Schema logSchema = mock(Schema.class);
  final Struct logRecord = mock(Struct.class);
  when(logRecord.schema()).thenReturn(logSchema);
  when(builder.build()).thenReturn(logRecord);
  // When:
  final byte[] serialized = layout.toByteArray(logEvent);
  // Then:
  verifyBeforeBuild(builder, io -> io.verify(builder).withLoggerName(LOGGER_NAME));
  verifyBeforeBuild(builder, io -> io.verify(builder).withTimeMs(LOG_TIME_MS));
  verifyBeforeBuild(builder, io -> io.verify(builder).withLevel(LOG_LEVEL.name()));
  verifyBeforeBuild(
      builder,
      io -> io.verify(builder).withMessageSchemaAndValue(schemaAndValue));
  verify(converter, times(1))
      .apply(logRecord);
  assertThat(serialized, equalTo(SERIALIZED_MSG));
}