// Path: benchmarks-api/src/main/java/uk/co/real_logic/benchmarks/remote/PersistedHistogram.java
// static final String AGGREGATE_FILE_SUFFIX = "-combined" + FILE_EXTENSION;


import static org.mockito.Mockito.*;
import static uk.co.real_logic.benchmarks.remote.PersistedHistogram.AGGREGATE_FILE_SUFFIX;
import org.HdrHistogram.EncodableHistogram;
import org.HdrHistogram.Histogram;
import org.HdrHistogram.HistogramLogReader;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;

    @Test
    void saveToFileCreatesNewFileWithIndexZero(final @TempDir Path tempDir) throws IOException
    {
        Files.createFile(tempDir.resolve("another-one-13.hdr"));

        final Histogram histogram = new Histogram(3);
        histogram.setStartTimeStamp(123456789);
        histogram.setEndTimeStamp(987654321);
        histogram.recordValue(100);
        histogram.recordValue(1000);
        histogram.recordValue(250);

        final PersistedHistogram persistedHistogram = new PersistedHistogram(histogram.copy());

        final Path file = persistedHistogram.saveToFile(tempDir, "test-histogram");

        assertNotNull(file);
        assertTrue(Files.exists(file));
        assertEquals("test-histogram-0.hdr", file.getFileName().toString());
        final Histogram savedHistogram = readHistogram(file);
        assertEquals(histogram, savedHistogram);
        assertEquals(histogram.getStartTimeStamp(), savedHistogram.getStartTimeStamp());
        assertEquals(histogram.getEndTimeStamp(), savedHistogram.getEndTimeStamp());
    }

    @Test
    void saveToFileCreatesNewFileByIncrementExistingMaxIndex(final @TempDir Path tempDir) throws IOException
    {
        Files.createFile(tempDir.resolve("another_one-13.hdr"));
// Path: benchmarks-api/src/main/java/uk/co/real_logic/benchmarks/remote/PersistedHistogram.java
// static final String AGGREGATE_FILE_SUFFIX = "-combined" + FILE_EXTENSION;


// Path: benchmarks-api/src/test/java/uk/co/real_logic/benchmarks/remote/PersistedHistogramTest.java
import static org.mockito.Mockito.*;
import static uk.co.real_logic.benchmarks.remote.PersistedHistogram.AGGREGATE_FILE_SUFFIX;
import org.HdrHistogram.EncodableHistogram;
import org.HdrHistogram.Histogram;
import org.HdrHistogram.HistogramLogReader;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;


    @Test
    void saveToFileCreatesNewFileWithIndexZero(final @TempDir Path tempDir) throws IOException
    {
        Files.createFile(tempDir.resolve("another-one-13.hdr"));

        final Histogram histogram = new Histogram(3);
        histogram.setStartTimeStamp(123456789);
        histogram.setEndTimeStamp(987654321);
        histogram.recordValue(100);
        histogram.recordValue(1000);
        histogram.recordValue(250);

        final PersistedHistogram persistedHistogram = new PersistedHistogram(histogram.copy());

        final Path file = persistedHistogram.saveToFile(tempDir, "test-histogram");

        assertNotNull(file);
        assertTrue(Files.exists(file));
        assertEquals("test-histogram-0.hdr", file.getFileName().toString());
        final Histogram savedHistogram = readHistogram(file);
        assertEquals(histogram, savedHistogram);
        assertEquals(histogram.getStartTimeStamp(), savedHistogram.getStartTimeStamp());
        assertEquals(histogram.getEndTimeStamp(), savedHistogram.getEndTimeStamp());
    }

    @Test
    void saveToFileCreatesNewFileByIncrementExistingMaxIndex(final @TempDir Path tempDir) throws IOException
    {
        Files.createFile(tempDir.resolve("another_one-13.hdr"));
        Files.createFile(tempDir.resolve("another_one" + AGGREGATE_FILE_SUFFIX));