-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from grusski/bugfix/fix-for-messageplaybook-fe…
…ature Fix for Message Books feature
- Loading branch information
Showing
6 changed files
with
132 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,4 +124,8 @@ task versionFile() { | |
} | ||
} | ||
|
||
test { | ||
useJUnit() | ||
} | ||
|
||
tasks.named('processResources') { dependsOn('versionFile') } |
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
60 changes: 60 additions & 0 deletions
60
src/main/java/at/esque/kafka/topics/model/KafkaMessageForMessageBook.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,60 @@ | ||
package at.esque.kafka.topics.model; | ||
|
||
|
||
public class KafkaMessageForMessageBook { | ||
|
||
private int partition; | ||
private String key; | ||
private String keyType; | ||
private String value; | ||
private String valueType; | ||
private String timestamp; | ||
|
||
public int getPartition() { | ||
return partition; | ||
} | ||
|
||
public void setPartition(int partition) { | ||
this.partition = partition; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public void setKey(String key) { | ||
this.key = key; | ||
} | ||
|
||
public String getKeyType() { | ||
return keyType; | ||
} | ||
|
||
public void setKeyType(String keyType) { | ||
this.keyType = keyType; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValueType() { | ||
return valueType; | ||
} | ||
|
||
public void setValueType(String valueType) { | ||
this.valueType = valueType; | ||
} | ||
|
||
public String getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public void setTimestamp(String timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
} |
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,50 @@ | ||
package at.esque.kafka; | ||
|
||
import at.esque.kafka.topics.model.KafkaMessageBookWrapper; | ||
import at.esque.kafka.topics.model.KafkaMessageForMessageBook; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ControllerTest { | ||
|
||
@Test | ||
public void testAddMessagesToSend() { | ||
// Given | ||
List<KafkaMessageBookWrapper> messagesToSend = new ArrayList<>(); | ||
File playFile = new File("src/test/resources/csv_testfiles/testAddMessagesToSend.csv"); | ||
|
||
KafkaMessageForMessageBook message1Expected = new KafkaMessageForMessageBook(); | ||
message1Expected.setKey("${value1:UUID}"); | ||
message1Expected.setPartition(-1); | ||
message1Expected.setTimestamp("2022-11-06T17:11:52.919Z"); | ||
message1Expected.setValue("{\"version\":0,\"newId\":\"${value1:UUID}\"}"); | ||
|
||
KafkaMessageForMessageBook message2Expected = new KafkaMessageForMessageBook(); | ||
message2Expected.setKey("${value2:UUID}"); | ||
message2Expected.setPartition(-1); | ||
message2Expected.setTimestamp("2022-11-06T17:13:52.919Z"); | ||
message2Expected.setValue("{\"version\":0,\"newId\":\"${value2:UUID}\"}"); | ||
|
||
// When | ||
Controller controller = new Controller(); | ||
controller.addMessagesToSend(messagesToSend, playFile); | ||
|
||
// Then | ||
assertEquals(2, messagesToSend.size()); | ||
|
||
assertEquals(message1Expected.getPartition(), messagesToSend.get(0).getWrappedMessage().getPartition()); | ||
assertEquals(message1Expected.getKey(), messagesToSend.get(0).getWrappedMessage().getKey()); | ||
assertEquals(message1Expected.getTimestamp(), messagesToSend.get(0).getWrappedMessage().getTimestamp()); | ||
assertEquals(message1Expected.getValue(), messagesToSend.get(0).getWrappedMessage().getValue()); | ||
|
||
assertEquals(message2Expected.getPartition(), messagesToSend.get(1).getWrappedMessage().getPartition()); | ||
assertEquals(message2Expected.getKey(), messagesToSend.get(1).getWrappedMessage().getKey()); | ||
assertEquals(message2Expected.getTimestamp(), messagesToSend.get(1).getWrappedMessage().getTimestamp()); | ||
assertEquals(message2Expected.getValue(), messagesToSend.get(1).getWrappedMessage().getValue()); | ||
} | ||
} |
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,3 @@ | ||
"key","partition","timestamp","value" | ||
"${value1:UUID}","-1","2022-11-06T17:11:52.919Z","{""version"":0,""newId"":""${value1:UUID}""}" | ||
"${value2:UUID}","-1","2022-11-06T17:13:52.919Z","{""version"":0,""newId"":""${value2:UUID}""}" |