Skip to content

Commit

Permalink
Bugfix: now not blowing up on missing pace (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed Nov 1, 2023
1 parent a20309a commit 0d1f0a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ synchronized Flux<I> limitRate(I command) {

try {

if (pace == null) {
logger.trace("{}: null pace - passthrough command={}", id, command);
return Flux.just(command);
}

var now = clock.instant();

if (!command.equals(lastCommand)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.sf.dz3r.common.TestClock;
import net.sf.dz3r.device.DeviceState;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import reactor.core.publisher.Flux;
Expand All @@ -11,9 +12,22 @@
import java.util.stream.Stream;

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

class AbstractCqrsDeviceTest {

@Test
void noPace() {
var clock = new TestClock();
var device = new PaceTest("pt", clock, null, null);

device.limitRate("command");

assertThatCode(() -> {
device.limitRate("command");
}).doesNotThrowAnyException();
}

@ParameterizedTest
@MethodSource("getPaceStream")
void pace(Flux<PaceTuple> source) {
Expand Down

0 comments on commit 0d1f0a1

Please sign in to comment.