Skip to content

Commit

Permalink
feat(bindings): Kafka 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Apr 29, 2024
1 parent 989f5ee commit bcdce21
Show file tree
Hide file tree
Showing 84 changed files with 1,023 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.asyncapi.bindings.http.HTTPChannelBinding;
import com.asyncapi.bindings.ibmmq.IBMMQChannelBinding;
import com.asyncapi.bindings.jms.JMSChannelBinding;
import com.asyncapi.bindings.kafka.v0._4_0.channel.KafkaChannelBinding;
import com.asyncapi.bindings.kafka.KafkaChannelBinding;
import com.asyncapi.bindings.mercure.MercureChannelBinding;
import com.asyncapi.bindings.mqtt.v0._1_0.channel.MQTTChannelBinding;
import com.asyncapi.bindings.mqtt5.v0._2_0.channel.MQTT5ChannelBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.asyncapi.bindings.http.HTTPMessageBinding;
import com.asyncapi.bindings.ibmmq.IBMMQMessageBinding;
import com.asyncapi.bindings.jms.JMSMessageBinding;
import com.asyncapi.bindings.kafka.v0._4_0.message.KafkaMessageBinding;
import com.asyncapi.bindings.kafka.KafkaMessageBinding;
import com.asyncapi.bindings.mercure.MercureMessageBinding;
import com.asyncapi.bindings.mqtt.v0._1_0.message.MQTTMessageBinding;
import com.asyncapi.bindings.mqtt5.v0._2_0.message.MQTT5MessageBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.asyncapi.bindings.http.HTTPOperationBinding;
import com.asyncapi.bindings.ibmmq.IBMMQOperationBinding;
import com.asyncapi.bindings.jms.JMSOperationBinding;
import com.asyncapi.bindings.kafka.v0._4_0.operation.KafkaOperationBinding;
import com.asyncapi.bindings.kafka.KafkaOperationBinding;
import com.asyncapi.bindings.mercure.MercureOperationBinding;
import com.asyncapi.bindings.mqtt.v0._1_0.operation.MQTTOperationBinding;
import com.asyncapi.bindings.mqtt5.v0._2_0.operation.MQTT5OperationBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.asyncapi.bindings.http.HTTPServerBinding;
import com.asyncapi.bindings.ibmmq.IBMMQServerBinding;
import com.asyncapi.bindings.jms.JMSServerBinding;
import com.asyncapi.bindings.kafka.v0._4_0.server.KafkaServerBinding;
import com.asyncapi.bindings.kafka.KafkaServerBinding;
import com.asyncapi.bindings.mercure.MercureServerBinding;
import com.asyncapi.bindings.mqtt.v0._1_0.server.MQTTServerBinding;
import com.asyncapi.bindings.mqtt5.v0._2_0.server.MQTT5ServerBinding;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.asyncapi.bindings.kafka;

import com.asyncapi.bindings.ChannelBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.EqualsAndHashCode;

