Skip to content

Commit

Permalink
Apply some code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Nov 9, 2023
1 parent 36c0d8f commit ee1315e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/extensions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ Often, the state can be kept locally in the `intercept(IMethodInvocation)` metho

Spock 2.4 adds a new `org.spockframework.runtime.extension.IStore` interface that allows extensions to store and retrieve data during the execution of a specification.

The store is available from the `org.spockframework.runtime.extension.IMethodInvocation` interface via the `getStore(IStore.Namespace namespace)` method. Currently, it is possible to access the store directly from an extension, only via a registering an <<#interceptors,interceptor>>.
The store is available from the `org.spockframework.runtime.extension.IMethodInvocation` interface via the `getStore(IStore.Namespace namespace)` method. Currently, it is not possible to access the store directly from an extension, only via registering an <<#interceptors,interceptor>>.

The stores are hierarchical and follow roughly the same hierarchy as shown in the <<spock-interceptors>> figure. The hierarchy is as follows:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void runParameterizedFeature(SpockExecutionContext context, ParameterizedFeature
return;
}

context = context.withChildStore();
context = context.withChildStoreProvider();
FeatureInfo feature = context.getCurrentFeature();
try (IDataIterator dataIterator = new DataIteratorFactory(supervisor).createFeatureDataIterator(context)) {
IIterationRunner iterationRunner = createIterationRunner(context, childExecutor);
Expand All @@ -52,7 +52,7 @@ void runParameterizedFeature(SpockExecutionContext context, ParameterizedFeature
} catch (Exception e) {
ExceptionUtil.sneakyThrow(e);
} finally {
runCloseContextStore(context, MethodKind.CLEANUP);
runCloseContextStoreProvider(context, MethodKind.CLEANUP);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ SpockExecutionContext createSpecInstance(SpockExecutionContext context, boolean
}


context = context.withChildStore().withCurrentInstance(instance);
context = context.withChildStoreProvider().withCurrentInstance(instance);
getSpecificationContext(context).setCurrentSpec(context.getSpec());
if (shared) {
context = context.withSharedInstance(instance);
Expand Down Expand Up @@ -151,7 +151,7 @@ public void doRunSetupSpec(SpockExecutionContext context, SpecInfo spec) {

void runCleanupSpec(SpockExecutionContext context) {
runCleanupSpec(context.withCurrentInstance(context.getSharedInstance()), context.getSpec());
runCloseContextStore(context, MethodKind.CLEANUP_SPEC);
runCloseContextStoreProvider(context, MethodKind.CLEANUP_SPEC);
}

private void runCleanupSpec(SpockExecutionContext context, SpecInfo spec) {
Expand Down Expand Up @@ -328,7 +328,7 @@ void runFeatureMethod(SpockExecutionContext context) {

void runCleanup(SpockExecutionContext context) {
runCleanup(context, context.getSpec());
runCloseContextStore(context, MethodKind.CLEANUP);
runCloseContextStoreProvider(context, MethodKind.CLEANUP);
}

private void runCleanup(SpockExecutionContext context, SpecInfo spec) {
Expand Down Expand Up @@ -373,12 +373,12 @@ private void runIterationCleanups(SpockExecutionContext context) {
}
}

void runCloseContextStore(SpockExecutionContext context, MethodKind kind) {
MethodInfo methodInfo = createMethodInfoForCloseContextStore(context, kind);
void runCloseContextStoreProvider(SpockExecutionContext context, MethodKind kind) {
MethodInfo methodInfo = createMethodInfoForCloseContextStoreProvider(context, kind);
invokeRaw(context, context.getStoreProvider(), methodInfo);
}

private MethodInfo createMethodInfoForCloseContextStore(SpockExecutionContext context, MethodKind kind) {
private MethodInfo createMethodInfoForCloseContextStoreProvider(SpockExecutionContext context, MethodKind kind) {
MethodInfo result = new MethodInfo((Object target, Object... arguments) -> {
context.getStoreProvider().close();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public SpockExecutionContext withParentId(UniqueId uniqueId) {
return clone().setParentId(uniqueId);
}

public SpockExecutionContext withChildStore() {
return clone().setStoreProvider(storeProvider.createChildStore());
public SpockExecutionContext withChildStoreProvider() {
return clone().setStoreProvider(storeProvider.createChildStoreProvider());
}

public Specification getSharedInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static StoreProvider createRootStore() {
return new StoreProvider(newBackendStore(null));
}

public StoreProvider createChildStore() {
public StoreProvider createChildStoreProvider() {
return new StoreProvider(newBackendStore(backend));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ default <V> V getOrComputeIfAbsent(Class<V> type) {

/**
* A {@code Namespace} is used to provide a <em>scope</em> for data saved by
* extensions within a {@link IStore}.
* extensions within an {@link IStore}.
*
* <p>Storing data in custom namespaces allows extensions to avoid accidentally
* mixing data between extensions or across different invocations within the
Expand Down

0 comments on commit ee1315e

Please sign in to comment.