org.junit.jupiter.api.extension.TestTemplateInvocationContext Java Examples

The following examples show how to use org.junit.jupiter.api.extension.TestTemplateInvocationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: doma   Author: domaframework   File: EntityProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #2
Source Project: doma   Author: domaframework   File: EntityProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> annotatedClass, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(annotatedClass),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #3
Source Project: doma   Author: domaframework   File: EntityProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #4
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new CriteriaGeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #5
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new CriteriaGeneratedClassNameParameterResolver(compilationUnit, "Q", ""),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #6
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #7
Source Project: doma   Author: domaframework   File: MetamodelOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new CriteriaGeneratedClassNameParameterResolver(compilationUnit, PREFIX, SUFFIX),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #8
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #9
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> annotatedClass, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(annotatedClass),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #10
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      invocationContext(Outer_nonStaticInner.class, Message.DOMA4415),
      invocationContext(Outer_nonPublicInner.class, Message.DOMA4415),
      invocationContext(Outer_nonPublicMiddle.class, Message.DOMA4415),
      invocationContext(
          LombokValueStaticConstructor.class,
          Message.DOMA4423,
          "-Adoma.lombok.Value=" + Value.class.getName()),
      invocationContext(
          LombokAllArgsConstructorStaticName.class,
          Message.DOMA4424,
          "-Adoma.lombok.AllArgsConstructor=" + AllArgsConstructor.class.getName()),
      invocationContext(
          LombokAllArgsConstructorAccess_private.class,
          Message.DOMA4425,
          "-Adoma.lombok.AllArgsConstructor=" + AllArgsConstructor.class.getName()),
      invocationContext(
          LombokAllArgsConstructorAccess_none.class,
          Message.DOMA4427,
          "-Adoma.lombok.AllArgsConstructor=" + AllArgsConstructor.class.getName()),
      invocationContext(Outer__illegalName.class, Message.DOMA4417));
}
 
Example #11
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #12
Source Project: doma   Author: domaframework   File: DaoProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(Class<?> clazz, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new ResourceParameterResolver(clazz),
          new GeneratedClassNameParameterResolver(clazz),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #13
Source Project: doma   Author: domaframework   File: SqlTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #14
Source Project: doma   Author: domaframework   File: SingletonConfigProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #15
Source Project: doma   Author: domaframework   File: DomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(compilationUnit),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #16
Source Project: doma   Author: domaframework   File: DomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> annotatedClass, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(annotatedClass),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #17
Source Project: doma   Author: domaframework   File: DomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #18
Source Project: doma   Author: domaframework   File: ExternalDomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> compilationUnit, Class<?> externalDomainClass) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return compilationUnit.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(compilationUnit),
          new ResourceParameterResolver(compilationUnit),
          new GeneratedClassNameParameterResolver(externalDomainClass, true));
    }
  };
}
 
Example #19
Source Project: doma   Author: domaframework   File: ExternalDomainProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
private TestTemplateInvocationContext invocationContext(
    Class<?> clazz, Message message, String... options) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz),
          new SimpleParameterResolver(message),
          new SimpleParameterResolver(options));
    }
  };
}
 
Example #20
Source Project: java-cloudant   Author: cloudant   File: HttpProxyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts
        (ExtensionContext context) {

    // AFAICT there is no way to instruct HttpURLConnection to connect via SSL to a
    // proxy server - so for now we just test an unencrypted proxy.
    // Note this is independent of the SSL tunnelling to an https server and influences
    // only requests between client and proxy. With an https server client requests are
    // tunnelled directly to the https server, other than the original HTTP CONNECT
    // request. The reason for using a SSL proxy would be to encrypt proxy auth creds
    // but it appears this scenario is not readily supported.
    // TODO is better to list all of these explicitly or not?
    return Stream.of(
            invocationContext(true, false, true, true),
            invocationContext(true, false, true, false),
            invocationContext(true, false, false, true),
            // see also https://github.com/cloudant/java-cloudant/issues/423 - these
            // tests current fail regardless of ordering
            //invocationContext(true, false, false, false),
            //invocationContext(false, false, true, true),
            invocationContext(false, false, true, false),
            invocationContext(false, false, false, true),
            invocationContext(false, false, false, false));
}
 