/**
* Describes Kafka channel binding.
*
* @version 0.4.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/kafka#channel-binding-object">Kafka channel binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.kafka.v0._4_0.channel.KafkaChannelBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.kafka.v0._4_0.channel.KafkaChannelBinding.class, names = {
"0.4.0",
"latest"
}),
})
@EqualsAndHashCode(callSuper = true)
public class KafkaChannelBinding extends ChannelBinding {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.asyncapi.bindings.kafka;

import com.asyncapi.bindings.MessageBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.EqualsAndHashCode;

/**
* Describes Kafka message binding.
* <p>
* Contains information about the message representation in Kafka.
*
* @version 0.1.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/kafka#message-binding-object">Kafka message binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.kafka.v0._4_0.message.KafkaMessageBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.kafka.v0._4_0.message.KafkaMessageBinding.class, names = {
"0.4.0",
"latest"
}),
})
@EqualsAndHashCode(callSuper = true)
public class KafkaMessageBinding extends MessageBinding {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.asyncapi.bindings.kafka;

import com.asyncapi.bindings.OperationBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.EqualsAndHashCode;

/**
* Describes Kafka operation binding.
* <p>
* Contains information about the operation representation in Kafka.
*
* @version 0.1.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/kafka#operation-binding-object">Kafka operation binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.kafka.v0._4_0.operation.KafkaOperationBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.kafka.v0._4_0.operation.KafkaOperationBinding.class, names = {
"0.4.0",
"latest"
}),
})
@EqualsAndHashCode(callSuper = true)
public class KafkaOperationBinding extends OperationBinding {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.asyncapi.bindings.kafka;

import com.asyncapi.bindings.ServerBinding;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.EqualsAndHashCode;

/**
* Describes Kafka server binding.
*
* @version 0.4.0
* @see <a href="https://github.com/asyncapi/bindings/tree/master/kafka#server-binding-object">Kafka server binding</a>
* @author Pavel Bodiachevskii
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
defaultImpl = com.asyncapi.bindings.kafka.v0._4_0.server.KafkaServerBinding.class,
property = "bindingVersion",
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = com.asyncapi.bindings.kafka.v0._4_0.server.KafkaServerBinding.class, names = {
"0.4.0",
"latest"
}),
})
@EqualsAndHashCode(callSuper = true)
public class KafkaServerBinding extends ServerBinding {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.asyncapi.bindings.kafka.v0._4_0.channel;

import com.asyncapi.bindings.ChannelBinding;
import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand All @@ -20,7 +19,7 @@
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@JsonClassDescription("Describes Kafka channel binding.")
public class KafkaChannelBinding extends ChannelBinding {
public class KafkaChannelBinding extends com.asyncapi.bindings.kafka.KafkaChannelBinding {

/**
* Kafka topic name if different from channel name.
Expand Down Expand Up @@ -66,11 +65,14 @@ public class KafkaChannelBinding extends ChannelBinding {
@JsonPropertyDescription("Topic configuration properties that are relevant for the API.")
private KafkaChannelTopicConfiguration topicConfiguration;

/**
* The version of this binding. If omitted, "latest" MUST be assumed.
*/
@Nullable
@Builder.Default
private String bindingVersion = "0.4.0";
@Override
public String getBindingVersion() {
return "0.4.0";
}

