Skip to content

Commit 2d8ae59

Browse files
authored
Promote beta features (#2278)
Promote `@Beta` features that existed before 2.4
1 parent c103586 commit 2d8ae59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+186
-281
lines changed

spock-core/src/main/java/org/spockframework/lang/ConditionBlock.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
package org.spockframework.lang;
1616

17-
import org.spockframework.util.Beta;
18-
19-
import java.lang.annotation.*;
17+
import java.lang.annotation.ElementType;
18+
import java.lang.annotation.Retention;
19+
import java.lang.annotation.RetentionPolicy;
20+
import java.lang.annotation.Target;
2021

2122
/**
2223
* Indicates that the closure argument(s) of the annotated method are code blocks
@@ -30,7 +31,6 @@
3031
* - the annotated method is called on object of type known at compilation time (no "def").
3132
* If the annotated method is overloaded, the closure arguments of all overloads are considered code blocks.
3233
*/
33-
@Beta
3434
@Target(ElementType.METHOD)
3535
@Retention(RetentionPolicy.RUNTIME)
3636
public @interface ConditionBlock {}

spock-core/src/main/java/org/spockframework/lang/ISpecificationContext.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414

1515
package org.spockframework.lang;
1616

17+
import org.spockframework.mock.IMockController;
1718
import org.spockframework.mock.IThreadAwareMockController;
1819
import org.spockframework.runtime.extension.IStoreProvider;
1920
import org.spockframework.runtime.model.BlockInfo;
2021
import org.spockframework.runtime.model.FeatureInfo;
22+
import org.spockframework.runtime.model.IterationInfo;
2123
import org.spockframework.runtime.model.SpecInfo;
2224
import org.spockframework.util.Beta;
23-
import org.spockframework.mock.IMockController;
24-
import org.spockframework.runtime.model.IterationInfo;
2525
import org.spockframework.util.Nullable;
2626

27-
@Beta
2827
public interface ISpecificationContext extends IStoreProvider {
2928
@Nullable
3029
SpecInfo getCurrentSpec();
@@ -33,6 +32,7 @@ public interface ISpecificationContext extends IStoreProvider {
3332

3433
IterationInfo getCurrentIteration();
3534

35+
@Beta
3636
@Nullable
3737
BlockInfo getCurrentBlock();
3838

@@ -41,5 +41,6 @@ public interface ISpecificationContext extends IStoreProvider {
4141

4242
IMockController getMockController();
4343

44+
@Beta
4445
IThreadAwareMockController getThreadAwareMockController();
4546
}

spock-core/src/main/java/org/spockframework/mock/CallRealMethodResponse.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
package org.spockframework.mock;
1616

17-
import org.spockframework.util.Beta;
18-
import org.spockframework.util.ThreadSafe;
19-
2017
import java.util.function.Supplier;
2118

19+
import org.spockframework.util.ThreadSafe;
20+
2221
/**
2322
* A response strategy that delegates method calls to the real object underlying the mock (if any).
2423
*/
25-
@Beta
2624
@ThreadSafe
2725
public class CallRealMethodResponse implements IDefaultResponse {
2826
public static final CallRealMethodResponse INSTANCE = new CallRealMethodResponse();

spock-core/src/main/java/org/spockframework/mock/IMockConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package org.spockframework.mock;
22

3-
import org.spockframework.mock.runtime.IMockMaker;
43
import spock.mock.IMockMakerSettings;
5-
import org.spockframework.util.*;
64
import spock.mock.MockingApi;
75

86
import java.lang.reflect.Type;
97
import java.util.List;
108

9+
import org.spockframework.mock.runtime.IMockMaker;
10+
import org.spockframework.util.Beta;
11+
import org.spockframework.util.Nullable;
12+
1113
/**
1214
* Configuration options for mock objects. Once a mock object has been created, its configuration cannot be changed.
1315
*
@@ -19,7 +21,6 @@
1921
* {@link #getConstructorArgs()} corresponds to the {@code constructorArgs:} named argument,
2022
* {@link #isGlobal()} to the {@code global:} named argument, etc.
2123
*/
22-
@Beta
2324
public interface IMockConfiguration {
2425
/**
2526
* Returns the name of the mock object.
@@ -95,6 +96,7 @@ public interface IMockConfiguration {
9596
*
9697
* @return the custom settings to use for the creation of the mock, or {@code null}
9798
*/
99+
@Beta
98100
@Nullable
99101
IMockMakerSettings getMockMaker();
100102

spock-core/src/main/java/org/spockframework/mock/MockImplementation.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
package org.spockframework.mock;
1616

17-
import org.spockframework.util.Beta;
1817
import spock.mock.MockingApi;
1918

2019
/**
2120
* Determines how method calls are processed and matched against interactions. A mock implementation
2221
* is chosen at mock creation time, typically by selecting the appropriate {@link MockingApi} factory method.
2322
*/
24-
@Beta
2523
public enum MockImplementation {
2624
/**
2725
* A generic implementation targeting any callers. Used by the {@link MockingApi#Mock},

spock-core/src/main/java/org/spockframework/mock/MockNature.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
package org.spockframework.mock;
1616

17-
import org.spockframework.util.Beta;
1817
import spock.mock.MockingApi;
1918

2019
/**
2120
* A named set of defaults for a mock's configuration options. A mock nature is chosen at
2221
* mock creation time, typically by selecting the appropriate {@link MockingApi} factory method.
2322
*/
24-
@Beta
2523
public enum MockNature {
2624
/**
2725
* A mock object whose method calls are verified, which instantiates class-based mock objects with Objenesis,

spock-core/src/main/java/org/spockframework/mock/MockUtil.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414

1515
package org.spockframework.mock;
1616

17-
import org.spockframework.mock.runtime.*;
18-
import org.spockframework.runtime.RunContext;
19-
import org.spockframework.util.*;
2017
import spock.lang.Specification;
2118

2219
import java.lang.reflect.Type;
2320
import java.util.Map;
2421

22+
import org.spockframework.mock.runtime.CompositeMockFactory;
23+
import org.spockframework.mock.runtime.MockConfiguration;
24+
import org.spockframework.mock.runtime.MockMakerRegistry;
25+
import org.spockframework.runtime.RunContext;
26+
import org.spockframework.util.Beta;
27+
import org.spockframework.util.Nullable;
28+
2529
/**
2630
* Detects mock objects and provides information about them.
2731
*/
28-
@Beta
2932
public class MockUtil {
3033
/**
3134
* Tells whether the given object is a (Spock) mock object.
@@ -44,6 +47,7 @@ public boolean isMock(Object object) {
4447
* @param clazz the class to check
4548
* @return {@code true} if this class is a Spock static mock currently active on the current {@code Thread}
4649
*/
50+
@Beta
4751
public boolean isStaticMock(Class<?> clazz) {
4852
return getMockMakerRegistry().isStaticMock(clazz);
4953
}
@@ -75,6 +79,7 @@ public IMockObject asMock(Object object) {
7579
* @param object a mock object
7680
* @return information about the mock object or {@code null}, if the object is not a mock.
7781
*/
82+
@Beta
7883
@Nullable
7984
public IMockObject asMockOrNull(Object object) {
8085
return getMockMakerRegistry().asMockOrNull(object);
@@ -110,7 +115,6 @@ public void detachMock(Object object) {
110115
* @param classloader the classloader to use
111116
* @return the mock
112117
*/
113-
@Beta
114118
public Object createDetachedMock(@Nullable String name, Type type, MockNature nature,
115119
MockImplementation implementation, Map<String, Object> options, ClassLoader classloader) {
116120

@@ -130,7 +134,6 @@ public Object createDetachedMock(@Nullable String name, Type type, MockNature na
130134
* @param classloader the classloader to use
131135
* @return the mock
132136
*/
133-
@Beta
134137
public Object createDetachedMock(@Nullable String name, Object obj, MockNature nature,
135138
MockImplementation implementation, Map<String, Object> options, ClassLoader classloader) {
136139

spock-core/src/main/java/org/spockframework/mock/ZeroOrNullResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
package org.spockframework.mock;
1616

17-
import org.spockframework.util.*;
17+
import org.spockframework.util.ReflectionUtil;
18+
import org.spockframework.util.ThreadSafe;
1819

1920
/**
2021
* A response strategy that returns zero, false, or null, depending on the method's return type.
2122
*/
22-
@Beta
2323
@ThreadSafe
2424
public class ZeroOrNullResponse implements IDefaultResponse {
2525
public static final ZeroOrNullResponse INSTANCE = new ZeroOrNullResponse();

spock-core/src/main/java/org/spockframework/mock/runtime/MockConfiguration.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@
1414

1515
package org.spockframework.mock.runtime;
1616

17-
import org.spockframework.mock.*;
18-
import org.spockframework.util.*;
1917
import spock.mock.IMockMakerSettings;
2018

2119
import java.lang.reflect.Type;
22-
import java.util.*;
20+
import java.util.List;
21+
import java.util.Map;
22+
23+
import org.spockframework.mock.IDefaultResponse;
24+
import org.spockframework.mock.IMockConfiguration;
25+
import org.spockframework.mock.MockImplementation;
26+
import org.spockframework.mock.MockNature;
27+
import org.spockframework.util.Beta;
28+
import org.spockframework.util.GenericTypeReflectorUtil;
29+
import org.spockframework.util.Nullable;
2330

2431
import static java.util.Collections.emptyList;
2532
import static java.util.Collections.singletonList;
2633

27-
@Beta
2834
public class MockConfiguration implements IMockConfiguration {
2935
private final String name;
3036
private final Type type;
@@ -123,6 +129,7 @@ public boolean isUseObjenesis() {
123129
return useObjenesis;
124130
}
125131

132+
@Beta
126133
@Override
127134
public IMockMakerSettings getMockMaker() {
128135
return mockMakerSettings;

spock-core/src/main/java/org/spockframework/mock/runtime/MockCreationSettings.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616

1717
package org.spockframework.mock.runtime;
1818

19-
import org.spockframework.mock.IMockConfiguration;
20-
import org.spockframework.mock.MockNature;
21-
import org.spockframework.util.Beta;
22-
import org.spockframework.util.Nullable;
2319
import spock.mock.IMockMakerSettings;
2420

2521
import java.util.ArrayList;
2622
import java.util.Collections;
2723
import java.util.List;
2824

25+
import org.spockframework.mock.IMockConfiguration;
26+
import org.spockframework.mock.MockNature;
27+
import org.spockframework.util.Beta;
28+
import org.spockframework.util.Nullable;
29+
2930
import static java.util.Objects.requireNonNull;
3031
import static org.spockframework.util.ObjectUtil.uncheckedCast;
3132

32-
@Beta
3333
public class MockCreationSettings implements IMockMaker.IMockCreationSettings {
3434

3535
private final IMockMakerSettings mockMakerSettings;
@@ -47,6 +47,7 @@ public static MockCreationSettings settingsFromMockConfiguration(IMockConfigurat
4747
return new MockCreationSettings(mockConfig.getMockMaker(), mockConfig.getType(), mockConfig.getNature(), new ArrayList<>(mockConfig.getAdditionalInterfaces()), mockConfig.getConstructorArgs(), interceptor, classLoader, mockConfig.isUseObjenesis(), false);
4848
}
4949

50+
@Beta
5051
public static MockCreationSettings settingsFromMockConfigurationForStaticMock(IMockConfiguration mockConfig, IProxyBasedMockInterceptor interceptor, ClassLoader classLoader) {
5152
return new MockCreationSettings(mockConfig.getMockMaker(), mockConfig.getType(), mockConfig.getNature(), Collections.emptyList(), null, interceptor, classLoader, false, true);
5253
}

0 commit comments

Comments
 (0)