From d531aa9d6c4d171f2bce60e735e5a07b0ac1f95d Mon Sep 17 00:00:00 2001 From: Volodymyr Sydorenko <vsydorenko@slb.com> Date: Thu, 1 Aug 2024 18:16:33 +0300 Subject: [PATCH] Refactoring of integration tests (cherry picked from commit 33aeee6e3e96be243975925377ef586de72bd160) --- .../osdu/register/util/HealthCheckTest.java | 64 +++++++++++++++++++ .../util/RetrieveApiTestTemplate.java | 9 --- 2 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/HealthCheckTest.java diff --git a/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/HealthCheckTest.java b/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/HealthCheckTest.java new file mode 100644 index 000000000..e7004e10f --- /dev/null +++ b/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/HealthCheckTest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.register.util; + +import com.sun.jersey.api.client.ClientResponse; +import org.junit.Test; +import org.springframework.http.HttpMethod; + +import static org.junit.Assert.assertEquals; + +public abstract class HealthCheckTest extends BaseTestTemplate { + + public HealthCheckTest(RestDescriptor getDescriptor) { + super(getDescriptor); + } + + private String id = "retrievetest" + System.currentTimeMillis(); + + @Override + protected String getId() { + return id; + } + + @Override + protected void deleteResource() throws Exception { + } + + @Override + protected void deleteResourcewitharg(String ext) throws Exception { + } + + @Override + protected void createResource() throws Exception { + } + @Override + protected void createResourcewitharg(String ext) throws Exception { + } + + @Override + protected int expectedOkResponseCode() { + return 200; + } + + @Test + public void should_returnTrailingOk() throws Exception { + ClientResponse response = + TestUtils.send("api/register/v1/ah/liveness_check/", HttpMethod.GET.name(), this.testUtils.getOpsAccessToken(), "", ""); + assertEquals(expectedOkResponseCode(), response.getStatus()); + } +} diff --git a/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/RetrieveApiTestTemplate.java b/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/RetrieveApiTestTemplate.java index 0f0e3bd6d..fc83aeff7 100644 --- a/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/RetrieveApiTestTemplate.java +++ b/testing/register-test-core/src/main/java/org/opengroup/osdu/register/util/RetrieveApiTestTemplate.java @@ -19,8 +19,6 @@ package org.opengroup.osdu.register.util; import com.sun.jersey.api.client.ClientResponse; import org.junit.Ignore; import org.junit.Test; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; import java.util.ArrayList; import java.util.List; @@ -112,11 +110,4 @@ public abstract class RetrieveApiTestTemplate extends BaseTestTemplate { assertEquals(error("Expected all successful responses. Actual " + sucessResponseCount), 10, sucessResponseCount); assertEquals(error("Unexpected error response returned"), 0, errorResponseCount); } - - @Test - public void should_returnTrailingOk() throws Exception { - ClientResponse response = - TestUtils.send("api/register/v1/ah/liveness_check/", HttpMethod.GET.name(), this.testUtils.getOpsAccessToken(), "", ""); - assertEquals(expectedOkResponseCode(), response.getStatus()); - } } -- GitLab