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 File: ExternalDomainProcessorTest.java    From doma with 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 #2
Source File: HttpProxyTest.java    From java-cloudant with 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 #3
Source File: UseDataProviderInvocationContextProvider.java    From junit-dataprovider with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: EntityProcessorTest.java    From doma with 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 #5
Source File: EntityProcessorTest.java    From doma with 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 #6
Source File: EntityProcessorTest.java    From doma with 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 File: MetamodelTest.java    From doma with 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 #8
Source File: MetamodelTest.java    From doma with 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 #9
Source File: MetamodelOptionTest.java    From doma with 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 #10
Source File: EmbeddableProcessorTest.java    From doma with 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 #11
Source File: EmbeddableProcessorTest.java    From doma with 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 #12
Source File: EmbeddableProcessorTest.java    From doma with 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 #13
Source File: DaoProcessorTest.java    From doma with 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 #14
Source File: ExternalDomainProcessorTest.java    From doma with 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 File: SqlTest.java    From doma with 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 #16
Source File: SingletonConfigProcessorTest.java    From doma with 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 #17
Source File: EmbeddableProcessorTest.java    From doma with 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 #18
Source File: DomainProcessorTest.java    From doma with 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 #19
Source File: DomainProcessorTest.java    From doma with 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 #20
Source File: DomainProcessorTest.java    From doma with 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 #21
Source File: MetamodelTest.java    From doma with 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 #22
Source File: SqlTest.java    From doma with 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));
}
 
Example #23
Source File: DomainProcessorTest.java    From doma with Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      invocationContext(IntersectionParameterizedDomain.class),
      invocationContext(UpperBoundParameterizedDomain.class),
      invocationContext(Salary.class),
      invocationContext(InterfaceDomain.class),
      invocationContext(ObjectDomain.class),
      invocationContext(NullRejectionDomain.class),
      invocationContext(ParameterizedSalary.class),
      invocationContext(ParameterizedOfSalary.class),
      invocationContext(SpecificDomain.class),
      invocationContext(OfAbstractDomain.class),
      invocationContext(OfPrimitiveValueType.class),
      invocationContext(OfSalary.class),
      invocationContext(OfEnumDomain.class),
      invocationContext(OfJobType.class),
      invocationContext(OfPrimitiveValueDomain.class),
      invocationContext(EnumDomain.class),
      invocationContext(PackagePrivateDomain.class),
      invocationContext(Outer.class, Outer.Inner.class),
      invocationContext(Outer_deepInner.class, Outer_deepInner.Middle.Inner.class),
      invocationContext(InterfaceOuter.class, InterfaceOuter.Inner.class),
      invocationContext(VersionCheckSuppressedDomain.class, "-Adoma.version.validation=false"),
      invocationContext(LombokValue.class, "-Adoma.lombok.Value=" + Value.class.getName()),
      invocationContext(PrimitiveValueDomain.class));
}
 
Example #24
Source File: JaasExtension.java    From taskana with 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 #25
Source File: SingletonConfigProcessorTest.java    From doma with Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(
    ExtensionContext context) {
  return Stream.of(
      invocationContext(NoConfig.class, Message.DOMA4253),
      invocationContext(MethodNotFoundConfig.class, Message.DOMA4254),
      invocationContext(PublicConstructorConfig.class, Message.DOMA4256));
}
 
Example #26
Source File: DaoProcessorTest.java    From doma with 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 #27
Source File: SessionInterceptorExpiryTests.java    From java-cloudant with Apache License 2.0 5 votes vote down vote up
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts
        (ExtensionContext context) {
    return Stream.of(invocationContext(false, "/_iam_session"),
            invocationContext(false, "/_session"),
            invocationContext(true, "/_iam_session"),
            invocationContext(true, "/_session"));
}
 
Example #28
Source File: ViewPaginationTests.java    From java-cloudant with Apache License 2.0 5 votes vote down vote up
public static Iterable<TestTemplateInvocationContext> data() {

        List<TestTemplateInvocationContext> contexts = new
                ArrayList<TestTemplateInvocationContext>();
        boolean[] tf = new boolean[]{true, false};
        for (CheckPagination.Type type : CheckPagination.Type.values()) {
            for (boolean descending : tf) {
                for (boolean stateless : tf) {
                    contexts.add(ParameterProvider.invocationContext(type, descending, stateless));
                }
            }
        }
        return contexts;
    }
 
Example #29
Source File: DesignDocumentTest.java    From java-cloudant with Apache License 2.0 5 votes vote down vote up
public static Iterable<TestTemplateInvocationContext> data() {
    List<TestTemplateInvocationContext> contexts = new
            ArrayList<TestTemplateInvocationContext>();
    for (Field f : EnumSet.allOf(Field.class)) {
        contexts.add(ParameterProvider.invocationContext(f));
    }
    return contexts;
}
 
Example #30
Source File: EnvironmentsExtension.java    From component-runtime with 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)));
}