private StateStore getStateStore(final String name,
                                     final boolean throwForBuiltInStores) {
        if (task != null) {
            final StateStore stateStore = ((ProcessorContextImpl) task.processorContext()).stateManager().getStore(name);
            if (stateStore != null) {
                if (throwForBuiltInStores) {
                    throwIfBuiltInStore(stateStore);
                }
                return stateStore;
            }
        }

        if (globalStateManager != null) {
            final StateStore stateStore = globalStateManager.getStore(name);
            if (stateStore != null) {
                if (throwForBuiltInStores) {
                    throwIfBuiltInStore(stateStore);
                }
                return stateStore;
            }

        }

        return null;
    }
Get the {@link StateStore} with the given name.
The store can be a "regular" or global store.
<p>
Should be used for custom stores only.
For built-in stores, the corresponding typed methods like {@link #getKeyValueStore(String)} should be used.
<p>
This is often useful in test cases to pre-populate the store before the test case instructs the topology to
{@link TestInputTopic#pipeInput(TestRecord) process an input message}, and/or to check the store afterward.

@param name the name of the store
@return the state store, or {@code null} if no store has been registered with the given name
@throws IllegalArgumentException if the store is a built-in store like {@link KeyValueStore},
{@link WindowStore}, or {@link SessionStore}

@see #getAllStateStores()
@see #getKeyValueStore(String)
@see #getTimestampedKeyValueStore(String)
@see #getVersionedKeyValueStore(String)
@see #getWindowStore(String)
@see #getTimestampedWindowStore(String)
@see #getSessionStore(String)
streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriver.java