Skip to content

Commit

Permalink
Relax timing requirement in MongoEventSourceITAssertions.
Browse files Browse the repository at this point in the history
Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Dec 21, 2020
1 parent eac810a commit cba015e
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -20,6 +20,8 @@
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CompletionException;
import java.util.concurrent.TimeUnit;

import org.eclipse.ditto.model.base.entity.id.DefaultEntityId;
import org.eclipse.ditto.model.base.entity.id.EntityId;
Expand Down Expand Up @@ -293,10 +295,12 @@ private void purgeEntities(final Config config, final boolean prependNamespace)
underTest.tell(purgeEntities, getRef());
expectMsg(Duration.ofSeconds(8), PurgeEntitiesResponse.successful(entityType, dittoHeaders));

sleep(Duration.ofSeconds(5L));

// restart the actors for the purged entities - they should work as if its entity never existed
final ActorRef purgedActor1 = watch(startEntityActor(actorSystem, pubSubMediator, purgedId1));
purgedActor1.tell(getRetrieveEntityCommand(purgedId1), getRef());
expectMsgClass(getEntityNotAccessibleClass());
expectMsgClass(Duration.ofSeconds(10L), getEntityNotAccessibleClass());

final ActorRef purgedActor2 = watch(startEntityActor(actorSystem, pubSubMediator, purgedId2));
purgedActor2.tell(getRetrieveEntityCommand(purgedId2), getRef());
Expand Down Expand Up @@ -327,4 +331,12 @@ private static String prependNamespace(final String id, final String ns, final b
}
}

private static void sleep(final Duration duration) {
try {
TimeUnit.MILLISECONDS.sleep(duration.toMillis());
} catch (final Exception e) {
throw new CompletionException(e);
}
}

}

0 comments on commit cba015e

Please sign in to comment.