// Path: src/main/java/de/sldk/mc/MetricsServer.java
// public class MetricsServer {
// 
// 	private final String host;
// 	private final int port;
// 	private final PrometheusExporter prometheusExporter;
// 
// 	private Server server;
// 
// 	public MetricsServer(String host, int port, PrometheusExporter prometheusExporter) {
// 		this.host = host;
// 		this.port = port;
// 		this.prometheusExporter = prometheusExporter;
// 	}
// 
// 	public void start() throws Exception {
// 		GzipHandler gzipHandler = new GzipHandler();
// 		gzipHandler.setHandler(new MetricsController(prometheusExporter));
// 
// 		InetSocketAddress address = new InetSocketAddress(host, port);
// 		server = new Server(address);
// 		server.setHandler(gzipHandler);
// 
// 		server.start();
// 	}
// 
// 	public void stop() throws Exception {
// 		if (server == null) {
// 			return;
// 		}
// 
// 		server.stop();
// 	}
// }
// 
// Path: src/main/java/de/sldk/mc/PrometheusExporter.java
// public class PrometheusExporter extends JavaPlugin {
// 
//     private final PrometheusExporterConfig config = new PrometheusExporterConfig(this);
//     private MetricsServer server;
// 
//     @Override
//     public void onEnable() {
// 
//         config.loadDefaultsAndSave();
// 
//         config.enableConfiguredMetrics();
// 
//         startMetricsServer();
//     }
// 
//     private void startMetricsServer() {
//         String host = config.get(PrometheusExporterConfig.HOST);
//         Integer port = config.get(PrometheusExporterConfig.PORT);
// 
// 		server = new MetricsServer(host, port, this);
// 
//         try {
//             server.start();
//             getLogger().info("Started Prometheus metrics endpoint at: " + host + ":" + port);
//         } catch (Exception e) {
//             getLogger().severe("Could not start embedded Jetty server");
//         }
//     }
// 
//     @Override
//     public void onDisable() {
//         try {
//             server.stop();
//         } catch (Exception e) {
//             getLogger().log(Level.WARNING, "Failed to stop metrics server gracefully: " + e.getMessage());
//             getLogger().log(Level.FINE, "Failed to stop metrics server gracefully", e);
//         }
//     }
// 
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import de.sldk.mc.MetricsServer;
import de.sldk.mc.PrometheusExporter;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.Counter;
import io.prometheus.client.exporter.common.TextFormat;
import io.restassured.RestAssured;
import org.bukkit.Server;
import org.bukkit.scheduler.BukkitScheduler;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.util.URIUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.concurrent.CompletableFuture;
package de.sldk.mc.exporter;





@ExtendWith(MockitoExtension.class)
public class PrometheusExporterTest {

	@Mock
	private PrometheusExporter exporterMock;
	@Mock
	private Server mockServer;
	@Mock
	private BukkitScheduler mockScheduler;

	private int metricsServerPort;
	private MetricsServer metricsServer;

	@BeforeEach
	void setup() throws Exception {
		CollectorRegistry.defaultRegistry.clear();
		metricsServerPort = getRandomFreePort();
// Path: src/main/java/de/sldk/mc/MetricsServer.java
// public class MetricsServer {
// 
// 	private final String host;
// 	private final int port;
// 	private final PrometheusExporter prometheusExporter;
// 
// 	private Server server;
// 
// 	public MetricsServer(String host, int port, PrometheusExporter prometheusExporter) {
// 		this.host = host;
// 		this.port = port;
// 		this.prometheusExporter = prometheusExporter;
// 	}
// 
// 	public void start() throws Exception {
// 		GzipHandler gzipHandler = new GzipHandler();
// 		gzipHandler.setHandler(new MetricsController(prometheusExporter));
// 
// 		InetSocketAddress address = new InetSocketAddress(host, port);
// 		server = new Server(address);
// 		server.setHandler(gzipHandler);
// 
// 		server.start();
// 	}
// 
// 	public void stop() throws Exception {
// 		if (server == null) {
// 			return;
// 		}
// 
// 		server.stop();
// 	}
// }
// 
// Path: src/main/java/de/sldk/mc/PrometheusExporter.java
// public class PrometheusExporter extends JavaPlugin {
// 
//     private final PrometheusExporterConfig config = new PrometheusExporterConfig(this);
//     private MetricsServer server;
// 
//     @Override
//     public void onEnable() {
// 
//         config.loadDefaultsAndSave();
// 
//         config.enableConfiguredMetrics();
// 
//         startMetricsServer();
//     }
// 
//     private void startMetricsServer() {
//         String host = config.get(PrometheusExporterConfig.HOST);
//         Integer port = config.get(PrometheusExporterConfig.PORT);
// 
// 		server = new MetricsServer(host, port, this);
// 
//         try {
//             server.start();
//             getLogger().info("Started Prometheus metrics endpoint at: " + host + ":" + port);
//         } catch (Exception e) {
//             getLogger().severe("Could not start embedded Jetty server");
//         }
//     }
// 
//     @Override
//     public void onDisable() {
//         try {
//             server.stop();
//         } catch (Exception e) {
//             getLogger().log(Level.WARNING, "Failed to stop metrics server gracefully: " + e.getMessage());
//             getLogger().log(Level.FINE, "Failed to stop metrics server gracefully", e);
//         }
//     }
// 
// }


// Path: src/test/java/de/sldk/mc/exporter/PrometheusExporterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import de.sldk.mc.MetricsServer;
import de.sldk.mc.PrometheusExporter;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.Counter;
import io.prometheus.client.exporter.common.TextFormat;
import io.restassured.RestAssured;
import org.bukkit.Server;
import org.bukkit.scheduler.BukkitScheduler;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.util.URIUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.concurrent.CompletableFuture;

package de.sldk.mc.exporter;





@ExtendWith(MockitoExtension.class)
public class PrometheusExporterTest {

	@Mock
	private PrometheusExporter exporterMock;
	@Mock
	private Server mockServer;
	@Mock
	private BukkitScheduler mockScheduler;

	private int metricsServerPort;
	private MetricsServer metricsServer;

	@BeforeEach
	void setup() throws Exception {
		CollectorRegistry.defaultRegistry.clear();
		metricsServerPort = getRandomFreePort();
		metricsServer = new MetricsServer("localhost", metricsServerPort, exporterMock);