@Test
@ExtendWith(TemporaryFolderExtension.class)
void testEnvironmentProperties(TemporaryFolder temporaryFolder) throws URISyntaxException, IOException {

    File testTemplatizedBundlesFolder = new File(temporaryFolder.getRoot(), "templatized-bundles");
    File testDetemplatizedBundlesFolder = new File(temporaryFolder.getRoot(), "detemplatized-bundles");
    File keyStoreFolder = new File(temporaryFolder.getRoot(), "keystore");
    File envFolder = new File(temporaryFolder.getRoot(), "config");
    File privateKeyFolder = new File(envFolder, "privateKeys");
    assertTrue(testDetemplatizedBundlesFolder.mkdirs());
    copyDirectory(new File(Objects.requireNonNull(getClass().getClassLoader().getResource("templatized-bundles")).toURI()), testTemplatizedBundlesFolder);
    ImmutableMap<String, String> environmentProperties = ImmutableMap.<String, String>builder()
            .put(
                    "ENV.IDENTITY_PROVIDER.simple ldap", "{\n" +
                            "    \"type\" : \"BIND_ONLY_LDAP\",\n" +
                            "    \"environmentVariables\": {\n" +
                            "      \"key1\":\"value1\",\n" +
                            "      \"key2\":\"value2\"\n" +
                            "    },\n" +
                            "    \"identityProviderDetail\" : {\n" +
                            "      \"serverUrls\": [\n" +
                            "        \"ldap://host:port\",\n" +
                            "        \"ldap://host:port2\"\n" +
                            "      ],\n" +
                            "      \"useSslClientAuthentication\":false,\n" +
                            "      \"bindPatternPrefix\": \"somePrefix\",\n" +
                            "      \"bindPatternSuffix\": \"someSuffix\"\n" +
                            "    }\n" +
                            "  }")
            .put("ENV.LISTEN_PORT.Custom HTTPS Port", "{\n" +
                    "      \"protocol\" : \"HTTPS\",\n" +
                    "      \"port\" : 12345,\n" +
                    "      \"enabledFeatures\" : [ \"Published service message input\" ],\n" +
                    "      \"tlsSettings\" : {\n" +
                    "        \"clientAuthentication\" : \"REQUIRED\",\n" +
                    "        \"enabledVersions\" : [ \"TLSv1.2\" ],\n" +
                    "        \"enabledCipherSuites\" : [ \"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384\", \"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384\", \"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384\" ],\n" +
                    "        \"environmentVariables\" : {\n" +
                    "          \"usesTLS\" : true\n" +
                    "        }\n" +
                    "      },\n" +
                    "      \"environmentVariables\" : { \n" +
                    "         \"threadPoolSize\" : \"20\"\n" +
                    "      }\n" +
                    "    }")
            .put("ENV.JDBC_CONNECTION.my-jdbc", "{\n" +
                    "    \"driverClass\" : \"com.mysql.jdbc.Driver\",\n" +
                    "    \"jdbcUrl\" : \"jdbc:mysql://localhost:3306/ssg\",\n" +
                    "    \"user\" : \"gateway\",\n" +
                    "    \"passwordRef\" : \"gateway\",\n" +
                    "    \"minimumPoolSize\" : 3,\n" +
                    "    \"maximumPoolSize\" : 15,\n" +
                    "    \"properties\" : {\n" +
                    "      \"EnableCancelTimeout\" : \"true\"\n" +
                    "    }\n" +
                    "  }")
            .put("ENV.CERTIFICATE.my-cert", "{\n" +
                    "      \"verifyHostname\" : false,\n" +
                    "      \"trustedForSsl\" : true,\n" +
                    "      \"trustedAsSamlAttestingEntity\" : false,\n" +
                    "      \"trustAnchor\" : true,\n" +
                    "      \"revocationCheckingEnabled\" : true,\n" +
                    "      \"trustedForSigningClientCerts\" : true,\n" +
                    "      \"trustedForSigningServerCerts\" : true,\n" +
                    "      \"trustedAsSamlIssuer\" : false,\n" +
                    "      \"certificateData\" : {\n" +
                    "           \"issuerName\" : \"my-cert\",\n" +
                    "           \"serialNumber\" : \"123\",\n" +
                    "           \"subjectName\" : \"my-cert\",\n" +
                    "           \"encodedData\" : \"my-cert-data\"\n" +
                    "      }\n" +
                    "  }")
            .put("ENV.PASSWORD.my_password", "my_secret_password")
            .put("ENV.SERVICE_PROPERTY.my-gateway-api.myEnvironmentVariable", "my-service-property-value")
            .put("ENV.CONTEXT_VARIABLE_PROPERTY.anotherEnvVar", "context-variable-value")
            .build();
    new EnvironmentCreatorApplication(
            environmentProperties,
            testTemplatizedBundlesFolder.getPath(),
            testDetemplatizedBundlesFolder.getPath(),
            keyStoreFolder.getPath(),
            privateKeyFolder.getPath(),
            envFolder.getPath()).run();
    assertEnvironment(testDetemplatizedBundlesFolder);
}