-
Notifications
You must be signed in to change notification settings - Fork 28
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 #30 from zeebe-io/json
feat(exporter): serialize records as JSON
- Loading branch information
Showing
5 changed files
with
120 additions
and
3 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
78 changes: 78 additions & 0 deletions
78
exporter/src/test/java/io/zeebe/hazelcast/ExporterJsonTest.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,78 @@ | ||
package io.zeebe.hazelcast; | ||
|
||
import com.hazelcast.client.HazelcastClient; | ||
import com.hazelcast.client.config.ClientConfig; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.ringbuffer.Ringbuffer; | ||
import io.zeebe.client.ZeebeClient; | ||
import io.zeebe.hazelcast.exporter.ExporterConfiguration; | ||
import io.zeebe.model.bpmn.Bpmn; | ||
import io.zeebe.model.bpmn.BpmnModelInstance; | ||
import io.zeebe.test.ZeebeTestRule; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import java.util.Properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ExporterJsonTest { | ||
|
||
private static final BpmnModelInstance WORKFLOW = | ||
Bpmn.createExecutableProcess("process") | ||
.startEvent("start") | ||
.sequenceFlowId("to-task") | ||
.serviceTask("task", s -> s.zeebeTaskType("test")) | ||
.sequenceFlowId("to-end") | ||
.endEvent("end") | ||
.done(); | ||
|
||
private static final ExporterConfiguration CONFIGURATION = new ExporterConfiguration(); | ||
|
||
@Rule | ||
public final ZeebeTestRule testRule = | ||
new ZeebeTestRule("zeebe-json.test.cfg.toml", Properties::new); | ||
|
||
private ZeebeClient client; | ||
private HazelcastInstance hz; | ||
|
||
@Before | ||
public void init() { | ||
client = testRule.getClient(); | ||
|
||
final ClientConfig clientConfig = new ClientConfig(); | ||
clientConfig.getNetworkConfig().addAddress("127.0.0.1:5701"); | ||
hz = HazelcastClient.newHazelcastClient(clientConfig); | ||
} | ||
|
||
@After | ||
public void cleanUp() { | ||
hz.shutdown(); | ||
} | ||
|
||
@Test | ||
public void shouldExportEventsAsProtobuf() throws Exception { | ||
// given | ||
final Ringbuffer<byte[]> buffer = hz.getRingbuffer(CONFIGURATION.name); | ||
|
||
var sequence = buffer.headSequence(); | ||
|
||
// when | ||
client.newDeployCommand().addWorkflowModel(WORKFLOW, "process.bpmn").send().join(); | ||
|
||
// then | ||
final var message = buffer.readOne(sequence); | ||
assertThat(message).isNotNull(); | ||
|
||
final var jsonRecord = new String(message); | ||
|
||
assertThat(jsonRecord) | ||
.startsWith("{") | ||
.endsWith("}") | ||
.contains("\"valueType\":\"DEPLOYMENT\"") | ||
.contains("\"recordType\":\"EVENT\"") | ||
.contains("\"intent\":\"CREATED\""); | ||
} | ||
} |
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,6 @@ | ||
[[exporters]] | ||
id = "hazelcast" | ||
className = "io.zeebe.hazelcast.exporter.HazelcastExporter" | ||
|
||
[exporters.args] | ||
format = "json" |