本文整理汇总了Java中com.google.common.truth.Subject类的典型用法代码示例。如果您正苦于以下问题:Java Subject类的具体用法?Java Subject怎么用?Java Subject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Subject类属于com.google.common.truth包,在下文中一共展示了Subject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertToolchainResolution
import com.google.common.truth.Subject; //导入依赖的package包/类
private Subject<DefaultSubject, Object> assertToolchainResolution(
Label toolchainType,
Iterable<ConstraintValueInfo> targetConstraints,
Iterable<ConstraintValueInfo> execConstraints,
ImmutableList<DeclaredToolchainInfo> toolchains)
throws Exception {
PlatformInfo execPlatform =
PlatformInfo.builder()
.setLabel(makeLabel("//platform:exec"))
.addConstraints(execConstraints)
.build();
PlatformInfo targetPlatform =
PlatformInfo.builder()
.setLabel(makeLabel("//platform:target"))
.addConstraints(targetConstraints)
.build();
DeclaredToolchainInfo resolvedToolchain =
ToolchainResolutionFunction.resolveConstraints(
toolchainType, execPlatform, targetPlatform, toolchains, null);
return assertThat(resolvedToolchain);
}
示例2: assertCompleted
import com.google.common.truth.Subject; //导入依赖的package包/类
static Subject<?, Object> assertCompleted(CompletionStage<?> stage)
throws InterruptedException, ExecutionException {
assertThat(stage.toCompletableFuture().isDone()).isTrue();
Object result = stage.toCompletableFuture().get();
assertThat(stage.toCompletableFuture().isCancelled()).isFalse();
assertThat(stage.toCompletableFuture().isCompletedExceptionally()).isFalse();
return assertThat(result);
}
示例3: assertAfterCompleted
import com.google.common.truth.Subject; //导入依赖的package包/类
static Subject<?, Object> assertAfterCompleted(CompletionStage<?> stage)
throws InterruptedException, ExecutionException {
Object result = stage.toCompletableFuture().get();
assertThat(stage.toCompletableFuture().isDone()).isTrue();
assertThat(stage.toCompletableFuture().isCancelled()).isFalse();
assertThat(stage.toCompletableFuture().isCompletedExceptionally()).isFalse();
return assertThat(result);
}
示例4: assertThat
import com.google.common.truth.Subject; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <S extends Subject<S, E>, E> ListSubject<S, E> assertThat(
List<E> list, Function<E, S> elementAssertThatFunction) {
// The ListSubjectFactory always returns ListSubjects.
// -> Casting is appropriate.
return (ListSubject<S, E>)
assertAbout(new ListSubjectFactory<>(elementAssertThatFunction)).that(list);
}
示例5: providedValue
import com.google.common.truth.Subject; //导入依赖的package包/类
/**
* Allows for assertions on the value provided by this provider.
*
* <p>The value provided by a checked provider is the object returned by a call to {@link
* CheckedProvider#get}
*
* @return a {@link Subject} for asserting against the return value of {@link CheckedProvider#get}
*/
public Subject<?, Object> providedValue() {
P provider = actual();
T got;
try {
got = provider.get();
} catch (Exception e) {
failWithRawMessageAndCause(
String.format("checked provider <%s> threw an exception", provider), e);
return ignoreCheck().that(new Object());
}
return check().withMessage("value provided by <%s>", provider).that(got);
}
示例6: classNames
import com.google.common.truth.Subject; //导入依赖的package包/类
static Subject.Factory<ClassNameSubject, String> classNames(Path basePath) {
return new Subject.Factory<ClassNameSubject, String>() {
@Override
public ClassNameSubject createSubject(FailureMetadata metadata, String actual) {
return new ClassNameSubject(metadata, basePath, actual);
}
};
}
示例7: assertThat
import com.google.common.truth.Subject; //导入依赖的package包/类
private static Subject<DefaultSubject, Object> assertThat(Object subject) {
return Truth.assertThat(subject);
}
示例8: assertThat
import com.google.common.truth.Subject; //导入依赖的package包/类
public static Subject<DefaultSubject, Object> assertThat(@Nullable Object target) {
return assert_().that(target);
}
示例9: booleanFormulasOf
import com.google.common.truth.Subject; //导入依赖的package包/类
/**
* Use this for checking assertions about BooleanFormulas (given the corresponding solver) with
* Truth: <code>assert_().about(booleanFormulasOf(context)).that(formula).is...()</code>.
*/
public static Subject.Factory<BooleanFormulaSubject, BooleanFormula> booleanFormulasOf(
final SolverContext context) {
return (metadata, formula) -> new BooleanFormulaSubject(metadata, formula, context);
}
示例10: proverEnvironments
import com.google.common.truth.Subject; //导入依赖的package包/类
/**
* Use this for checking assertions about ProverEnvironments with Truth: <code>
* assert_().about(proverEnvironments()).that(stack).is...()</code>.
*/
public static Subject.Factory<ProverEnvironmentSubject, BasicProverEnvironment<?>>
proverEnvironments() {
return (metadata, formula) -> new ProverEnvironmentSubject(metadata, formula);
}
示例11: assertThat
import com.google.common.truth.Subject; //导入依赖的package包/类
public static <S extends Subject<S, ? super T>, T> OptionalSubject<S, T> assertThat(
Optional<T> optional, Function<? super T, ? extends S> elementAssertThatFunction) {
OptionalSubjectFactory<S, T> optionalSubjectFactory =
new OptionalSubjectFactory<>(elementAssertThatFunction);
return assertAbout(optionalSubjectFactory).that(optional);
}
示例12: types
import com.google.common.truth.Subject; //导入依赖的package包/类
public static Subject.Factory<TypeSubject, TypeI> types() {
return TypeSubject::new;
}
示例13: checkedProviders
import com.google.common.truth.Subject; //导入依赖的package包/类
public static <T, P extends CheckedProvider<T>>
Subject.Factory<CheckedProviderSubject<T, P>, P> checkedProviders() {
return new CheckedProviderSubjectFactory<>();
}
示例14: deadline
import com.google.common.truth.Subject; //导入依赖的package包/类
public static Subject.Factory<DeadlineSubject, Deadline> deadline() {
return deadlineFactory;
}
示例15: paths
import com.google.common.truth.Subject; //导入依赖的package包/类
/** Returns the subject factory for doing assertions on paths. */
public static Subject.Factory<PathSubject, Path> paths() {
return new PathSubjectFactory();
}