Java 类org.junit.jupiter.api.extension.ExtensionContext.Namespace 实例源码
项目:junit-dataprovider
文件:AbstractUseDataProviderArgumentProviderTest.java
@Test
void testInvokeDataProviderMethodToRetrieveDataShouldThrowParameterResolutionExceptionIfDataProviderInvocationThrows()
throws Exception {
// Given:
Method dataProviderMethod = this.getClass().getDeclaredMethod(
"testInvokeDataProviderMethodToRetrieveDataShouldThrowParameterResolutionExceptionIfDataProviderInvocationThrows");
when(extensionContext.getRoot()).thenReturn(extensionContext);
when(extensionContext.getStore(any(Namespace.class))).thenReturn(store);
// When:
Exception result = assertThrows(ParameterResolutionException.class,
() -> underTest.invokeDataProviderMethodToRetrieveData(dataProviderMethod, true, extensionContext));
// Then:
assertThat(result).hasMessageMatching("Exception while invoking dataprovider method '.*': .*");
}
项目:qpp-conversion-tool
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
}
else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:mastering-junit5
文件:MockitoExtension.java
private Object getMock(Parameter parameter,
ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext
.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName,
key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(),
key -> mock(mockType));
}
}
项目:mastering-junit5
文件:MockitoExtension.java
private Object getMock(Parameter parameter,
ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext
.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName,
key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(),
key -> mock(mockType));
}
}
项目:intellij-spring-assistant
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:open-kilda
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
}
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
项目:selenium-jupiter
文件:MockitoExtension.java
private Object getMock(Parameter parameter,
ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext
.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName,
key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(),
key -> mock(mockType));
}
}
项目:Mastering-Software-Testing-with-JUnit-5
文件:MockitoExtension.java
private Object getMock(Parameter parameter,
ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext
.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName,
key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(),
key -> mock(mockType));
}
}
项目:Mastering-Software-Testing-with-JUnit-5
文件:MockitoExtension.java
private Object getMock(Parameter parameter,
ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext
.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName,
key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(),
key -> mock(mockType));
}
}
项目:junit-extensions
文件:WatcherExtensionMetaTest.java
@BeforeEach
public void prepare() {
MockitoAnnotations.initMocks(this);
when(extensionContext.getStore(Namespace.create(WatcherExtension.class, extensionContext)))
.thenReturn(store);
sut = new WatcherExtension(logger);
}
项目:junit-extensions
文件:TemporaryFolderExtensionMetaTest.java
@BeforeEach
public void prepare() {
MockitoAnnotations.initMocks(this);
when(extensionContext.getStore(
Namespace.create(TemporaryFolderExtension.class, extensionContext)))
.thenReturn(store);
}
项目:vertx-acme4j
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
}
else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:logbook-kai-plugins
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
}
else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:kata-botwars
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:Lyrics
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:Lyrics
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:triplea
文件:MockitoExtension.java
private Object getMock(final Parameter parameter, final ExtensionContext extensionContext) {
final Class<?> mockType = parameter.getType();
final Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
final String mockName = getMockName(parameter);
return (mockName != null)
? mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName))
: mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
项目:junit5-samples
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
}
else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:GitToolBox
文件:MockitoExtension.java
private Object getMock(Parameter parameter, ExtensionContext extensionContext) {
Class<?> mockType = parameter.getType();
Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType));
String mockName = getMockName(parameter);
if (mockName != null) {
return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName));
} else {
return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType));
}
}
项目:mastering-junit5
文件:TimingExtension.java
private Store getStore(ExtensionContext context) {
return context.getStore(Namespace.create(getClass(), context));
}
项目:paper
文件:EnglishLocaleExtension.java
private ExtensionContext.Store getStore(ExtensionContext context) {
return context.getStore(Namespace.create("de.aliceice.paper", getClass().getName()));
}
项目:Mastering-Software-Testing-with-JUnit-5
文件:TimingExtension.java
private Store getStore(ExtensionContext context) {
return context.getStore(Namespace.create(getClass(), context));
}
项目:junit5-demo
文件:TimingExtension.java
private Store getStore(ExtensionContext context) {
return context.getStore(Namespace.create(context.getRequiredTestMethod()));
}
项目:pdfcompare
文件:TempDirectoryExtension.java
private Namespace localNamespace(ExtensionContext context) {
return Namespace.create(TempDirectoryExtension.class, context);
}
项目:datagen
文件:DatagenUtils.java
private static Store getMethodStore(ExtensionContext context) {
Optional<Method> m = context.getTestMethod();
if (m.isPresent()) return context.getStore(Namespace.create(DatagenUtils.class, m.get()));
return null;
}
项目:datagen
文件:DatagenUtils.java
private static Store getClassStore(ExtensionContext context) {
Optional<Class<?>> c = context.getTestClass();
if (c.isPresent()) return context.getStore(Namespace.create(DatagenUtils.class, c.get()));
return null;
}
项目:GitToolBox
文件:ExtensionContextParamResolver.java
ExtensionContextParamResolver(Namespace namespace, Class<?> first, Class<?>... others) {
this(namespace, new EmptyResolver(), first, others);
}
项目:GitToolBox
文件:ExtensionContextParamResolver.java
ExtensionContextParamResolver(Namespace namespace, ParameterResolver parent, Class<?> first, Class<?>... others) {
this.namespace = namespace;
this.parent = parent;
this.parameterTypes = Lists.asList(first, others);
}
项目:junit-extensions
文件:WatcherExtension.java
/**
* Creates a {@link Namespace} in which {@link ExtensionContext}s are stored on creation for post
* execution restoration. Storing data in a custom namespace prevents accidental cross pollination
* of data between extensions and between different invocations within the lifecycle of a single
* extension.
*
* @param extensionContext the <em>context</em> in which the current test or container is being
* executed
* @return a {@link Namespace} describing the scope for a single {@link ExtensionContext}
*/
private Namespace namespace(ExtensionContext extensionContext) {
return Namespace.create(this.getClass(), extensionContext);
}
项目:junit-extensions
文件:TemporaryFolderExtension.java
/**
* Creates a {@link Namespace} in which {@link TemporaryFolder}s are stored on creation for post
* execution destruction. Storing data in a custom namespace prevents accidental cross pollination
* of data between extensions and between different invocations within the lifecycle of a single
* extension.
*
* @param extensionContext the <em>context</em> in which the current test or container is being
* executed
* @return a {@link Namespace} describing the scope for a single {@link TemporaryFolder}
*/
private Namespace namespace(ExtensionContext extensionContext) {
return Namespace.create(this.getClass(), extensionContext);
}
项目:junit-extensions
文件:SystemPropertyExtension.java
/**
* Creates a {@link Namespace} in which {@link RestoreContext}s are stored on creation for post
* execution restoration. Storing data in a custom namespace prevents accidental cross pollination
* of data between extensions and between different invocations within the lifecycle of a single
* extension.
*
* @param extensionContext the <em>context</em> in which the current test or container is being
* executed
* @return a {@link Namespace} describing the scope for a single {@link RestoreContext}
*/
private Namespace namespace(ExtensionContext extensionContext) {
return Namespace.create(this.getClass(), extensionContext);
}