@Test
    void verifyGetInCacheAndSave() {
        val id = new PublisherIdentifier();
        val appCtx = new StaticApplicationContext();
        appCtx.refresh();
        val serviceRegistry = new InMemoryServiceRegistry(appCtx);
        val stream = casProperties.getServiceRegistry().getStream();
        val mgr = mock(DistributedCacheManager.class);
        val strategy = new DefaultRegisteredServiceReplicationStrategy(mgr, stream, id);

        val service = newService("Test");
        val object = DistributedCacheObject.<RegisteredService>builder()
            .value(service)
            .publisherIdentifier(id)
            .build();
        when(mgr.find(any())).thenReturn(Optional.of(object));

        val svc = strategy.getRegisteredServiceFromCacheIfAny(null, 1000, serviceRegistry);
        assertNotNull(svc);
        assertEquals(1, serviceRegistry.size());
    }
This is {@link DefaultRegisteredServiceReplicationStrategyTests}.

@author Misagh Moayyed
@since 6.2.0
core/cas-server-core-services-registry/src/test/java/org/apereo/cas/services/replication/DefaultRegisteredServiceReplicationStrategyTests.java