From 4fb0265ce65db5fcfc873ed951de962d68bd9af5 Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Wed, 22 May 2024 12:11:11 +0100 Subject: [PATCH 1/4] feat:added new envs for containers work --- .../dvsa/testing/lib/url/utils/EnvironmentType.java | 10 ++++------ src/test/java/URLTest.java | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java b/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java index add9ca1..ae9625f 100644 --- a/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java +++ b/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java @@ -27,6 +27,7 @@ public static EnvironmentType getEnum(@NotNull String env) { switch (env.toLowerCase()) { case "qa": + case "int": envEnum = EnvironmentType.QUALITY_ASSURANCE; break; case "dev": @@ -35,13 +36,11 @@ public static EnvironmentType getEnum(@NotNull String env) { case "da": envEnum = EnvironmentType.DAILY_ASSURANCE; break; - case "int": - envEnum = EnvironmentType.INTEGRATION; - break; case "reg": envEnum = EnvironmentType.REGRESSION; break; case "pre": + case "prep": envEnum = EnvironmentType.PREPRODUCTION; break; case "prod": @@ -57,11 +56,10 @@ public static EnvironmentType getEnum(@NotNull String env) { envEnum = EnvironmentType.LOCAL; break; default: - throw new IllegalArgumentException(String.format("[ERROR] %s does not match up to any environment")); + throw new IllegalArgumentException(String.format("[ERROR] %s does not match up to any environment", env)); } return envEnum; } - public static String name(@NotNull ApplicationType appType, @NotNull EnvironmentType env) { String name; @@ -101,7 +99,7 @@ public static String name(@NotNull ApplicationType appType, @NotNull Environment } break; default: - throw new IllegalArgumentException(String.format("unable to handle application type of %s and/or environment of type %s.", appType, env)); + throw new IllegalArgumentException(String.format("unable to handle application type of %s and/or environment of type %s. ", appType, env)); } return name; diff --git a/src/test/java/URLTest.java b/src/test/java/URLTest.java index e7e5a5c..a3c879d 100644 --- a/src/test/java/URLTest.java +++ b/src/test/java/URLTest.java @@ -52,17 +52,15 @@ public void createInternalDailyAssuranceDomain() throws MalformedURLException { @Test public void createExternalIntegrationDomain() throws MalformedURLException { - java.net.URL actualDomain = new java.net.URL("https://ssweb.int.olcs.dvsacloud.uk/"); - java.net.URL expectedDomain = URL.build(ApplicationType.EXTERNAL, EnvironmentType.INTEGRATION); - + java.net.URL actualDomain = new java.net.URL("https://ssweb.qa.olcs.dev-dvsacloud.uk/"); + java.net.URL expectedDomain = URL.build(ApplicationType.EXTERNAL, EnvironmentType.QUALITY_ASSURANCE); assertEquals(expectedDomain, actualDomain); } @Test public void createInternalIntegrationDomain() throws MalformedURLException { - java.net.URL actualDomain = new java.net.URL("https://iuweb.int.olcs.dvsacloud.uk/"); - java.net.URL expectedDomain = URL.build(ApplicationType.INTERNAL, EnvironmentType.INTEGRATION); - + java.net.URL actualDomain = new java.net.URL("https://iuweb.qa.olcs.dev-dvsacloud.uk/"); + java.net.URL expectedDomain = URL.build(ApplicationType.INTERNAL, EnvironmentType.QUALITY_ASSURANCE); assertEquals(expectedDomain, actualDomain); } From 1be1faeae9067890d588bdf3ccdc3330ded299e4 Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Wed, 10 Jul 2024 17:23:17 +0100 Subject: [PATCH 2/4] chore: update possible api url for prod --- src/main/java/org/dvsa/testing/lib/url/api/URL.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/dvsa/testing/lib/url/api/URL.java b/src/main/java/org/dvsa/testing/lib/url/api/URL.java index 8330bcc..1fb47e7 100644 --- a/src/main/java/org/dvsa/testing/lib/url/api/URL.java +++ b/src/main/java/org/dvsa/testing/lib/url/api/URL.java @@ -7,11 +7,14 @@ public class URL extends URLBase { public static java.net.URL build(@NotNull String scheme, @NotNull EnvironmentType environment, @NotNull String path) { - // TODO: find out how prod url looks and incorporate findings if (environment == EnvironmentType.LOCAL) { - setURL(String.format("%s://olcs-backend/api/%s",scheme, path)); + setURL(String.format("%s://olcs-backend/api/%s", scheme, path)); } else { - setURL(String.format("%s://api.%s.olcs.dev-dvsacloud.uk/api/%s", scheme, environment, path)); + String baseUrl = String.format("%s://api.%s.olcs.dev-dvsacloud.uk/api/%s", scheme, environment, path); + if (environment == EnvironmentType.PRODUCTION) { + baseUrl = baseUrl.replace(".dev-", "."); + } + setURL(baseUrl); } return getURL(); } From 690e6a444986ad72077ec2b1f3b2af494da209f0 Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Wed, 23 Oct 2024 10:47:19 +0100 Subject: [PATCH 3/4] chore: prep --- .../dvsa/testing/lib/url/utils/EnvironmentType.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java b/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java index ae9625f..a2742b9 100644 --- a/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java +++ b/src/main/java/org/dvsa/testing/lib/url/utils/EnvironmentType.java @@ -12,7 +12,7 @@ public enum EnvironmentType { DEVELOP("dev"), REGRESSION("reg"), INTEGRATION("int"), - PREPRODUCTION("pre"), + PREPRODUCTION("prep"), PRODUCTION("prod"), LOCAL("local"); @@ -24,10 +24,8 @@ public enum EnvironmentType { public static EnvironmentType getEnum(@NotNull String env) { EnvironmentType envEnum; - switch (env.toLowerCase()) { case "qa": - case "int": envEnum = EnvironmentType.QUALITY_ASSURANCE; break; case "dev": @@ -36,10 +34,12 @@ public static EnvironmentType getEnum(@NotNull String env) { case "da": envEnum = EnvironmentType.DAILY_ASSURANCE; break; + case "int": + envEnum = EnvironmentType.INTEGRATION; + break; case "reg": envEnum = EnvironmentType.REGRESSION; break; - case "pre": case "prep": envEnum = EnvironmentType.PREPRODUCTION; break; @@ -60,9 +60,9 @@ public static EnvironmentType getEnum(@NotNull String env) { } return envEnum; } + public static String name(@NotNull ApplicationType appType, @NotNull EnvironmentType env) { String name; - switch (env) { case QUALITY_ASSURANCE: name = "qa"; @@ -83,7 +83,7 @@ public static String name(@NotNull ApplicationType appType, @NotNull Environment name = "prodsupp"; break; case PREPRODUCTION: - name = "pre"; + name = "prep"; break; case DEMO: name = "demo"; @@ -104,6 +104,7 @@ public static String name(@NotNull ApplicationType appType, @NotNull Environment return name; } + @Override public final String toString() { return this.name; From 77096c0f92ba78527d802ed02e3a765a5da5d74a Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Wed, 23 Oct 2024 10:52:44 +0100 Subject: [PATCH 4/4] chore: tests --- src/test/java/URLTest.java | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/test/java/URLTest.java b/src/test/java/URLTest.java index a3c879d..c99af59 100644 --- a/src/test/java/URLTest.java +++ b/src/test/java/URLTest.java @@ -52,21 +52,23 @@ public void createInternalDailyAssuranceDomain() throws MalformedURLException { @Test public void createExternalIntegrationDomain() throws MalformedURLException { - java.net.URL actualDomain = new java.net.URL("https://ssweb.qa.olcs.dev-dvsacloud.uk/"); - java.net.URL expectedDomain = URL.build(ApplicationType.EXTERNAL, EnvironmentType.QUALITY_ASSURANCE); + java.net.URL actualDomain = new java.net.URL("https://ssweb.int.olcs.dvsacloud.uk/"); + java.net.URL expectedDomain = URL.build(ApplicationType.EXTERNAL, EnvironmentType.INTEGRATION); + assertEquals(expectedDomain, actualDomain); } @Test public void createInternalIntegrationDomain() throws MalformedURLException { - java.net.URL actualDomain = new java.net.URL("https://iuweb.qa.olcs.dev-dvsacloud.uk/"); - java.net.URL expectedDomain = URL.build(ApplicationType.INTERNAL, EnvironmentType.QUALITY_ASSURANCE); + java.net.URL actualDomain = new java.net.URL("https://iuweb.int.olcs.dvsacloud.uk/"); + java.net.URL expectedDomain = URL.build(ApplicationType.INTERNAL, EnvironmentType.INTEGRATION); + assertEquals(expectedDomain, actualDomain); } @Test public void createExternalPreProductionDomain() throws MalformedURLException { - java.net.URL actualDomain = new java.net.URL("https://ssweb.pre.olcs.dvsacloud.uk/"); + java.net.URL actualDomain = new java.net.URL("https://ssweb.prep.olcs.dvsacloud.uk/"); java.net.URL expectedDomain = URL.build(ApplicationType.EXTERNAL, EnvironmentType.PREPRODUCTION); assertEquals(expectedDomain, actualDomain); @@ -74,7 +76,7 @@ public void createExternalPreProductionDomain() throws MalformedURLException { @Test public void createInternalPreProductionDomain() throws MalformedURLException { - java.net.URL actualDomain = new java.net.URL("https://iuweb.pre.olcs.dvsacloud.uk/"); + java.net.URL actualDomain = new java.net.URL("https://iuweb.prep.olcs.dvsacloud.uk/"); java.net.URL expectedDomain = URL.build(ApplicationType.INTERNAL, EnvironmentType.PREPRODUCTION); assertEquals(expectedDomain, actualDomain); @@ -160,6 +162,22 @@ public void createInternalRegressionDomain() throws MalformedURLException { assertEquals(expectedDomain, actualDomain); } + @Test + public void createExternalDemoDomain() throws MalformedURLException { + java.net.URL actualDomain = new java.net.URL("https://ssweb.demo.olcs.dev-dvsacloud.uk/"); + java.net.URL expectedDomain = URL.build(ApplicationType.EXTERNAL, EnvironmentType.DEMO); + + assertEquals(expectedDomain, actualDomain); + } + + @Test + public void createInternalDemoDomain() throws MalformedURLException { + java.net.URL actualDomain = new java.net.URL("https://iuweb.demo.olcs.dev-dvsacloud.uk/"); + java.net.URL expectedDomain = URL.build(ApplicationType.INTERNAL, EnvironmentType.DEMO); + + assertEquals(expectedDomain, actualDomain); + } + @Test public void updatesTheURLPath() throws MalformedURLException { URL.build(ApplicationType.EXTERNAL, EnvironmentType.PRODUCTION, "register");