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(); } 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..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,7 +24,6 @@ public enum EnvironmentType { public static EnvironmentType getEnum(@NotNull String env) { EnvironmentType envEnum; - switch (env.toLowerCase()) { case "qa": envEnum = EnvironmentType.QUALITY_ASSURANCE; @@ -41,7 +40,7 @@ public static EnvironmentType getEnum(@NotNull String env) { case "reg": envEnum = EnvironmentType.REGRESSION; break; - case "pre": + case "prep": envEnum = EnvironmentType.PREPRODUCTION; break; case "prod": @@ -57,14 +56,13 @@ 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; - switch (env) { case QUALITY_ASSURANCE: name = "qa"; @@ -85,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"; @@ -101,11 +99,12 @@ 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; } + @Override public final String toString() { return this.name; diff --git a/src/test/java/URLTest.java b/src/test/java/URLTest.java index e7e5a5c..c99af59 100644 --- a/src/test/java/URLTest.java +++ b/src/test/java/URLTest.java @@ -68,7 +68,7 @@ public void createInternalIntegrationDomain() throws MalformedURLException { @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); @@ -76,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); @@ -162,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");