Skip to content

Commit e1ebb67

Browse files
authored
Merge pull request #34 from virtualansoftware/compare
KAFKA and JDBC cucumblan official delivery
2 parents ae324bb + d6dce75 commit e1ebb67

File tree

12 files changed

+492
-347
lines changed

12 files changed

+492
-347
lines changed

modules/cucumblan-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<artifactId>cucumblan-api</artifactId>
55
<packaging>jar</packaging>
66
<name>cucumblan-api</name>
7-
<version>1.1.7-SNAPSHOT</version>
7+
<version>1.1.9-SNAPSHOT</version>
88
<properties>
99
<mapson.version>1.1.4</mapson.version>
1010
<cucumber.version>6.7.0</cucumber.version>

modules/cucumblan-api/src/main/java/io/virtualan/cucumblan/core/BaseStepDefinition.java

+437-327
Large diffs are not rendered by default.

modules/cucumblan-db/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<artifactId>cucumblan-db</artifactId>
55
<packaging>jar</packaging>
66
<name>cucumblan-db</name>
7-
<version>0.0.2-SNAPSHOT</version>
7+
<version>0.1.1-SNAPSHOT</version>
88
<properties>
99
<junit.version>5.5.2</junit.version>
1010
<mapson.version>1.1.4</mapson.version>

modules/cucumblan-message/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.virtualan</groupId>
44
<artifactId>cucumblan-message</artifactId>
5-
<version>0.0.2-SNAPSHOT</version>
5+
<version>0.1.1-SNAPSHOT</version>
66
<packaging>jar</packaging>
77
<name>cucumblan-message</name>
88
<properties>

modules/cucumblan-message/src/main/java/io/virtualan/cucumblan/core/MsgBaseStepDefinition.java

+24-10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void before(Scenario scenario) {
7474
* @param resource the resource
7575
* @param type the type
7676
* @param messages the messages
77+
* @throws MessageNotDefinedException the message not defined exception
7778
*/
7879
@Given("send message event (.*) in partition (.*) on (.*) with type (.*)$")
7980
public void produceMessageWithPartition(String eventName, Integer partition, String resource,
@@ -85,13 +86,19 @@ public void produceMessageWithPartition(String eventName, Integer partition, Str
8586
scenario.log(builtMessage.toString());
8687

8788
KafkaProducerClient
88-
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
89+
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
8990
partition, builtMessage.getHeaders());
9091
} else {
9192
Assertions.assertTrue(false, eventName + " is not configured for any topic. or " + type +" is not configured");
9293
}
9394
}
9495

