Skip to content

Commit

Permalink
enhanced test by asserting for the recovered write model
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Feb 9, 2022
1 parent c9763e1 commit 721f224
Showing 1 changed file with 20 additions and 14 deletions.
Expand Up @@ -267,20 +267,9 @@ public void forceUpdateAfterInitialStart() throws InterruptedException {
return null;
}).when(findPublisher).subscribe(any());

final CountDownLatch recoveryCompleteLatch = new CountDownLatch(1);
final Consumer<AbstractWriteModel> recoveryCompleteConsumer = writeModel -> {
recoveryCompleteLatch.countDown();
};
final Props props = Props.create(ThingUpdater.class,
() -> new ThingUpdater(pubSubTestProbe.ref(), changeQueueTestProbe.ref(), 0.0,
forceUpdateAfterStartTimeout, 0.0, mongoClientExtension, true, true,
recoveryCompleteConsumer));
final var underTest = childActorOf(props, THING_ID.toString());

final long request = probe.expectRequest();
DocumentCodec codec = new DocumentCodec();
DecoderContext decoderContext = DecoderContext.builder().build();
final var existingIndexDocument = codec.decode(new BsonDocumentReader(new BsonDocument()
final BsonDocument existingIndexBsonDocument = new BsonDocument()
.append(PersistenceConstants.FIELD_ID, new BsonString(THING_ID.toString()))
.append(PersistenceConstants.FIELD_REVISION, new BsonInt64(1234L))
.append(PersistenceConstants.FIELD_POLICY_ID, new BsonString(THING_ID.toString()))
Expand All @@ -290,8 +279,25 @@ public void forceUpdateAfterInitialStart() throws InterruptedException {
.append(PersistenceConstants.FIELD_SORTING, new BsonDocument().append("Lorem ipsum",
new BsonString("Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")))
.append(PersistenceConstants.FIELD_INTERNAL, new BsonArray())
), decoderContext);
.append(PersistenceConstants.FIELD_INTERNAL, new BsonArray());

final CountDownLatch recoveryCompleteLatch = new CountDownLatch(1);
final Consumer<AbstractWriteModel> recoveryCompleteConsumer = writeModel -> {
assertThat(writeModel).isEqualTo(
ThingWriteModel.of(
Metadata.of(THING_ID, 1234L, PolicyId.of(THING_ID), 1L, null),
existingIndexBsonDocument));
recoveryCompleteLatch.countDown();
};
final Props props = Props.create(ThingUpdater.class,
() -> new ThingUpdater(pubSubTestProbe.ref(), changeQueueTestProbe.ref(), 0.0,
forceUpdateAfterStartTimeout, 0.0, mongoClientExtension, true, true,
recoveryCompleteConsumer));
final var underTest = childActorOf(props, THING_ID.toString());

final long request = probe.expectRequest();
final var existingIndexDocument = codec.decode(new BsonDocumentReader(existingIndexBsonDocument),
decoderContext);
probe.sendNext(existingIndexDocument);

// wait until Actor was recovered:
Expand Down

0 comments on commit 721f224

Please sign in to comment.