Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump zeebe-bom from 1.3.6 to 8.0.2 #145

Merged
merged 7 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Java environment
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_GPG_SIGNING_KEY_SEC }}
gpg-passphrase: MAVEN_CENTRAL_GPG_PASSPHRASE
- name: Build
Expand Down
5 changes: 5 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
17 changes: 12 additions & 5 deletions eze/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>eze</artifactId>
Expand All @@ -23,6 +25,11 @@
<artifactId>zeebe-workflow-engine</artifactId>
</dependency>

<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-db</artifactId>
</dependency>

<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-util</artifactId>
Expand Down Expand Up @@ -195,10 +202,10 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.jetbrains</groupId>-->
<!-- <artifactId>annotations</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.jetbrains</groupId>-->
<!-- <artifactId>annotations</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,25 @@ class EzeDbColumnFamily<ColumnFamilyNames : Enum<ColumnFamilyNames>,
}
}

override fun put(key: KeyType, value: ValueType) {
override fun insert(key: KeyType, value: ValueType) {
if (exists(key)) {
throw IllegalStateException("An entry with the key $key already exists.")
}
put(key, value)
}

override fun update(key: KeyType, value: ValueType) {
if (!exists(key)) {
throw IllegalStateException("An entry with the key $key doesn't exist.")
}
put(key, value)
}

override fun upsert(key: KeyType, value: ValueType) {
put(key, value)
}

private fun put(key: KeyType, value: ValueType) {
ensureInOpenTransaction(
context
) { transaction ->
Expand All @@ -53,6 +71,7 @@ class EzeDbColumnFamily<ColumnFamilyNames : Enum<ColumnFamilyNames>,
}
}


override fun get(key: KeyType): ValueType? {
columnFamilyContext.writeKey(key)
val valueBuffer: DirectBuffer? = getValue(context, columnFamilyContext)
Expand Down Expand Up @@ -103,7 +122,18 @@ class EzeDbColumnFamily<ColumnFamilyNames : Enum<ColumnFamilyNames>,
whileEqualPrefix(context, keyPrefix, visitor)
}

override fun delete(key: KeyType) {
override fun deleteExisting(key: KeyType) {
if (!exists(key)) {
throw IllegalStateException("An entry with the key $key doesn't exist.")
}
delete(key)
}

override fun deleteIfExists(key: KeyType) {
delete(key)
}

private fun delete(key: KeyType) {
columnFamilyContext.writeKey(key)
ensureInOpenTransaction(
context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package org.camunda.community.eze.db;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import io.camunda.zeebe.db.ColumnFamily;
import io.camunda.zeebe.db.ZeebeDb;
Expand Down Expand Up @@ -45,13 +47,13 @@ public void setup() throws Exception {
}

@Test
public void shouldPutValue() {
public void shouldInsertValue() {
// given
key.wrapLong(1213);
value.wrapLong(255);

// when
columnFamily.put(key, value);
columnFamily.insert(key, value);
value.wrapLong(221);

// then
Expand All @@ -64,6 +66,81 @@ public void shouldPutValue() {
assertThat(value.getValue()).isEqualTo(255);
}

@Test
public void shouldNotInsertIfExist() {
// given
key.wrapLong(1);
value.wrapLong(10);

columnFamily.insert(key, value);

// when/then
assertThatThrownBy(() -> columnFamily.insert(key, value))
.isInstanceOf(IllegalStateException.class);
}

@Test
public void shouldUpdateValue() {
// given
key.wrapLong(1213);
value.wrapLong(255);
columnFamily.insert(key, value);

// when
value.wrapLong(256);
columnFamily.update(key, value);

// then
final DbLong zbLong = columnFamily.get(key);

assertThat(zbLong).isNotNull();
assertThat(zbLong.getValue()).isEqualTo(256);
}

@Test
public void shouldNotUpdateIfNotExist() {
// given
key.wrapLong(1);
value.wrapLong(10);

// when/then
assertThatThrownBy(() -> columnFamily.update(key, value))
.isInstanceOf(IllegalStateException.class);
}

@Test
public void shouldUpsertIfExist() {
// given
key.wrapLong(1);
value.wrapLong(10);

columnFamily.insert(key, value);

// when
value.wrapLong(11);
columnFamily.upsert(key, value);

// then
final var persistedValue = columnFamily.get(key);

assertThat(persistedValue.getValue()).isEqualTo(11);
}

@Test
public void shouldUpsertIfNotExist() {
// given
key.wrapLong(1);
value.wrapLong(10);

// when
columnFamily.upsert(key, value);

// then
final var persistedValue = columnFamily.get(key);

assertThat(persistedValue.getValue()).isEqualTo(10);
}

@Test
public void shouldReturnNullIfNotExist() {
// given
Expand Down Expand Up @@ -149,12 +226,12 @@ public void shouldNotExist() {
}

@Test
public void shouldDelete() {
public void shouldDeleteExisting() {
// given
putKeyValuePair(1213, 255);

// when
columnFamily.delete(key);
columnFamily.deleteExisting(key);

// then
final boolean exists = columnFamily.exists(key);
Expand All @@ -164,14 +241,52 @@ public void shouldDelete() {
assertThat(zbLong).isNull();
}

@Test
public void shouldNotDeleteExistingIfNotExist() {
// given
key.wrapLong(1);
value.wrapLong(10);

// when/then
assertThatThrownBy(() -> columnFamily.deleteExisting(key))
.isInstanceOf(IllegalStateException.class);
}

@Test
public void shouldDeleteIfExists() {
// given
key.wrapLong(1);
value.wrapLong(10);

columnFamily.insert(key, value);

// when
columnFamily.deleteIfExists(key);

// then
final var persistedValue = columnFamily.get(key);

assertThat(persistedValue).isNull();
}

@Test
public void shouldIgnoreDeleteIfNotExist() {
// given
key.wrapLong(1);
value.wrapLong(10);

// when/then
assertThatCode(() -> columnFamily.deleteIfExists(key)).doesNotThrowAnyException();
}

@Test
public void shouldNotDeleteDifferentKey() {
// given
putKeyValuePair(1213, 255);

// when
key.wrapLong(700);
columnFamily.delete(key);
columnFamily.deleteIfExists(key);

// then
key.wrapLong(1213);
Expand Down Expand Up @@ -235,7 +350,7 @@ public void shouldDeleteOnForeachPair() {
// when
columnFamily.forEach(
(key, value) -> {
columnFamily.delete(key);
columnFamily.deleteIfExists(key);
});

final List<Long> keys = new ArrayList<>();
Expand Down Expand Up @@ -302,7 +417,7 @@ public void shouldDeleteWhileTrue() {
// when
columnFamily.whileTrue(
(key, value) -> {
columnFamily.delete(key);
columnFamily.deleteIfExists(key);
return key.getValue() != 4567;
});

Expand All @@ -326,13 +441,13 @@ public void shouldCheckIfEmpty() {
putKeyValuePair(1, 10);
assertThat(columnFamily.isEmpty()).isFalse();

columnFamily.delete(key);
columnFamily.deleteIfExists(key);
assertThat(columnFamily.isEmpty()).isTrue();
}

private void putKeyValuePair(final int key, final int value) {
this.key.wrapLong(key);
this.value.wrapLong(value);
columnFamily.put(this.key, this.value);
columnFamily.upsert(this.key, this.value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public void setup() throws Exception {
}

@Test
public void shouldPutValue() {
public void shouldInsertValue() {
// given
key.wrapString("foo");
value.wrapString("baring");

// when
columnFamily.put(key, value);
columnFamily.insert(key, value);
value.wrapString("yes");

// then
Expand Down Expand Up @@ -230,6 +230,6 @@ public void shouldThrowExceptionOnMultipleNestedWhileEqualPrefix() {
private void putKeyValuePair(final String key, final String value) {
this.key.wrapString(key);
this.value.wrapString(value);
columnFamily.put(this.key, this.value);
columnFamily.upsert(this.key, this.value);
}
}
Loading