Skip to content

Commit

Permalink
Merge pull request #34 from virtualansoftware/compare
Browse files Browse the repository at this point in the history
KAFKA and JDBC cucumblan official delivery
  • Loading branch information
elans3 authored Apr 4, 2021
2 parents ae324bb + d6dce75 commit e1ebb67
Show file tree
Hide file tree
Showing 12 changed files with 492 additions and 347 deletions.
2 changes: 1 addition & 1 deletion modules/cucumblan-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<artifactId>cucumblan-api</artifactId>
<packaging>jar</packaging>
<name>cucumblan-api</name>
<version>1.1.7-SNAPSHOT</version>
<version>1.1.9-SNAPSHOT</version>
<properties>
<mapson.version>1.1.4</mapson.version>
<cucumber.version>6.7.0</cucumber.version>
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/cucumblan-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<artifactId>cucumblan-db</artifactId>
<packaging>jar</packaging>
<name>cucumblan-db</name>
<version>0.0.2-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<properties>
<junit.version>5.5.2</junit.version>
<mapson.version>1.1.4</mapson.version>
Expand Down
2 changes: 1 addition & 1 deletion modules/cucumblan-message/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.virtualan</groupId>
<artifactId>cucumblan-message</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cucumblan-message</name>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void before(Scenario scenario) {
* @param resource the resource
* @param type the type
* @param messages the messages
* @throws MessageNotDefinedException the message not defined exception
*/
@Given("send message event (.*) in partition (.*) on (.*) with type (.*)$")
public void produceMessageWithPartition(String eventName, Integer partition, String resource,
Expand All @@ -85,13 +86,19 @@ public void produceMessageWithPartition(String eventName, Integer partition, Str
scenario.log(builtMessage.toString());

KafkaProducerClient
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
partition, builtMessage.getHeaders());
} else {
Assertions.assertTrue(false, eventName + " is not configured for any topic. or " + type +" is not configured");
}
}

