ActorUtils { public void setDatastoreContext(final DatastoreContextFactory contextFactory) { this.datastoreContext = contextFactory.getBaseDatastoreContext(); setCachedProperties(); updated = true; if (shardManager != null) { shardManager.tell(contextFactory, ActorRef.noSender()); } } ActorUtils(final ActorSystem actorSystem, final ActorRef shardManager,
            final ClusterWrapper clusterWrapper, final Configuration configuration);  ActorUtils(final ActorSystem actorSystem, final ActorRef shardManager,
            final ClusterWrapper clusterWrapper, final Configuration configuration,
            final DatastoreContext datastoreContext, final PrimaryShardInfoFutureCache primaryShardInfoCache); DatastoreContext getDatastoreContext(); ActorSystem getActorSystem(); ActorRef getShardManager(); ActorSelection actorSelection(final String actorPath); ActorSelection actorSelection(final ActorPath actorPath); void setSchemaContext(final EffectiveModelContext schemaContext); void setDatastoreContext(final DatastoreContextFactory contextFactory); EffectiveModelContext getSchemaContext(); Future<PrimaryShardInfo> findPrimaryShardAsync(final String shardName); Optional<ActorRef> findLocalShard(final String shardName); Future<ActorRef> findLocalShardAsync(final String shardName); @SuppressWarnings("checkstyle:IllegalCatch") Object executeOperation(final ActorRef actor, final Object message); @SuppressWarnings("checkstyle:IllegalCatch") Object executeOperation(final ActorSelection actor, final Object message); Future<Object> executeOperationAsync(final ActorRef actor, final Object message, final Timeout timeout); Future<Object> executeOperationAsync(final ActorSelection actor, final Object message,
            final Timeout timeout); Future<Object> executeOperationAsync(final ActorSelection actor, final Object message); void sendOperationAsync(final ActorSelection actor, final Object message); @SuppressWarnings("checkstyle:IllegalCatch") void shutdown(); ClusterWrapper getClusterWrapper(); MemberName getCurrentMemberName(); void broadcast(final Function<Short, Object> messageSupplier, final Class<?> messageClass); FiniteDuration getOperationDuration(); Timeout getOperationTimeout(); boolean isPathLocal(final String path); Timer getOperationTimer(final String operationName); Timer getOperationTimer(final String dataStoreType, final String operationName); String getDataStoreName(); double getTxCreationLimit(); void acquireTxCreationPermit(); Timeout getTransactionCommitOperationTimeout(); ExecutionContext getClientDispatcher(); String getNotificationDispatcherPath(); Configuration getConfiguration(); ShardStrategyFactory getShardStrategyFactory(); PrimaryShardInfoFutureCache getPrimaryShardInfoCache(); static final String BOUNDED_MAILBOX; static final String COMMIT; }
@Test public void testSetDatastoreContext() { final TestKit testKit = new TestKit(getSystem()); ActorUtils actorUtils = new ActorUtils(getSystem(), testKit.getRef(), mock(ClusterWrapper.class), mock(Configuration.class), DatastoreContext.newBuilder() .operationTimeoutInSeconds(5).shardTransactionCommitTimeoutInSeconds(7).build(), new PrimaryShardInfoFutureCache()); assertEquals("getOperationDuration", 5, actorUtils.getOperationDuration().toSeconds()); assertEquals("getTransactionCommitOperationTimeout", 7, actorUtils.getTransactionCommitOperationTimeout().duration().toSeconds()); DatastoreContext newContext = DatastoreContext.newBuilder().operationTimeoutInSeconds(6) .shardTransactionCommitTimeoutInSeconds(8).build(); DatastoreContextFactory mockContextFactory = mock(DatastoreContextFactory.class); Mockito.doReturn(newContext).when(mockContextFactory).getBaseDatastoreContext(); actorUtils.setDatastoreContext(mockContextFactory); testKit.expectMsgClass(Duration.ofSeconds(5), DatastoreContextFactory.class); Assert.assertSame("getDatastoreContext", newContext, actorUtils.getDatastoreContext()); assertEquals("getOperationDuration", 6, actorUtils.getOperationDuration().toSeconds()); assertEquals("getTransactionCommitOperationTimeout", 8, actorUtils.getTransactionCommitOperationTimeout().duration().toSeconds()); }