package de.digitalcollections.blueprints.rest.integration.tests;

import de.digitalcollections.blueprints.rest.client.HelloClient;
import de.digitalcollections.blueprints.rest.common.model.impl.Greeting;
import feign.Feign;
import feign.gson.GsonDecoder;
import java.io.File;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.from;

@Testcontainers
public class HelloClientTest {

  private static final String DOCKER_COMPOSE_FILE = "src/test/resources/docker-compose.yml";

  private static final String REST_SERVICE_NAME = "rest_1";

  private static final int REST_SERVICE_PORT = 9000;

//  //@ExtendWith(SpringExtension.class)
  @Container
  public static final DockerComposeContainer ENVIRONMENT = new DockerComposeContainer(new File(DOCKER_COMPOSE_FILE))
      .withLocalCompose(true)
      .withExposedService(REST_SERVICE_NAME, REST_SERVICE_PORT)
      .withTailChildContainers(true); // append all outputs of applications in the container to the main log

  @Test
  public void greetingShouldReturnGreetingForTheExpectedName() {
    final String targetUrl = String.format("http://%s:%d",
        ENVIRONMENT.getServiceHost(REST_SERVICE_NAME, REST_SERVICE_PORT),
        ENVIRONMENT.getServicePort(REST_SERVICE_NAME, REST_SERVICE_PORT));

    final HelloClient client = Feign.builder()
        .decoder(new GsonDecoder())
        .target(HelloClient.class, targetUrl);

    assertThat(client.greeting("Captain")).returns("Hello, Captain!", from(Greeting::getContent));
  }
}

@@ -252,29 +252,8 @@
 er;%0A
-import java.io.File;%0A
 impo
@@ -287,177 +287,8 @@
 st;%0A
-import org.testcontainers.containers.DockerComposeContainer;%0Aimport org.testcontainers.junit.jupiter.Container;%0Aimport org.testcontainers.junit.jupiter.Testcontainers;%0A%0A
 %0Aimp
@@ -399,24 +399,8 @@
 m;%0A%0A
-@Testcontainers%0A
 publ
@@ -433,662 +433,209 @@
 %0A%0A  
-private static final String DOCKER_COMPOSE_FILE = %22src/test/resources/docker-compose.yml%22;%0A%0A  private static final String REST_SERVICE_NAME = %22rest_1%22;%0A%0A  private static final int REST_SERVICE_PORT = 9000;%0A%0A//  //@ExtendWith(SpringExtension.class)%0A  @Container%0A  public static final DockerComposeContainer ENVIRONMENT = new DockerComposeContainer(new File(DOCKER_COMPOSE_FILE))%0A      .withLocalCompose(true)%0A      .withExposedService(REST_SERVICE_NAME, REST_SERVICE_PORT)%0A      .withTailChildContainers(true); // append all outputs of applications in the container to the main log%0A%0A  @Test%0A  public void greetingShouldReturnGreetingForTheExpectedName() %7B
+@Test%0A  public void greetingShouldReturnGreetingForTheExpectedName() %7B%0A    final String host = getEnvOrDefault(%22REST_HOST%22, %22localhost%22);%0A    final String port = getEnvOrDefault(%22REST_PORT%22, %2232790%22);%0A
 %0A   
@@ -690,391 +690,516 @@
 %25s:%25
-d%22,%0A        ENVIRONMENT.getServiceHost(REST_SERVICE_NAME, REST_SERVICE_PORT),%0A        ENVIRONMENT.getServicePort(REST_SERVICE_NAME, REST_SERVICE_PORT));%0A%0A    final HelloClient client = Feign.builder()%0A        .decoder(new GsonDecoder())%0A        .target(HelloClient.class, targetUrl);%0A%0A    assertThat(client.greeting(%22Captain%22)).returns(%22Hello, Captain!%22, from(Greeting::getContent));
+s%22, host, port);%0A%0A    final HelloClient client = Feign.builder()%0A                                    .decoder(new GsonDecoder())%0A                                    .target(HelloClient.class, targetUrl);%0A%0A    assertThat(client.greeting(%22Captain%22)).returns(%22Hello, Captain!%22, from(Greeting::getContent));%0A  %7D%0A%0A  private String getEnvOrDefault(String name, String defaultValue) %7B%0A    String value = System.getenv(name);%0A    if (value == null) %7B%0A      return defaultValue;%0A    %7D else %7B%0A      return value;%0A    %7D
 %0A  %7D

remove testcontainers integration and replace it with a more naive and simple one