@Override
public void setBindingVersion(@Nullable String bindingVersion) {
super.setBindingVersion("0.4.0");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.asyncapi.bindings.kafka.v0._4_0.message;

import com.asyncapi.bindings.MessageBinding;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand All @@ -21,7 +20,7 @@
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class KafkaMessageBinding extends MessageBinding {
public class KafkaMessageBinding extends com.asyncapi.bindings.kafka.KafkaMessageBinding {

/**
* The message key.
Expand Down Expand Up @@ -55,13 +54,14 @@ public class KafkaMessageBinding extends MessageBinding {
@JsonPropertyDescription("Freeform string for any naming strategy class to use. Clients should default to the vendor default if not supplied.")
private String schemaLookupStrategy;

/**
* The version of this binding. If omitted, "latest" MUST be assumed.
*/
@Nullable
@Builder.Default
@JsonProperty("bindingVersion")
@JsonPropertyDescription("The version of this binding.")
private String bindingVersion = "0.4.0";
@Override
public String getBindingVersion() {
return "0.4.0";
}

@Override
public void setBindingVersion(@Nullable String bindingVersion) {
super.setBindingVersion("0.4.0");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.asyncapi.bindings.kafka.v0._4_0.operation;

import com.asyncapi.bindings.OperationBinding;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand All @@ -21,7 +20,7 @@
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class KafkaOperationBinding extends OperationBinding {
public class KafkaOperationBinding extends com.asyncapi.bindings.kafka.KafkaOperationBinding {

/**
* Id of the consumer group.
Expand All @@ -39,11 +38,14 @@ public class KafkaOperationBinding extends OperationBinding {
@JsonPropertyDescription("Id of the consumer inside a consumer group.")
private AsyncAPISchema clientId;

/**
* The version of this binding. If omitted, "latest" MUST be assumed.
*/
@Nullable
@Builder.Default
private String bindingVersion = "0.4.0";
@Override
public String getBindingVersion() {
return "0.4.0";
}

@Override
public void setBindingVersion(@Nullable String bindingVersion) {
super.setBindingVersion("0.4.0");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.asyncapi.bindings.kafka.v0._4_0.server;

import com.asyncapi.bindings.ServerBinding;
import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand All @@ -20,7 +19,7 @@
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@JsonClassDescription("Describes Kafka server binding.")
public class KafkaServerBinding extends ServerBinding {
public class KafkaServerBinding extends com.asyncapi.bindings.kafka.KafkaServerBinding {

/**
* API URL for the Schema Registry used when producing Kafka messages (if a Schema Registry was used)
Expand All @@ -40,13 +39,14 @@ public class KafkaServerBinding extends ServerBinding {
@JsonPropertyDescription("The vendor of Schema Registry and Kafka serdes library that should be used (e.g. apicurio, confluent, ibm, or karapace)")
private String schemaRegistryVendor;

/**
* The version of this binding.
*/
@Nullable
@Builder.Default
@JsonProperty("bindingVersion")
@JsonPropertyDescription("The version of this binding.")
private String bindingVersion = "0.4.0";
@Override
public String getBindingVersion() {
return "0.4.0";
}

@Override
public void setBindingVersion(@Nullable String bindingVersion) {
super.setBindingVersion("0.4.0");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.asyncapi.bindings.kafka;

import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SuiteDisplayName;

@Suite
@SuiteDisplayName("Kafka")
@SelectPackages("com.asyncapi.bindings.kafka")
public class Kafka {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.asyncapi.bindings.kafka;

import com.asyncapi.bindings.BindingTest;
import com.asyncapi.bindings.kafka.v0._4_0.channel.KafkaChannelBinding;
import com.asyncapi.bindings.kafka.v0._4_0.message.KafkaMessageBinding;
import com.asyncapi.bindings.kafka.v0._4_0.operation.KafkaOperationBinding;
import com.asyncapi.bindings.kafka.v0._4_0.server.KafkaServerBinding;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;

@DisplayName("latest")
public class KafkaLatestTest {

@Nested
@DisplayName("channel")
class ChannelTest extends BindingTest<KafkaChannelBinding> {{
super.binding = KafkaV0_4_0Test.channelBinding();
super.bindingTypeClass = KafkaChannelBinding.class;
super.pathToBindingJson = "/bindings/kafka/latest/channel/binding.json";
super.pathToExtendedBindingJson = "/bindings/kafka/latest/channel/binding - extended.json";
super.pathToWronglyExtendedBindingJson = "/bindings/kafka/latest/channel/binding - wrongly extended.json";
}}

@Nested
@DisplayName("message")
class Message extends BindingTest<KafkaMessageBinding> {{
super.binding = KafkaV0_4_0Test.messageBinding();
super.bindingTypeClass = KafkaMessageBinding.class;
super.pathToBindingJson = "/bindings/kafka/latest/message/binding.json";
super.pathToExtendedBindingJson = "/bindings/kafka/latest/message/binding - extended.json";
super.pathToWronglyExtendedBindingJson = "/bindings/kafka/latest/message/binding - wrongly extended.json";
}}

@Nested
@DisplayName("operation")
class Operation extends BindingTest<KafkaOperationBinding> {{
super.binding = KafkaV0_4_0Test.operationBinding();
super.bindingTypeClass = KafkaOperationBinding.class;
super.pathToBindingJson = "/bindings/kafka/latest/operation/binding.json";
super.pathToExtendedBindingJson = "/bindings/kafka/latest/operation/binding - extended.json";
super.pathToWronglyExtendedBindingJson = "/bindings/kafka/latest/operation/binding - wrongly extended.json";
}}

@Nested
@DisplayName("server")
class Server extends BindingTest<KafkaServerBinding> {{
super.binding = KafkaV0_4_0Test.serverBinding();
super.bindingTypeClass = KafkaServerBinding.class;
super.pathToBindingJson = "/bindings/kafka/latest/server/binding.json";
super.pathToExtendedBindingJson = "/bindings/kafka/latest/server/binding - extended.json";
super.pathToWronglyExtendedBindingJson = "/bindings/kafka/latest/server/binding - wrongly extended.json";
}}

}
Loading

0 comments on commit bcdce21

Please sign in to comment.