Example #21
@Override
protected Stream<TestTemplateInvocationContext> provideInvocationContexts(ExtensionContext context,
        TEST_ANNOTATION annotation) {
    Method testMethod = context.getRequiredTestMethod();

    DataProviderResolverContext dataProviderResolverContext = getDataProviderResolverContext(context, annotation);
    List<Method> dataProviderMethods = findDataProviderMethods(dataProviderResolverContext);

    checkArgument(dataProviderMethods.size() > 0,
            String.format("Could not find a dataprovider for test '%s' using resolvers '%s'.", testMethod,
                    dataProviderResolverContext.getResolverClasses()));

    return dataProviderMethods.stream().flatMap(dpm -> {
        DATAPROVIDER_ANNOTATION dataProviderAnnotation = dpm.getAnnotation(dataProviderAnnotationClass);
        boolean cacheDataProviderResult = cacheDataProviderResult(dataProviderAnnotation);

        Object data = invokeDataProviderMethodToRetrieveData(dpm, cacheDataProviderResult, context);

        return convertData(testMethod, data, getConverterContext(dataProviderAnnotation))
                .map(d -> (TestTemplateInvocationContext) new DataProviderInvocationContext(testMethod, d,
                        getDisplayNameContext(dataProviderAnnotation)));
    });
}
 
Example #22
Source Project: taskana   Author: Taskana   File: JaasExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  List<WithAccessId> accessIds =
      AnnotationSupport.findRepeatableAnnotations(context.getElement(), WithAccessId.class);
  Store store = getStore(context);
  return accessIds.stream()
      .peek(a -> store.put(ACCESS_IDS_STORE_KEY, a))
      .map(JaasExtensionInvocationContext::new);
}
 
Example #23
Source Project: component-runtime   Author: Talend   File: EnvironmentsExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(final ExtensionContext context) {
    final String format = findAnnotation(context.getRequiredTestMethod(), EnvironmentalTest.class).get().format();
    return new EnvironmentsConfigurationParser(context.getRequiredTestClass())
            .stream()
            .map(e -> new EnvironmentalContext(e,
                    format
                            .replace("${displayName}", context.getDisplayName())
                            .replace("${environment}", DecoratingEnvironmentProvider.class.cast(e).getName()),
                    createComponentExtension(context)));
}
 
Example #24
Source Project: nomulus   Author: google   File: DualDatabaseTestInvocationContextProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      createInvocationContext("Test Datastore", TransactionManagerFactory::ofyTm),
      createInvocationContext("Test PostgreSQL", TransactionManagerFactory::jpaTm));
}
 
Example #25
Source Project: nomulus   Author: google   File: DualDatabaseTestInvocationContextProvider.java    License: Apache License 2.0 5 votes vote down vote up
private TestTemplateInvocationContext createInvocationContext(
    String name, Supplier<? extends TransactionManager> tmSupplier) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return name;
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return ImmutableList.of(new DatabaseSwitchInvocationContext(tmSupplier));
    }
  };
}
 
Example #26
Source Project: sarl   Author: sarl   File: ResourceSetGlobalCompilationUnitExtension.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
	final ResourceSetGlobalCompilationContext ctx = getOrCreateCompilationContext(context);
	final Method meth = context.getRequiredTestMethod();
	ctx.setCurrentMethod(meth.getName());
	return Stream.of(new DynamicContext(meth.getName()));
}
 
Example #27
Source Project: doma   Author: domaframework   File: MetamodelTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      invocationContext(Worker.class, Message.DOMA4455),
      invocationContext(Salesman.class, Message.DOMA4455));
}
 
Example #28
Source Project: doma   Author: domaframework   File: EmbeddableProcessorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      invocationContext(Address.class),
      invocationContext(NotTopLevel.class, NotTopLevel.Address.class),
      invocationContext(AbstractEmbeddable.class),
      invocationContext(LombokValue.class, "-Adoma.lombok.Value=" + Value.class.getName()),
      invocationContext(
          LombokAllArgsConstructor.class,
          "-Adoma.lombok.AllArgsConstructor=" + AllArgsConstructor.class.getName()),
      invocationContext(Derived.class));
}
 
Example #29
Source Project: doma   Author: domaframework   File: DaoProcessorTest.java    License: Apache License 2.0 5 votes vote down vote up
private TestTemplateInvocationContext invocationContext(Class<?> clazz, Message message) {
  return new TestTemplateInvocationContext() {
    @Override
    public String getDisplayName(int invocationIndex) {
      return clazz.getSimpleName();
    }

    @Override
    public List<Extension> getAdditionalExtensions() {
      return Arrays.asList(
          new SimpleParameterResolver(clazz), new SimpleParameterResolver(message));
    }
  };
}
 
Example #30
Source Project: doma   Author: domaframework   File: SqlTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      invocationContext(AnnotationConflictDao.class, Message.DOMA4444),
      invocationContext(ModifySqlFileElementConflictDao.class, Message.DOMA4445),
      invocationContext(BatchModifySqlFileElementConflictDao.class, Message.DOMA4445),
      invocationContext(DefaultMethodConflictDao.class, Message.DOMA4446));
}