@Override
  public void write(String key, InputStream data) {
    checkNotNull(data);
    try {
      write(key, data.readAllBytes());
    } catch (IOException e) {
      throw new IllegalStateException("Failed to read sensor write cache data", e);
    }
  }
@Test
  public void write_throws_IAE_if_writing_same_key_twice() {
    byte[] b1 = new byte[] {1};
    byte[] b2 = new byte[] {2};

    writeCache.write("key", b1);
    assertThatThrownBy(() -> writeCache.write("key", b2))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Cache already contains key 'key'");
  }