AtomixLogStorageReader implements LogStorageReader { @Override public boolean isEmpty() { if (!reader.isEmpty()) { reader.reset(); while (reader.hasNext()) { if (reader.next().type() == ZeebeEntry.class) { return false; } } } return true; } AtomixLogStorageReader(
      final ZeebeIndexMapping zeebeIndexMapping, final RaftLogReader reader); @Override boolean isEmpty(); @Override long read(final DirectBuffer readBuffer, final long address); @Override long readLastBlock(final DirectBuffer readBuffer); @Override long lookUpApproximateAddress(final long position); @Override void close(); Optional<Indexed<ZeebeEntry>> findEntry(final long index);  }
@Test public void shouldReturnEmptyIfLogIsEmpty() { final var reader = storageRule.get().newReader(); final var isEmpty = reader.isEmpty(); assertThat(isEmpty).isTrue(); }
@Test public void shouldReturnEmptyIfLogContainsNonZeebeEntries() { final var reader = storageRule.get().newReader(); final var entry = storageRule .getRaftLog() .writer() .append(new ConfigurationEntry(1, System.currentTimeMillis(), Collections.emptyList())); final var isEmpty = reader.isEmpty(); assertThat(entry).isNotNull(); assertThat(isEmpty).isTrue(); }
@Test public void shouldNotReturnEmptyIfAtLeastOneZeebeEntryPresent() { final var reader = storageRule.get().newReader(); final var entry = storageRule .getRaftLog() .writer() .append(new ConfigurationEntry(1, System.currentTimeMillis(), Collections.emptyList())); final var expected = append(1, 4, allocateData(1)); final var isEmpty = reader.isEmpty(); assertThat(entry).isNotNull(); assertThat(expected).isNotNull(); assertThat(isEmpty).isFalse(); }