From b7bc541cfbd771e4e1293fb332fa0d682d594257 Mon Sep 17 00:00:00 2001
From: Lars Johansson <lars.johansson@ess.eu>
Date: Tue, 11 Oct 2022 09:32:57 +0200
Subject: [PATCH] Added docker integration test for REST API endpoint - report

---
 .../openepics/names/docker/HealthcheckIT.java |  2 +-
 .../org/openepics/names/docker/ReportIT.java  | 64 +++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 src/test/java/org/openepics/names/docker/ReportIT.java

diff --git a/src/test/java/org/openepics/names/docker/HealthcheckIT.java b/src/test/java/org/openepics/names/docker/HealthcheckIT.java
index 0d9efd37..aa1e0554 100644
--- a/src/test/java/org/openepics/names/docker/HealthcheckIT.java
+++ b/src/test/java/org/openepics/names/docker/HealthcheckIT.java
@@ -36,7 +36,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
  * with docker-compose.yml / Dockerfile.
  *
  * <p>
- * Focus of this class is Healthcheck endpoint.
+ * Focus of this class is healthcheck endpoint.
  * In practice, it means means to have Naming and PostgreSQL up and running.
  * </p>
  *
diff --git a/src/test/java/org/openepics/names/docker/ReportIT.java b/src/test/java/org/openepics/names/docker/ReportIT.java
new file mode 100644
index 00000000..cfe35909
--- /dev/null
+++ b/src/test/java/org/openepics/names/docker/ReportIT.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 European Spallation Source ERIC.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+package org.openepics.names.docker;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+
+import org.junit.jupiter.api.Test;
+import org.testcontainers.containers.DockerComposeContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+/**
+ * Integration tests for Naming and PostgreSQL that make use of existing dockerization
+ * with docker-compose.yml / Dockerfile.
+ *
+ * <p>
+ * Focus of this class is report endpoint.
+ * </p>
+ *
+ * @author Lars Johansson
+ */
+@Testcontainers
+class ReportIT {
+
+    @Container
+    public static final DockerComposeContainer<?> ENVIRONMENT =
+        new DockerComposeContainer<>(new File("docker-compose-integrationtest.yml"))
+            .waitingFor(ITUtil.NAMING, Wait.forLogMessage(".*Started NamingApplication.*", 1));
+
+    @Test
+    void readReportAbout() {
+        try {
+            String address = ITUtil.HTTP_IP_PORT_NAMING + "/report/about";
+            int responseCode = ITUtil.doGet(address);
+
+            assertEquals(HttpURLConnection.HTTP_OK, responseCode);
+        } catch (IOException e) {
+            fail();
+        }
+    }
+
+}
-- 
GitLab