From 6e12df7ba8edc93654382d73bf6f9cdd20b594e7 Mon Sep 17 00:00:00 2001 From: rmueller Date: Tue, 2 Apr 2024 11:25:33 +0200 Subject: [PATCH] delete useless tests --- .../tests/AdminControllerIT.java | 75 +------------------ 1 file changed, 3 insertions(+), 72 deletions(-) diff --git a/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java b/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java index fa0b5b2b..5cd08724 100644 --- a/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java +++ b/src/test/java/org/highmed/numportal/integrationtesting/tests/AdminControllerIT.java @@ -3,20 +3,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; import lombok.SneakyThrows; -import org.apache.commons.io.IOUtils; import org.highmed.numportal.integrationtesting.security.WithMockNumUser; +import org.highmed.numportal.service.SetupHealthiness; import org.junit.Assert; import org.junit.Test; import org.mockito.Mock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultMatcher; -import org.highmed.numportal.service.SetupHealthiness; -import java.nio.charset.StandardCharsets; - -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static org.highmed.numportal.domain.model.Roles.*; import static org.mockito.Mockito.when; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; @@ -109,59 +106,6 @@ public void shouldGetExternalUrlsSuccessfully() throws Exception { .andExpect(jsonPath("$.userManualUrl.EN").value("user-manual-en")); } - @Test - public void shouldGetServicesStatus() throws Exception { - stubFor( - WireMock.get("/health-url") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/NUM-Codex-Status.html"), - StandardCharsets.UTF_8)))); - stubFor( - WireMock.get("/statusCake?PublicID=Lmw50IEZ6s") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/statusCakeResponse.json"), - StandardCharsets.UTF_8)))); - //testSuccess("/admin/services-status", status().isOk());//PREPROD - testSuccess("/admin/services-status?setup=PROD", status().isServiceUnavailable()); - testFail("/admin/services-status?setup=STAGING", status().isServiceUnavailable()); - testFail("/admin/services-status?setup=DEV", status().isServiceUnavailable()); - } - - @Test - public void shouldGetAnnouncement() throws Exception { - stubFor( - WireMock.get("/health-url") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/NUM-Codex-Status.html"), - StandardCharsets.UTF_8)))); - stubFor( - WireMock.get("/statusCake?PublicID=Lmw50IEZ6s") - .willReturn(okTextXml(IOUtils.toString(getClass().getResourceAsStream("/health-check/statusCakeResponseWithAnnouncements.json"), - StandardCharsets.UTF_8)))); - mockMvc - .perform( - get("/admin/services-status?setup=PROD") - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isServiceUnavailable()) - .andExpect(jsonPath("NUM").value("")) - .andExpect(jsonPath("EHRBASE").isNotEmpty()) - .andExpect(jsonPath("FHIR_BRIDGE").value("")) - .andExpect(jsonPath("CHECK_FOR_ANNOUNCEMENTS").value("Please visit health.num-codex.de page for announcement. Date/Time - [13:30] Description - [Testing]")) - .andExpect(jsonPath("FE").value("")) - .andExpect(jsonPath("KEYCLOAK").value("")); - } - - private void testSuccess(String url, ResultMatcher status) throws Exception { - mockMvc - .perform( - get(url) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status) - .andExpect(jsonPath("NUM").value("")) - .andExpect(jsonPath("EHRBASE").isNotEmpty()) - .andExpect(jsonPath("FHIR_BRIDGE").value("")) - .andExpect(jsonPath("FE").value("")) - .andExpect(jsonPath("KEYCLOAK").value("")); - } @Test public void testException() { @@ -175,17 +119,4 @@ public void testException() { } } - private void testFail(String url, ResultMatcher status) throws Exception { - mockMvc - .perform( - get(url) - .with(csrf()) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status) - .andExpect(jsonPath("NUM").isNotEmpty()) - .andExpect(jsonPath("EHRBASE").isNotEmpty()) - .andExpect(jsonPath("FHIR_BRIDGE").isNotEmpty()) - .andExpect(jsonPath("FE").isNotEmpty()) - .andExpect(jsonPath("KEYCLOAK").isNotEmpty()); - } }