public synchronized void write(final LocalCommand localCommand) throws IOException {
    if (writer == null) {
      throw new IOException("Write permission denied.");
    }

    final byte[] bytes = MAPPER.writeValueAsBytes(localCommand);
    writer.write(bytes);
    writer.write(NEW_LINE_SEPARATOR_BYTES);
    writer.flush();
  }
@Test
  public void shouldWriteRecord() throws IOException {
    // When
    localCommandsFile.write(LOCAL_COMMAND1);
    localCommandsFile.write(LOCAL_COMMAND2);

    // Then
    final List<String> commands = Files.readAllLines(internalCommandsFile.toPath());
    assertThat(commands.size(), is(2));
    assertThat(commands.get(0), is("{\"@type\":\"transient_query\",\"queryApplicationId\":"
        + "\"_confluent-ksql-default_transient_932097300573686369_1606940079718\"}"));
    assertThat(commands.get(1), is("{\"@type\":\"transient_query\",\"queryApplicationId\":"
        + "\"_confluent-ksql-default_transient_123457300573686369_1606940012343\"}"));
  }