• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParameterResolutionException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.junit.jupiter.api.extension.ParameterResolutionException的典型用法代码示例。如果您正苦于以下问题:Java ParameterResolutionException类的具体用法?Java ParameterResolutionException怎么用?Java ParameterResolutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParameterResolutionException类属于org.junit.jupiter.api.extension包,在下文中一共展示了ParameterResolutionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolveParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
        throws ParameterResolutionException {
    Object argument = arguments[parameterContext.getIndex()];
    Parameter parameter = parameterContext.getParameter();
    Optional<ConvertWith> annotation = AnnotationUtils.findAnnotation(parameter, ConvertWith.class);
    // @formatter:off
    ArgumentConverter argumentConverter = annotation.map(ConvertWith::value)
            .map(clazz -> (ArgumentConverter) ReflectionUtils.newInstance(clazz))
            .map(converter -> AnnotationConsumerInitializer.initialize(parameter, converter))
            .orElse(DefaultArgumentConverter.INSTANCE);
    // @formatter:on
    try {
        return argumentConverter.convert(argument, parameterContext);
    } catch (Exception ex) {
        throw new ParameterResolutionException("参数转换出错:" + parameter.getType().getName(),
                ex);
    }
}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:20,代码来源:AutoTestParameterResolver.java


示例2: resolveParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public Object resolveParameter(ParameterContext parameterContext,
    ExtensionContext extensionContext)
    throws ParameterResolutionException {
  List<ParameterFactory> validFactories =
      getSupportedFactories(parameterContext.getParameter()).collect(toList());

  if (validFactories.size() > 1) {
    throw new ParameterResolutionException(
        String.format("Too many factories: %s for parameter: %s",
            validFactories,
            parameterContext.getParameter()));
  }

  return Iterables.getOnlyElement(validFactories)
      .getParameterValue(parameterContext.getParameter());
}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:18,代码来源:MockitoExtension.java


示例3: resolve

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
//  public AbstractVaadinPageObject resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
  public AbstractVaadinPageObject resolve(ParameterContext parameterContext, ExtensionContext extensionContext)
      throws ParameterResolutionException {

    Supplier<WebDriver> webDriverSupplier = webdriver().apply(extensionContext);

    Class<?> pageObject = parameterContext.getParameter().getType();
    try {
      Constructor<?> constructor =
          pageObject.getConstructor(WebDriver.class);
      return AbstractVaadinPageObject.class.cast(constructor.newInstance(webDriverSupplier.get()));
    } catch (NoSuchMethodException
        | IllegalAccessException
        | InstantiationException
        | InvocationTargetException e) {
      e.printStackTrace();
      throw new ParameterResolutionException("was not able to create PageObjectInstance ", e);
    }
  }
 
开发者ID:Java-Publications,项目名称:vaadin-016-helloworld-14,代码行数:21,代码来源:PageObjectExtension.java


示例4: init

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
public void init() throws ParameterResolutionException {
  server = mock(ServerContext.class);
  request = mock(Request.class);
  session = mock(Session.class);

  when(request.getServerContext()).thenReturn(server);
  when(request.getSession()).thenReturn(session);
  when(session.getId()).thenReturn("localhost:12345");

  MockitoAnnotations.initMocks(target);

  try {
    command = target.getClass().getAnnotation(CommandUnderTest.class).value().newInstance();
  } catch (InstantiationException | IllegalAccessException e) {
    throw new ParameterResolutionException("error", e);
  }
}
 
开发者ID:tonivade,项目名称:resp-server,代码行数:18,代码来源:CommandRule.java


示例5: when

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@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 '.*': .*");
}
 
开发者ID:TNG,项目名称:junit-dataprovider,代码行数:18,代码来源:AbstractUseDataProviderArgumentProviderTest.java


示例6: resolveParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    // we did our checks in supportsParameter() method, now we can do simple resolution
    if (getContainerFromStore(extensionContext) != null) {
        List<Annotation> qualifiers = resolveQualifiers(parameterContext, getContainerFromStore(extensionContext).getBeanManager());
        return getContainerFromStore(extensionContext)
            .select(parameterContext.getParameter().getType(), qualifiers.toArray(new Annotation[qualifiers.size()])).get();
    }
    return null;
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:11,代码来源:WeldJunit5Extension.java


示例7: supportsParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    // if weld container isn't up yet or if its not Method, we don't resolve it
    if (getContainerFromStore(extensionContext) == null || (!(parameterContext.getDeclaringExecutable() instanceof Method))) {
        return false;
    }
    List<Annotation> qualifiers = resolveQualifiers(parameterContext, getContainerFromStore(extensionContext).getBeanManager());
    // if we require explicit parameter injection (via global settings or annotation) and there are no qualifiers we don't resolve it
    if ((getExplicitInjectionInfoFromStore(extensionContext) || (methodRequiresExplicitParamInjection(parameterContext))) && qualifiers.isEmpty()) {
        return false;
    } else {
        return getContainerFromStore(extensionContext).select(parameterContext.getParameter().getType(), qualifiers.toArray(new Annotation[qualifiers.size()]))
            .isResolvable();
    }
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:16,代码来源:WeldJunit5Extension.java


示例8: classNotFound

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(type = ParameterResolutionException.class),
    @Cause(type = ArgumentConversionException.class),
    @Cause(type = ClassNotFoundException.class)
})
@ParameterizedTest
@ValueSource(strings = "123ClassDoesNotExist")
void classNotFound(@ConvertWith(ClassArgumentConverter.class) Class<?> clazz) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:9,代码来源:UsageExampleTests.java


