Skip to content
This repository has been archived by the owner on Jan 30, 2022. It is now read-only.

Commit

Permalink
chore: new generated defaults
Browse files Browse the repository at this point in the history
- updates defaults for generated classes such that all fields are now
  optional and will be initialized with correct zero-values
- removes complex property based testing in favor of exporter
  integration harness
  • Loading branch information
npepinpe committed Mar 14, 2021
1 parent 9f4da91 commit 49ee736
Show file tree
Hide file tree
Showing 28 changed files with 228 additions and 1,913 deletions.
32 changes: 15 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?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>
<name>Zeebe Protocol Immutables</name>
Expand All @@ -16,7 +18,7 @@
<artifactId>camunda-release-parent</artifactId>
<version>3.7</version>
<!-- do not remove empty tag - http://jira.codehaus.org/browse/MNG-4687 -->
<relativePath />
<relativePath/>
</parent>

<properties>
Expand All @@ -36,6 +38,7 @@

<!-- project dependencies -->
<version.assertj>3.19.0</version.assertj>
<version.awaitility>4.0.3</version.awaitility>
<version.immutables>2.8.8</version.immutables>
<version.jackson>2.11.3</version.jackson>
<version.javax-annotation>1.3.2</version.javax-annotation>
Expand Down Expand Up @@ -97,7 +100,7 @@

<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-protocol-impl</artifactId>
<artifactId>zeebe-test</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -128,13 +131,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand All @@ -143,16 +139,16 @@
</dependency>

<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
<version>${version.jqwik}</version>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${version.assertj}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${version.assertj}</version>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${version.awaitility}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -164,7 +160,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<sourcepath>${project.build.sourceDirectory}:${project.build.directory}/generated-sources/annotations</sourcepath>
<sourcepath>
${project.build.sourceDirectory}:${project.build.directory}/generated-sources/annotations
</sourcepath>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,4 @@
@Value.Immutable
@ZeebeStyle
abstract class AbstractErrorRecordValue extends AbstractJsonSerializable
implements ErrorRecordValue {

@Value.Default
@Override
public String getExceptionMessage() {
return "";
}

@Value.Default
@Override
public String getStacktrace() {
return "";
}

@Value.Default
@Override
public long getWorkflowInstanceKey() {
return -1;
}
}
implements ErrorRecordValue {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.zeebe.protocol.immutables.record;

import io.zeebe.protocol.record.value.ErrorType;
import io.zeebe.protocol.record.value.IncidentRecordValue;
import org.immutables.value.Value;

Expand All @@ -25,7 +26,7 @@ abstract class AbstractIncidentRecordValue extends AbstractJsonSerializable

@Value.Default
@Override
public long getJobKey() {
return -1;
public ErrorType getErrorType() {
return ErrorType.UNKNOWN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public Map<String, String> getCustomHeaders() {
return Collections.emptyMap();
}

@Value.Default
@Override
public String getErrorMessage() {
return "";
}

@Value.Default
@Override
public String getErrorCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,4 @@
@Value.Immutable
@ZeebeStyle
abstract class AbstractMessageRecordValue extends AbstractJsonSerializable
implements MessageRecordValue {

@Value.Default
@Override
public String getMessageId() {
return "";
}

@Value.Default
@Override
public long getTimeToLive() {
return 0;
}
}
implements MessageRecordValue {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import io.zeebe.protocol.record.Record;
import io.zeebe.protocol.record.RecordType;
import io.zeebe.protocol.record.RecordValue;
import io.zeebe.protocol.record.RejectionType;
import io.zeebe.protocol.record.intent.Intent;
Expand All @@ -30,18 +31,6 @@
abstract class AbstractRecord<T extends RecordValue> extends AbstractJsonSerializable
implements Record<T> {

@Value.Default
@Override
public long getSourceRecordPosition() {
return -1;
}

@Value.Default
@Override
public long getKey() {
return -1;
}

@Value.Default
@JsonTypeInfo(use = Id.CUSTOM, include = As.EXTERNAL_PROPERTY, property = "valueType")
@JsonTypeIdResolver(IntentTypeIdResolver.class)
Expand All @@ -52,20 +41,14 @@ public Intent getIntent() {

@Value.Default
@Override
public RejectionType getRejectionType() {
return RejectionType.NULL_VAL;
}

@Value.Default
@Override
public String getRejectionReason() {
return "";
public RecordType getRecordType() {
return RecordType.NULL_VAL;
}

@Value.Default
@Override
public String getBrokerVersion() {
return "";
public RejectionType getRejectionType() {
return RejectionType.NULL_VAL;
}

@JsonTypeInfo(use = Id.CUSTOM, include = As.EXTERNAL_PROPERTY, property = "valueType")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,4 @@
@Value.Immutable
@ZeebeStyle
abstract class AbstractTimerRecordValue extends AbstractJsonSerializable
implements TimerRecordValue {

@Value.Default
@Override
public int getRepetitions() {
return 0;
}
}
implements TimerRecordValue {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,9 @@
package io.zeebe.protocol.immutables.record;

import io.zeebe.protocol.record.value.WorkflowInstanceCreationRecordValue;
import java.util.Collections;
import java.util.Map;
import org.immutables.value.Value;

@Value.Immutable
@ZeebeStyle
abstract class AbstractWorkflowInstanceCreationRecordValue extends AbstractJsonSerializable
implements WorkflowInstanceCreationRecordValue {

@Value.Default
@Override
public Map<String, Object> getVariables() {
return Collections.emptyMap();
}
}
implements WorkflowInstanceCreationRecordValue {}
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,4 @@ abstract class AbstractWorkflowInstanceRecordValue extends AbstractJsonSerializa
public BpmnElementType getBpmnElementType() {
return BpmnElementType.UNSPECIFIED;
}

@Value.Default
@Override
public long getFlowScopeKey() {
return -1;
}

@Value.Default
@Override
public long getParentWorkflowInstanceKey() {
return -1;
}

@Value.Default
@Override
public long getParentElementInstanceKey() {
return -1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
import java.lang.annotation.Target;
import org.immutables.value.Value;
import org.immutables.value.Value.Style.ImplementationVisibility;
import org.immutables.value.Value.Style.ValidationMethod;

@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
@Value.Style(
get = {"is*", "get*"},
typeAbstract = {"Abstract*"},
visibility = ImplementationVisibility.PUBLIC)
visibility = ImplementationVisibility.PUBLIC,
jdkOnly = true,
defaults = @Value.Immutable(prehash = true),
validationMethod = ValidationMethod.NONE,
defaultAsDefault = true,
headerComments = true,
clearBuilder = true)
@JsonSerialize
public @interface ZeebeStyle {}
Loading

0 comments on commit 49ee736

Please sign in to comment.