-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10458: Reorganize stream processor and engine tests r=Zelldon a=Zelldon ## Description Moved some tests around to make it easier to detect which need to be migrated for #10455 and to make it easier to create the new module and copy the tests, which are part of the StreamProcessor see #10130 <!-- Please explain the changes you made here. --> ## Related issues <!-- Which issues are closed by this PR or are related --> related to #10455 related to #10130 Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
- Loading branch information
Showing
11 changed files
with
111 additions
and
13 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
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
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
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
101 changes: 101 additions & 0 deletions
101
engine/src/test/java/io/camunda/zeebe/streamprocessor/TypedEventSerializationTest.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,101 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.streamprocessor; | ||
|
||
import static io.camunda.zeebe.util.buffer.BufferUtil.wrapString; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import io.camunda.zeebe.engine.api.TypedRecord; | ||
import io.camunda.zeebe.logstreams.log.LoggedEvent; | ||
import io.camunda.zeebe.protocol.impl.record.CopiedRecord; | ||
import io.camunda.zeebe.protocol.impl.record.RecordMetadata; | ||
import io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord; | ||
import io.camunda.zeebe.protocol.record.RecordType; | ||
import io.camunda.zeebe.protocol.record.RejectionType; | ||
import io.camunda.zeebe.protocol.record.ValueType; | ||
import io.camunda.zeebe.protocol.record.intent.DeploymentIntent; | ||
import io.camunda.zeebe.test.util.JsonUtil; | ||
import io.camunda.zeebe.util.collection.Tuple; | ||
import org.agrona.DirectBuffer; | ||
import org.junit.Test; | ||
|
||
public final class TypedEventSerializationTest { | ||
|
||
private static Tuple<TypedRecord, CopiedRecord> createRecordTuple() { | ||
final RecordMetadata recordMetadata = new RecordMetadata(); | ||
|
||
final DeploymentIntent intent = DeploymentIntent.CREATE; | ||
final int protocolVersion = 1; | ||
final ValueType valueType = ValueType.DEPLOYMENT; | ||
|
||
final RecordType recordType = RecordType.COMMAND; | ||
final String rejectionReason = "fails"; | ||
final RejectionType rejectionType = RejectionType.INVALID_ARGUMENT; | ||
final int requestId = 23; | ||
final int requestStreamId = 1; | ||
|
||
recordMetadata | ||
.intent(intent) | ||
.protocolVersion(protocolVersion) | ||
.valueType(valueType) | ||
.recordType(recordType) | ||
.rejectionReason(rejectionReason) | ||
.rejectionType(rejectionType) | ||
.requestId(requestId) | ||
.requestStreamId(requestStreamId); | ||
|
||
final String resourceName = "resource"; | ||
final DirectBuffer resource = wrapString("contents"); | ||
final String bpmnProcessId = "testProcess"; | ||
final long processDefinitionKey = 123; | ||
final int processVersion = 12; | ||
final DeploymentRecord record = new DeploymentRecord(); | ||
record.resources().add().setResourceName(wrapString(resourceName)).setResource(resource); | ||
record | ||
.processesMetadata() | ||
.add() | ||
.setBpmnProcessId(wrapString(bpmnProcessId)) | ||
.setKey(processDefinitionKey) | ||
.setResourceName(wrapString(resourceName)) | ||
.setVersion(processVersion) | ||
.setChecksum(wrapString("checksum")); | ||
|
||
final long key = 1234; | ||
final long position = 4321; | ||
final long sourcePosition = 231; | ||
final long timestamp = 2191L; | ||
|
||
final LoggedEvent loggedEvent = mock(LoggedEvent.class); | ||
when(loggedEvent.getPosition()).thenReturn(position); | ||
when(loggedEvent.getKey()).thenReturn(key); | ||
when(loggedEvent.getSourceEventPosition()).thenReturn(sourcePosition); | ||
when(loggedEvent.getTimestamp()).thenReturn(timestamp); | ||
|
||
final TypedRecordImpl typedEvent = new TypedRecordImpl(0); | ||
typedEvent.wrap(loggedEvent, recordMetadata, record); | ||
|
||
final CopiedRecord copiedRecord = | ||
new CopiedRecord<>(record, recordMetadata, key, 0, position, sourcePosition, timestamp); | ||
|
||
return new Tuple<>(typedEvent, copiedRecord); | ||
} | ||
|
||
@Test | ||
public void shouldCreateSameJson() { | ||
// given | ||
final Tuple<TypedRecord, CopiedRecord> records = createRecordTuple(); | ||
final String expectedJson = records.getRight().toJson(); | ||
|
||
// when | ||
final String actualJson = records.getLeft().toJson(); | ||
|
||
// then | ||
JsonUtil.assertEquality(actualJson, expectedJson); | ||
} | ||
} |