示例9: badParameterType

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(type = ParameterResolutionException.class),
    @Cause(type = ArgumentConversionException.class, message = "Invalid parameter type")
})
@ParameterizedTest
@ValueSource(strings = "java.lang.Object")
void badParameterType(@ConvertWith(ClassArgumentConverter.class) String clazz) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:8,代码来源:UsageExampleTests.java


示例10: wrongClass

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(type = ParameterResolutionException.class),
    @Cause(
        type = ArgumentConversionException.class,
        message = "java.lang.Class<java.util.List> is not assignable to"
            + " java.lang.Class<java.util.Collection<?>>"
    )
})
@ParameterizedTest
@ValueSource(strings = "java.util.List")
void wrongClass(@ConvertWith(ClassArgumentConverter.class) Class<Collection<?>> clazz) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:12,代码来源:UsageExampleTests.java


示例11: badLowerBound

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(type = ParameterResolutionException.class),
    @Cause(type = ArgumentConversionException.class, message = "is not assignable to")
})
@ParameterizedTest
@ValueSource(strings = "java.util.List")
void badLowerBound(
    @ConvertWith(ClassArgumentConverter.class) Class<? super Collection<?>> clazz) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:9,代码来源:UsageExampleTests.java


示例12: badUpperBound

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(type = ParameterResolutionException.class),
    @Cause(type = ArgumentConversionException.class, message = "is not assignable to")
})
@ParameterizedTest
@ValueSource(strings = "java.lang.Object")
void badUpperBound(
    @ConvertWith(ClassArgumentConverter.class) Class<? extends Collection<?>> clazz) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:9,代码来源:UsageExampleTests.java


示例13: supportsParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public boolean supportsParameter(ParameterContext parameterContext,
    ExtensionContext extensionContext)
    throws ParameterResolutionException {
  Parameter parameter = parameterContext.getParameter();
  if (getBindingAnnotations(parameter).size() > 1) {
    return false;
  }

  Key<?> key = getKey(
      extensionContext.getTestClass(),
      parameter);
  Optional<Injector> optInjector = getInjectorForParameterResolution(extensionContext);
  return optInjector.map(injector -> injector.getExistingBinding(key)).isPresent();
}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:16,代码来源:GuiceExtension.java


示例14: resolveParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public Object resolveParameter(ParameterContext parameterContext,
    ExtensionContext extensionContext)
    throws ParameterResolutionException {
  Parameter parameter = parameterContext.getParameter();
  Key<?> key = getKey(extensionContext.getTestClass(), parameter);
  Injector injector = getInjectorForParameterResolution(extensionContext)
      .orElseThrow(() ->
          new ParameterResolutionException(
              String.format(
                  "Could not create injector for: %s It has no annotated element.",
                  extensionContext.getDisplayName())));

  return injector.getInstance(key);
}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:16,代码来源:GuiceExtension.java


示例15: moduleWithoutZeroArgConstructor

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(
        type = ParameterResolutionException.class,
        message = "Could not find a suitable constructor"
    ),
    @Cause(type = NoSuchMethodException.class, message = "BadModule1.<init>()")
})
@Test
@IncludeModule(BadModule1.class)
void moduleWithoutZeroArgConstructor(String string) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:11,代码来源:GuiceExtensionTest.java


示例16: moduleConstructorThrowsException

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@ExpectFailure({
    @Cause(
        type = ParameterResolutionException.class,
        message = "constructor threw an exception"),
    @Cause(type = InvocationTargetException.class),
    @Cause(type = IllegalArgumentException.class, message = BadModule2.MESSAGE)
})
@Test
@IncludeModule(BadModule2.class)
void moduleConstructorThrowsException(String string) {}
 
开发者ID:JeffreyFalgout,项目名称:junit5-extensions,代码行数:11,代码来源:GuiceExtensionTest.java


示例17: resolveParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public ApplicationConfiguration resolveParameter(
    ParameterContext parameterContext,
    ExtensionContext extensionContext
) throws ParameterResolutionException {
    return getConfiguration();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:8,代码来源:ApplicationConfigurationResolver.java


示例18: resolveParameter

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public FilesLocator resolveParameter(
    ParameterContext parameterContext,
    ExtensionContext extensionContext
) throws ParameterResolutionException {
    if (applicationFilesLocator == null) {
        applicationFilesLocator = new ScenarioFilesLocator(null);
    }

    return applicationFilesLocator;
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:12,代码来源:FilesLocatorResolver.java


示例19: createTempDirectory

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
private Path createTempDirectory(final String parentPath, ExtensionContext context) {
    try {
        if (parentPath.length() > 0) {
            return Files.createTempDirectory(Paths.get(parentPath), getDirName(context));
        } else {
            return Files.createTempDirectory(getDirName(context));
        }
    } catch (IOException e) {
        throw new ParameterResolutionException("Could not create temp directory", e);
    }
}
 
开发者ID:red6,项目名称:pdfcompare,代码行数:12,代码来源:TempDirectoryExtension.java


示例20: resolve

import org.junit.jupiter.api.extension.ParameterResolutionException; //导入依赖的package包/类
@Override
public Object resolve(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    if (extensionContext.getTestClass().isPresent()) {
        CasePack pack = extensionContext.getTestClass().get().getAnnotation(CasePack.class);
        return pack.value();
    }
    return null;
}
 
开发者ID:MegafonWebLab,项目名称:histone-java2,代码行数:9,代码来源:StringParamResolver.java



注:本文中的org.junit.jupiter.api.extension.ParameterResolutionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MethodResponse类代码示例发布时间:2022-05-21
下一篇:
Java IRuntimeConfig类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap