protected boolean isServiceInCache(final String serviceId, final long id) {
        return servicesManager.getAllServices()
            .stream()
            .anyMatch(r -> Optional.ofNullable(serviceId).map(s -> r.getServiceId().equals(s)).orElseGet(() -> r.getId() == id));
    }
Attempts to make sure service lookup operations
are valid based on the existing cache, specially if load
takes a long time.

@throws Exception in case threads cannot be started or joined.
core/cas-server-core-services/src/test/java/org/apereo/cas/services/AbstractServicesManagerTests.java