Skip to content

Commit

Permalink
[#964] fix PoliciesServiceGlobalCommandRegistryTest and PoliciesRootA…
Browse files Browse the repository at this point in the history
…ctorTest.

Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Feb 15, 2021
1 parent 60e710d commit fa4e016
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Expand Up @@ -71,7 +71,7 @@ private PoliciesRootActor(final PoliciesConfig policiesConfig,

// Start distributed data replicator even though it is not used for now.
// TODO: use the DistributedSub for notification publication
PolicyNotificationPubSubFactory.of(actorSystem).startDistributedPub();
PolicyNotificationPubSubFactory.of(getContext(), actorSystem).startDistributedPub();

final Props policySupervisorProps = PolicySupervisorActor.props(pubSubMediator, snapshotAdapter);

Expand Down
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.ditto.services.models.policies.commands.sudo.SudoRetrievePolicy;
import org.eclipse.ditto.services.models.streaming.SudoStreamPids;
import org.eclipse.ditto.services.utils.health.RetrieveHealth;
import org.eclipse.ditto.services.utils.pubsub.api.PublishSignal;
import org.eclipse.ditto.services.utils.test.GlobalCommandRegistryTestCases;
import org.eclipse.ditto.signals.commands.cleanup.CleanupPersistence;
import org.eclipse.ditto.signals.commands.common.Shutdown;
Expand Down Expand Up @@ -48,6 +49,7 @@ public PoliciesServiceGlobalCommandRegistryTest() {
CleanupPersistence.class,
RetrieveHealth.class,
PurgeEntities.class,
PublishSignal.class,

// added due to ditto-model-placeholders
CreateSubscription.class,
Expand Down
Expand Up @@ -56,7 +56,8 @@ static DittoProtocolSubImpl of(final ActorSystem system, final DistributedAcks d
LiveSignalPubSubFactory.of(system, distributedAcks).startDistributedSub();
final DistributedSub twinEventSub =
ThingEventPubSubFactory.readSubjectsOnly(system, distributedAcks).startDistributedSub();
final DistributedSub policyNotificationSub = PolicyNotificationPubSubFactory.of(system).startDistributedSub();
final DistributedSub policyNotificationSub =
PolicyNotificationPubSubFactory.of(system, system).startDistributedSub();
return new DittoProtocolSubImpl(liveSignalSub, twinEventSub, policyNotificationSub, distributedAcks);
}

Expand Down
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.ditto.services.utils.pubsub.extractors.AckExtractor;
import org.eclipse.ditto.signals.notifications.policies.PolicyNotification;

import akka.actor.ActorRefFactory;
import akka.actor.ActorSystem;

/**
Expand All @@ -28,18 +29,19 @@ public final class PolicyNotificationPubSubFactory extends AbstractPubSubFactory
AckExtractor.of(PolicyNotification::getEntityId, PolicyNotification::getDittoHeaders);

@SuppressWarnings({"unchecked"})
private PolicyNotificationPubSubFactory(final ActorSystem actorSystem) {
super(actorSystem, actorSystem, (Class<PolicyNotification<?>>) (Object) PolicyNotification.class,
private PolicyNotificationPubSubFactory(final ActorRefFactory actorRefFactory, final ActorSystem actorSystem) {
super(actorRefFactory, actorSystem, (Class<PolicyNotification<?>>) (Object) PolicyNotification.class,
new PolicyNotificationTopicExtractor(), PROVIDER, ACK_EXTRACTOR, DistributedAcks.empty());
}

/**
* Create a pubsub factory for thing events ignoring shard ID topics.
*
* @param actorRefFactory the factory with which to create the sub-supervisor actor.l
* @param system the actor system.
* @return the thing event pub-sub factory.
*/
public static PolicyNotificationPubSubFactory of(final ActorSystem system) {
return new PolicyNotificationPubSubFactory(system);
public static PolicyNotificationPubSubFactory of(final ActorRefFactory actorRefFactory, final ActorSystem system) {
return new PolicyNotificationPubSubFactory(actorRefFactory, system);
}
}

0 comments on commit fa4e016

Please sign in to comment.