package io.specto.hoverfly.junit;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class TearDownTest {

    @Rule
    public HoverflyRule hoverflyRule = HoverflyRule.buildFromClassPathResource("test-service.json").build();

    private HttpClient httpClient;

    private static String hoverflyBinaryPath;

    @Before
    public void setUp() {
        httpClient = HttpClientBuilder.create().useSystemProperties().build();
    }

    @Test
    public void executeTestToSetupHoverflyBinariesConfigAndTempData() throws IOException {
        // Given
        final HttpGet httpGet = new HttpGet("https://www.my-test.com/api/bookings/1");

        // When
        final HttpResponse response = httpClient.execute(httpGet);

        // Then
        assertThatJson(EntityUtils.toString(response.getEntity())).isEqualTo("{" +
                "\"bookingId\":\"1\"," +
                "\"origin\":\"London\"," +
                "\"destination\":\"Singapore\"," +
                "\"time\":\"2011-09-01T12:30\"," +
                "\"_links\":{\"self\":{\"href\":\"http://localhost/api/bookings/1\"}}" +
                "}");

        // set the current hoverflyBinaryPath location for @AfterClass assertion
        TearDownTest.hoverflyBinaryPath = hoverflyRule.getBinaryPath().toString();
    }

    @AfterClass
    public static void b_allHoverflyTempFilesShouldBeDeleted() throws IOException {

        // Given
        // The executeTestToSetupHoverflyBinariesConfigAndTempData has completed successfully

        // When
        Path hoverflyBinaryPath = Paths.get(TearDownTest.hoverflyBinaryPath);
        Path hoverflyDatabasePath = hoverflyBinaryPath.getParent().resolve("requests.db");

        // Then
        assertThat(Files.exists(hoverflyBinaryPath), is(false));
        assertThat(Files.exists(hoverflyDatabasePath), is(false));
    }
}

@@ -1895,10 +1895,8 @@
 oid 
-b_
 allH

Change method name to be more meaningful