diff --git a/cwms-data-api/src/test/java/cwms/cda/api/DataApiTestIT.java b/cwms-data-api/src/test/java/cwms/cda/api/DataApiTestIT.java index d6e982e42..f67bbb9eb 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/DataApiTestIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/DataApiTestIT.java @@ -29,6 +29,7 @@ import cwms.cda.data.dto.LocationCategory; import cwms.cda.data.dto.LocationGroup; import fixtures.CwmsDataApiSetupCallback; +import fixtures.IntegrationTestNameGenerator; import fixtures.TestAccounts; import fixtures.users.MockCwmsUserPrincipalImpl; import java.io.File; @@ -64,6 +65,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.extension.ExtendWith; import usace.cwms.db.jooq.codegen.packages.CWMS_ENV_PACKAGE; @@ -71,6 +73,7 @@ * Helper class to manage cycling tests multiple times against a database. * NOTE: Not thread safe, do not run parallel tests. That may be future work though. */ +@DisplayNameGeneration(IntegrationTestNameGenerator.class) @Tag("integration") @ExtendWith(CwmsDataApiSetupCallback.class) public class DataApiTestIT { diff --git a/cwms-data-api/src/test/java/cwms/cda/data/dao/location/kind/TurbineDaoIT.java b/cwms-data-api/src/test/java/cwms/cda/data/dao/location/kind/TurbineDaoIT.java index 90d5fdfc3..3a22c29ec 100644 --- a/cwms-data-api/src/test/java/cwms/cda/data/dao/location/kind/TurbineDaoIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/data/dao/location/kind/TurbineDaoIT.java @@ -207,7 +207,7 @@ void testRename() throws Exception { Turbine retrievedTurbine = turbineDao.retrieveTurbine(newId, office); assertEquals(newId, retrievedTurbine.getLocation().getName()); turbineDao.deleteTurbine(newId, office, DeleteRule.DELETE_ALL); - }); + }, CwmsDataApiSetupCallback.getWebUser()); } @Test @@ -241,8 +241,7 @@ void testTurbineChangesRoundTrip() throws Exception { turbineDao.deleteTurbine(TURBINE_LOC1.getName(), TURBINE_LOC1.getOfficeId(), DeleteRule.DELETE_ALL); turbineDao.deleteTurbine(TURBINE_LOC2.getName(), TURBINE_LOC2.getOfficeId(), DeleteRule.DELETE_ALL); turbineDao.deleteTurbine(TURBINE_LOC3.getName(), TURBINE_LOC3.getOfficeId(), DeleteRule.DELETE_ALL); - }); - + }, CwmsDataApiSetupCallback.getWebUser()); } private static Location buildProjectLocation(String projectId) { diff --git a/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java b/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java index f7e1b940f..2de99eb63 100644 --- a/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java +++ b/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java @@ -43,7 +43,7 @@ public class CwmsDataApiSetupCallback implements BeforeAllCallback,AfterAllCallb private static final String ORACLE_IMAGE = System.getProperty("CDA.oracle.database.image",System.getProperty("RADAR.oracle.database.image", CwmsDatabaseContainer.ORACLE_19C)); private static final String ORACLE_VOLUME = System.getProperty("CDA.oracle.database.volume",System.getProperty("RADAR.oracle.database.volume", "cwmsdb_data_api_volume")); - private static final String CWMS_DB_IMAGE = System.getProperty("CDA.cwms.database.image",System.getProperty("RADAR.cwms.database.image", "registry.hecdev.net/cwms/schema_installer:99.99.99.2-CDA_STAGING")); + static final String CWMS_DB_IMAGE = System.getProperty("CDA.cwms.database.image",System.getProperty("RADAR.cwms.database.image", "registry.hecdev.net/cwms/schema_installer:99.99.99.2-CDA_STAGING")); private static String webUser = null; @@ -91,7 +91,7 @@ public void beforeAll(ExtensionContext context) throws Exception { logger.atInfo().log("Tomcat Listing on " + cdaInstance.getPort()); RestAssured.baseURI=CwmsDataApiSetupCallback.httpUrl(); RestAssured.port = CwmsDataApiSetupCallback.httpPort(); - RestAssured.basePath = "/cwms-data"; + RestAssured.basePath = System.getProperty("warContext"); // we only use doubles RestAssured.config() .jsonConfig( diff --git a/cwms-data-api/src/test/java/fixtures/IntegrationTestNameGenerator.java b/cwms-data-api/src/test/java/fixtures/IntegrationTestNameGenerator.java new file mode 100644 index 000000000..6b2048559 --- /dev/null +++ b/cwms-data-api/src/test/java/fixtures/IntegrationTestNameGenerator.java @@ -0,0 +1,53 @@ +/* + * MIT License + * + * Copyright (c) 2024 Hydrologic Engineering Center + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package fixtures; + +import java.lang.reflect.Method; +import org.junit.jupiter.api.DisplayNameGenerator; + +public final class IntegrationTestNameGenerator implements DisplayNameGenerator { + private static String schemaVersion; + + static { + // Fetch the schema version from a system property + String[] split = CwmsDataApiSetupCallback.CWMS_DB_IMAGE.split(":"); + schemaVersion = split[split.length - 1]; + } + + @Override + public String generateDisplayNameForClass(Class testClass) { + return testClass.getSimpleName() + " (schema: " + schemaVersion + ")"; + } + + @Override + public String generateDisplayNameForNestedClass(Class nestedClass) { + return nestedClass.getSimpleName() + " (schema: " + schemaVersion + ")"; + } + + @Override + public String generateDisplayNameForMethod(Class testClass, Method testMethod) { + return testClass.getSimpleName() + "." + testMethod.getName() + " (schema: " + schemaVersion + ")"; + } +}