forked from eclipse-ditto/ditto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse-ditto#903]: Make schema optional, allow alternate content type
This change allows to make the schema optional and also allows to configure the data content type. Signed-off-by: Jens Reimann <[email protected]>
- Loading branch information
Showing
11 changed files
with
274 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...java/org/eclipse/ditto/services/gateway/endpoints/routes/cloudevents/CloudEventsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.ditto.services.gateway.endpoints.routes.cloudevents; | ||
|
||
import org.eclipse.ditto.services.gateway.endpoints.EndpointTestBase; | ||
import org.eclipse.ditto.services.gateway.util.config.endpoints.CloudEventsConfig; | ||
import org.junit.Test; | ||
|
||
import java.util.Set; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public final class CloudEventsTest extends EndpointTestBase { | ||
|
||
@Test | ||
public void testDefaults() { | ||
final Object defaultValue = CloudEventsConfig.CloudEventsConfigValue.DATA_TYPES.getDefaultValue(); | ||
assertThat(defaultValue).isEqualTo(Set.of("application/json", "application/vnd.eclipse.ditto+json")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...main/java/org/eclipse/ditto/services/gateway/util/config/endpoints/CloudEventsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2020 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.services.gateway.util.config.endpoints; | ||
|
||
import java.util.Set; | ||
|
||
import javax.annotation.concurrent.Immutable; | ||
|
||
import akka.http.javadsl.model.MediaTypes; | ||
import org.eclipse.ditto.model.base.common.DittoConstants; | ||
import org.eclipse.ditto.services.utils.config.KnownConfigValue; | ||
|
||
import static org.eclipse.ditto.model.base.common.DittoConstants.DITTO_PROTOCOL_CONTENT_TYPE; | ||
|
||
/** | ||
* Provides configuration settings for the cloud events endpoint of the Ditto Gateway service. | ||
*/ | ||
@Immutable | ||
public interface CloudEventsConfig { | ||
|
||
/** | ||
* Returns if an empty data schema is allowed. | ||
* | ||
* @return {@code true} if an empty data schema is allowed {@code false} otherwise. | ||
*/ | ||
boolean isEmptySchemaAllowed(); | ||
|
||
/** | ||
* Returns the allowed data types. | ||
* | ||
* @return The set of allowed data types. | ||
*/ | ||
Set<String> getDataTypes(); | ||
|
||
/** | ||
* An enumeration of the known config path expressions and their associated default values for | ||
* {@code CloudEventsConfig}. | ||
*/ | ||
enum CloudEventsConfigValue implements KnownConfigValue { | ||
|
||
/** | ||
* Flag if an empty data schema is allowed. | ||
*/ | ||
EMPTY_SCHEMA_ALLOWED("empty-schema-allowed", true), | ||
|
||
/** | ||
* Set of allowed data types | ||
*/ | ||
DATA_TYPES("data-types", Set.of(MediaTypes.APPLICATION_JSON.toString(), DittoConstants.DITTO_PROTOCOL_CONTENT_TYPE)); | ||
|
||
private final String path; | ||
private final Object defaultValue; | ||
|
||
private CloudEventsConfigValue(final String thePath, final Object theDefaultValue) { | ||
path = thePath; | ||
defaultValue = theDefaultValue; | ||
} | ||
|
||
@Override | ||
public Object getDefaultValue() { | ||
return defaultValue; | ||
} | ||
|
||
@Override | ||
public String getConfigPath() { | ||
return path; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.