GatewayHttpConfig implements HttpConfig { public static GatewayHttpConfig of(final Config config) { final DefaultHttpConfig basicHttpConfig = DefaultHttpConfig.of(config); return new GatewayHttpConfig(basicHttpConfig, ConfigWithFallback.newInstance(config, basicHttpConfig.getConfigPath(), GatewayHttpConfigValue.values())); } private  GatewayHttpConfig(final DefaultHttpConfig basicHttpConfig, final ScopedConfig scopedConfig); static GatewayHttpConfig of(final Config config); @Override String getHostname(); @Override int getPort(); @Override Duration getCoordinatedShutdownTimeout(); @Override Set<JsonSchemaVersion> getSupportedSchemaVersions(); @Override boolean isForceHttps(); @Override boolean isRedirectToHttps(); @Override Pattern getRedirectToHttpsBlocklistPattern(); @Override boolean isEnableCors(); @Override Duration getRequestTimeout(); @Override String getActorPropsFactoryFullQualifiedClassname(); @Override Set<HeaderDefinition> getQueryParametersAsHeaders(); @Override Set<String> getAdditionalAcceptedMediaTypes(); @SuppressWarnings("OverlyComplexMethod") @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void tryToGetInstanceWithUnknownSchemaVersions() { final int unknownVersionNumber = -1; final Collection<Integer> knownSchemaVersions = List.of(JsonSchemaVersion.V_1.toInt(), JsonSchemaVersion.V_2.toInt()); final Collection<Integer> allSchemaVersions = new ArrayList<>(knownSchemaVersions); allSchemaVersions.add(unknownVersionNumber); final String configPath = "http." + HttpConfig.GatewayHttpConfigValue.SCHEMA_VERSIONS.getConfigPath(); final Config config = ConfigFactory.parseMap(Maps.newHashMap(configPath, allSchemaVersions)); assertThatExceptionOfType(DittoConfigError.class) .isThrownBy(() -> GatewayHttpConfig.of(config)) .withMessage("Schema version <%s> is not supported!", unknownVersionNumber) .withNoCause(); }
@Test public void tryToGetInstanceWithUnknownQueryParametersAsHeaders() { final List<String> unknownHeaderKeys = Lists.newArrayList("foo", "bar"); final List<String> knownHeaderKeys = Lists.newArrayList(DittoHeaderDefinition.CORRELATION_ID.getKey(), DittoHeaderDefinition.RESPONSE_REQUIRED.getKey()); final List<String> allHeaderKeys = new ArrayList<>(knownHeaderKeys); allHeaderKeys.addAll(unknownHeaderKeys); final String configPath = "http." + HttpConfig.GatewayHttpConfigValue.QUERY_PARAMS_AS_HEADERS.getConfigPath(); final Config config = ConfigFactory.parseMap(Maps.newHashMap(configPath, allHeaderKeys)); assertThatExceptionOfType(DittoConfigError.class) .isThrownBy(() -> GatewayHttpConfig.of(config)) .withMessage("The query parameter names <%s> do not denote known header keys!", unknownHeaderKeys) .withNoCause(); }