Skip to content

Commit

Permalink
merge: #10605
Browse files Browse the repository at this point in the history
10605: test: fix unfinished stubbing of command response writer r=oleschoenburg a=oleschoenburg

The engine is shared across multiple tests and not stopped in-between. With this change we only set up mocking of the response writer once and not for every test method. This ensures that mocking does not interfere with engine processing from previous tests which would show up as unfinished mocking exceptions.

closes #10604 

Co-authored-by: Ole Schönburg <ole.schoenburg@gmail.com>
  • Loading branch information
zeebe-bors-camunda[bot] and oleschoenburg committed Oct 7, 2022
2 parents bb33569 + 7acd44d commit 70c0fd2
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,23 @@ public final class CreateProcessInstanceWithResultTest {
@ClassRule public static final EngineRule ENGINE = EngineRule.singlePartition();
private static final BpmnModelInstance PROCESS =
Bpmn.createExecutableProcess("PROCESS").startEvent().endEvent().done();
private static ProcessInstanceResultRecord response;
private static CommandResponseWriter mockCommandResponseWriter;

@Rule
public final RecordingExporterTestWatcher recordingExporterTestWatcher =
new RecordingExporterTestWatcher();

private ProcessInstanceResultRecord response;
private CommandResponseWriter mockCommandResponseWriter;

@BeforeClass
public static void init() {
mockCommandResponseWriter = ENGINE.getCommandResponseWriter();
interceptResponseWriter(mockCommandResponseWriter);
ENGINE.deployment().withXmlResource(PROCESS).deploy();
}

@Before
public void setUp() {
mockCommandResponseWriter = ENGINE.getCommandResponseWriter();
public void reset() {
Mockito.clearInvocations(mockCommandResponseWriter);
interceptResponseWriter(mockCommandResponseWriter);
}

@Test
Expand Down Expand Up @@ -159,7 +158,8 @@ public void shouldSendRejectionImmediately() {
verify(ENGINE.getCommandResponseWriter(), timeout(1000).times(1)).tryWriteResponse(3, 3);
}

private void interceptResponseWriter(final CommandResponseWriter mockCommandResponseWriter) {
private static void interceptResponseWriter(
final CommandResponseWriter mockCommandResponseWriter) {
doAnswer(
(Answer<CommandResponseWriter>)
(invocation -> {
Expand Down

0 comments on commit 70c0fd2

Please sign in to comment.