/**
* Produce message.
*
* @param sleep the sleep
* @throws InterruptedException the interrupted exception
*/
@Given("pause message process for (.*) milliseconds$")
public void produceMessage(long sleep) throws InterruptedException {
Thread.sleep(sleep);
Expand All @@ -104,6 +111,7 @@ public void produceMessage(long sleep) throws InterruptedException {
* @param resource the resource
* @param type the type
* @param messages the messages
* @throws MessageNotDefinedException the message not defined exception
*/
@Given("send message event (.*) on (.*) with type (.*)$")
public void produceMessage(String eventName, String resource, String type,
Expand All @@ -113,9 +121,9 @@ public void produceMessage(String eventName, String resource, String type,
if (topic != null && messageType != null) {
MessageType builtMessage = messageType.buildProducerMessage(messages);
scenario.log(builtMessage.toString());
if (builtMessage.getId() != null) {
if (builtMessage.getKey() != null) {
KafkaProducerClient
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
null, builtMessage.getHeaders());
} else {
KafkaProducerClient
Expand All @@ -134,6 +142,7 @@ public void produceMessage(String eventName, String resource, String type,
* @param resource the resource
* @param type the type
* @param messages the messages
* @throws MessageNotDefinedException the message not defined exception
*/
@Given("send inline message event (.*) on (.*) with type (.*)$")
public void produceMessage(String eventName, String resource, String type,
Expand All @@ -143,9 +152,9 @@ public void produceMessage(String eventName, String resource, String type,
if (topic != null && messageType != null) {
MessageType builtMessage = messageType.buildProducerMessage(messages);
scenario.log(builtMessage.toString());
if (builtMessage.getId() != null) {
if (builtMessage.getKey() != null) {
KafkaProducerClient
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
null, builtMessage.getHeaders());
} else {
KafkaProducerClient
Expand All @@ -164,6 +173,7 @@ public void produceMessage(String eventName, String resource, String type,
* @param resource the resource
* @param type the type
* @param messages the messages
* @throws MessageNotDefinedException the message not defined exception
*/
@Given("send mapson message event (.*) on (.*) with type (.*)$")
public void produceMessageMapson(String eventName, String resource, String type,
Expand All @@ -173,9 +183,9 @@ public void produceMessageMapson(String eventName, String resource, String type,
if (topic != null && messageType != null) {
MessageType builtMessage = messageType.buildProducerMessage(messages);
scenario.log(builtMessage.toString());
if (builtMessage.getId() != null) {
if (builtMessage.getKey() != null) {
KafkaProducerClient
.sendMessage(resource, topic, builtMessage.getId(), builtMessage.getMessage(),
.sendMessage(resource, topic, builtMessage.getKey(), builtMessage.getMessage(),
null, builtMessage.getHeaders());
} else {
KafkaProducerClient
Expand All @@ -195,9 +205,11 @@ public void produceMessageMapson(String eventName, String resource, String type,
* @param eventName the event name
* @param id the id
* @param resource the resource
* @param type the type
* @param csvson the csvson
* @throws InterruptedException the interrupted exception
* @throws BadInputDataException bad input data exception
* @throws InterruptedException the interrupted exception
* @throws BadInputDataException bad input data exception
* @throws MessageNotDefinedException the message not defined exception
*/
@Given("verify (.*) contains (.*) on (.*) with type (.*)$")
public void verifyConsumedJSONObject(String eventName, String id, String resource, String type,
Expand Down Expand Up @@ -228,8 +240,10 @@ public void verifyConsumedJSONObject(String eventName, String id, String resourc
* @param eventName the event name
* @param id the id
* @param resource the resource
* @param type the type
* @param keyValue the key value
* @throws InterruptedException interrupted exception
* @throws InterruptedException interrupted exception
* @throws MessageNotDefinedException the message not defined exception
*/
@Given("verify-by-elements (.*) contains (.*) on (.*) with type (.*)$")
public void consumeMessage(String eventName, String id, String resource, String type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ private boolean getMessageType(String eventName, String type,
if (messageType != null) {
try {
obj = messageType.buildConsumerMessage(record, record.key(), record.value());
if (obj != null) {
MessageContext.setEventContextMap(eventName, String.valueOf(obj.getId()), obj);
if (obj != null && obj.getId() != null) {
MessageContext.setEventContextMap(eventName, obj.getId().toString(), obj);
return true;
} else if(obj != null){
throw new MessageNotDefinedException( "Id is not defined ");
}
} catch (MessageNotDefinedException e) {
LOGGER.warning(record.key() + " is not defined " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ public interface MessageType<T, TT> {
*/
String getType();

/**
* Gets unique identifier of the message
*
* @return the id
*/
Object getId();

/**
* Gets Kafka message key for kafka
*
* @return the id
*/
T getId();
T getKey();


/**
Expand Down Expand Up @@ -88,7 +95,7 @@ public interface MessageType<T, TT> {
* Build message while consuming the message
* for your specific needs Refer io.virtualan.cucumblan.message.typeimpl.JSONMessage
*
* @param record ConsumerRecord<T, TT> object available in the context
* @param record ConsumerRecord object available in the context
* @param key the kafka message key
* @param value the kafka message object
* @return the message type used for Pre defined verification steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public Integer getId() {
return id;
}

@Override
public Integer getKey() {
return id;
}

@Override
public String getMessage() {
return body;
Expand Down
2 changes: 1 addition & 1 deletion modules/cucumblan-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.virtualan</groupId>
<artifactId>cucumblan-ui</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cucumblan-ui</name>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>cucumblan-project</artifactId>
<packaging>pom</packaging>
<name>cucumblan-project</name>
<version>1.1.7-SNAPSHOT</version>
<version>1.1.9-SNAPSHOT</version>
<url>https://virtualan.io</url>
<scm>
<connection>scm:git:ssh://git@github.com/virtualansoftware/cucumblan.git</connection>
Expand Down
3 changes: 2 additions & 1 deletion samples/cucumblan-message-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<packaging>jar</packaging>
<name>cucumblan-message-testing</name>
<properties>
<cucumblan-message.version>0.0.3-SNAPSHOT</cucumblan-message.version>
<mapson.version>1.1.4</mapson.version>
<kafka-clients.version>2.7.0</kafka-clients.version>
<junit.version>5.5.2</junit.version>
Expand Down Expand Up @@ -128,7 +129,7 @@
<dependency>
<groupId>io.virtualan</groupId>
<artifactId>cucumblan-message</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>${cucumblan-message.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public List<Header> getHeaders() {
return null;
}


@Override
public String getKey() {
return null;
}

@Override
public String getId() {
return id;
Expand Down

0 comments on commit e1ebb67

Please sign in to comment.