96+
/**
97+
* Produce message.
98+
*
99+
* @param sleep the sleep
100+
* @throws InterruptedException the interrupted exception
101+
*/
95102
@Given("pause message process for (.*) milliseconds$")
96103
public void produceMessage(long sleep) throws InterruptedException {
97104
Thread.sleep(sleep);
@@ -104,6 +111,7 @@ public void produceMessage(long sleep) throws InterruptedException {
104111
* @param resource the resource
105112
* @param type the type
106113
* @param messages the messages
114+
* @throws MessageNotDefinedException the message not defined exception
107115
*/
108116
@Given("send message event (.*) on (.*) with type (.*)$")
109117
public void produceMessage(String eventName, String resource, String type,
@@ -113,9 +121,9 @@ public void produceMessage(String eventName, String resource, String type,
113121
if (topic != null && messageType != null) {
114122
MessageType builtMessage = messageType.buildProducerMessage(messages);
115123
scenario.log(builtMessage.toString());
116-
if (builtMessage.getId() != null) {
124+
if (builtMessage.getKey() != null) {
117125
KafkaProducerClient
118-
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
126+
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
119127
null, builtMessage.getHeaders());
120128
} else {
121129
KafkaProducerClient
@@ -134,6 +142,7 @@ public void produceMessage(String eventName, String resource, String type,
134142
* @param resource the resource
135143
* @param type the type
136144
* @param messages the messages
145+
* @throws MessageNotDefinedException the message not defined exception
137146
*/
138147
@Given("send inline message event (.*) on (.*) with type (.*)$")
139148
public void produceMessage(String eventName, String resource, String type,
@@ -143,9 +152,9 @@ public void produceMessage(String eventName, String resource, String type,
143152
if (topic != null && messageType != null) {
144153
MessageType builtMessage = messageType.buildProducerMessage(messages);
145154
scenario.log(builtMessage.toString());
146-
if (builtMessage.getId() != null) {
155+
if (builtMessage.getKey() != null) {
147156
KafkaProducerClient
148-
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
157+
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
149158
null, builtMessage.getHeaders());
150159
} else {
151160
KafkaProducerClient
@@ -164,6 +173,7 @@ public void produceMessage(String eventName, String resource, String type,
164173
* @param resource the resource
165174
* @param type the type
166175
* @param messages the messages
176+
* @throws MessageNotDefinedException the message not defined exception
167177
*/
168178
@Given("send mapson message event (.*) on (.*) with type (.*)$")
169179
public void produceMessageMapson(String eventName, String resource, String type,
@@ -173,9 +183,9 @@ public void produceMessageMapson(String eventName, String resource, String type,
173183
if (topic != null && messageType != null) {
174184
MessageType builtMessage = messageType.buildProducerMessage(messages);
175185
scenario.log(builtMessage.toString());
176-
if (builtMessage.getId() != null) {
186+
if (builtMessage.getKey() != null) {
177187
KafkaProducerClient
178-
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
188+
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
179189
null, builtMessage.getHeaders());
180190
} else {
181191
KafkaProducerClient
@@ -195,9 +205,11 @@ public void produceMessageMapson(String eventName, String resource, String type,
195205
* @param eventName the event name
196206
* @param id the id
197207
* @param resource the resource
208+
* @param type the type
198209
* @param csvson the csvson
199-
* @throws InterruptedException the interrupted exception
200-
* @throws BadInputDataException bad input data exception
210+
* @throws InterruptedException the interrupted exception
211+
* @throws BadInputDataException bad input data exception
212+
* @throws MessageNotDefinedException the message not defined exception
201213
*/
202214
@Given("verify (.*) contains (.*) on (.*) with type (.*)$")
203215
public void verifyConsumedJSONObject(String eventName, String id, String resource, String type,
@@ -228,8 +240,10 @@ public void verifyConsumedJSONObject(String eventName, String id, String resourc
228240
* @param eventName the event name
229241
* @param id the id
230242
* @param resource the resource
243+
* @param type the type
231244
* @param keyValue the key value
232-
* @throws InterruptedException interrupted exception
245+
* @throws InterruptedException interrupted exception
246+
* @throws MessageNotDefinedException the message not defined exception
233247
*/
234248
@Given("verify-by-elements (.*) contains (.*) on (.*) with type (.*)$")
235249
public void consumeMessage(String eventName, String id, String resource, String type,

modules/cucumblan-message/src/main/java/io/virtualan/cucumblan/core/msg/kafka/KafkaConsumerClient.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ private boolean getMessageType(String eventName, String type,
151151
if (messageType != null) {
152152
try {
153153
obj = messageType.buildConsumerMessage(record, record.key(), record.value());
154-
if (obj != null) {
155-
MessageContext.setEventContextMap(eventName, String.valueOf(obj.getId()), obj);
154+
if (obj != null && obj.getId() != null) {
155+
MessageContext.setEventContextMap(eventName, obj.getId().toString(), obj);
156156
return true;
157+
} else if(obj != null){
158+
throw new MessageNotDefinedException( "Id is not defined ");
157159
}
158160
} catch (MessageNotDefinedException e) {
159161
LOGGER.warning(record.key() + " is not defined " + e.getMessage());

modules/cucumblan-message/src/main/java/io/virtualan/cucumblan/message/type/MessageType.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,19 @@ public interface MessageType<T, TT> {
4242
*/
4343
String getType();
4444

45+
/**
46+
* Gets unique identifier of the message
47+
*
48+
* @return the id
49+
*/
50+
Object getId();
51+
4552
/**
4653
* Gets Kafka message key for kafka
4754
*
4855
* @return the id
4956
*/
50-
T getId();
57+
T getKey();
5158

5259

5360
/**
@@ -88,7 +95,7 @@ public interface MessageType<T, TT> {
8895
* Build message while consuming the message
8996
* for your specific needs Refer io.virtualan.cucumblan.message.typeimpl.JSONMessage
9097
*
91-
* @param record ConsumerRecord<T, TT> object available in the context
98+
* @param record ConsumerRecord object available in the context
9299
* @param key the kafka message key
93100
* @param value the kafka message object
94101
* @return the message type used for Pre defined verification steps

modules/cucumblan-message/src/main/java/io/virtualan/cucumblan/message/typeimpl/JSONMessage.java

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public Integer getId() {
7272
return id;
7373
}
7474

75+
@Override
76+
public Integer getKey() {
77+
return id;
78+
}
79+
7580
@Override
7681
public String getMessage() {
7782
return body;

modules/cucumblan-ui/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.virtualan</groupId>
44
<artifactId>cucumblan-ui</artifactId>
5-
<version>1.0.4-SNAPSHOT</version>
5+
<version>1.0.6-SNAPSHOT</version>
66
<packaging>jar</packaging>
77
<name>cucumblan-ui</name>
88
<properties>

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<artifactId>cucumblan-project</artifactId>
1010
<packaging>pom</packaging>
1111
<name>cucumblan-project</name>
12-
<version>1.1.7-SNAPSHOT</version>
12+
<version>1.1.9-SNAPSHOT</version>
1313
<url>https://virtualan.io</url>
1414
<scm>
1515
<connection>scm:git:ssh://[email protected]/virtualansoftware/cucumblan.git</connection>

samples/cucumblan-message-testing/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<packaging>jar</packaging>
77
<name>cucumblan-message-testing</name>
88
<properties>
9+
<cucumblan-message.version>0.0.3-SNAPSHOT</cucumblan-message.version>
910
<mapson.version>1.1.4</mapson.version>
1011
<kafka-clients.version>2.7.0</kafka-clients.version>
1112
<junit.version>5.5.2</junit.version>
@@ -128,7 +129,7 @@
128129
<dependency>
129130
<groupId>io.virtualan</groupId>
130131
<artifactId>cucumblan-message</artifactId>
131-
<version>0.0.2-SNAPSHOT</version>
132+
<version>${cucumblan-message.version}</version>
132133
</dependency>
133134
<dependency>
134135
<groupId>org.junit.jupiter</groupId>

samples/cucumblan-message-testing/src/test/java/io/virtualan/test/msgtype/impl/JSONMessage.java

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public List<Header> getHeaders() {
6565
return null;
6666
}
6767

68+
69+
@Override
70+
public String getKey() {
71+
return null;
72+
}
73+
6874
@Override
6975
public String getId() {
7076
return id;

0 commit comments

Comments
 (0)