com.google.common.truth.Subject Java Examples

The following examples show how to use com.google.common.truth.Subject. 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: SoyFunctionsTest.java    From deploymentmanager-autogen with Apache License 2.0 5 votes vote down vote up
@CheckReturnValue
Subject hasResultThat() {
  try {
    return assertThat(callable.call());
  } catch (Exception e) {
    throw new AssertionError("Unexpected exception", e);
  }
}
 
Example #2
Source File: ZipEntrySubject.java    From bundletool with Apache License 2.0 5 votes vote down vote up
static Subject.Factory<ZipEntrySubject, ZipEntry> zipEntries(ZipFile zip) {
  return new Subject.Factory<ZipEntrySubject, ZipEntry>() {
    @Override
    public ZipEntrySubject createSubject(FailureMetadata metadata, ZipEntry actual) {
      return new ZipEntrySubject(metadata, zip, actual);
    }
  };
}
 
Example #3
Source File: FutureAssertions.java    From mug with Apache License 2.0 5 votes vote down vote up
public 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);
}
 
Example #4
Source File: FutureAssertions.java    From mug with Apache License 2.0 5 votes vote down vote up
public 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);
}
 
Example #5
Source File: ClassPathsSubject.java    From bazel with Apache License 2.0 5 votes vote down vote up
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);
    }
  };
}
 
Example #6
Source File: ToolchainContextSubject.java    From bazel with Apache License 2.0 4 votes vote down vote up
/** Static method for getting the subject factory (for use with assertAbout()). */
public static Subject.Factory<ToolchainContextSubject, ToolchainContext> toolchainContexts() {
  return TOOLCHAIN_CONTEXT_SUBJECT_FACTORY;
}
 
Example #7
Source File: IntentSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<IntentSubject, Intent> intents() {
  return IntentSubject::new;
}
 
Example #8
Source File: LocationSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<LocationSubject, Location> locations() {
  return LocationSubject::new;
}
 
Example #9
Source File: EvaluationResultSubject.java    From bazel with Apache License 2.0 4 votes vote down vote up
public Subject hasEntryThat(SkyKey key) {
  return check("get(%s)", key).that(actual.get(key));
}
 
Example #10
Source File: NodeEntrySubject.java    From bazel with Apache License 2.0 4 votes vote down vote up
public Subject hasVersionThat() {
  return check("getVersion()").that(actual.getVersion());
}
 
Example #11
Source File: NodeEntrySubject.java    From bazel with Apache License 2.0 4 votes vote down vote up
public Subject addReverseDepAndCheckIfDone(@Nullable SkyKey reverseDep)
    throws InterruptedException {
  return check("addReverseDepAndCheckIfDone()")
      .that(actual.addReverseDepAndCheckIfDone(reverseDep));
}
 
Example #12
Source File: ToolchainCollectionSubject.java    From bazel with Apache License 2.0 4 votes vote down vote up
/** Static method for getting the subject factory (for use with assertAbout()). */
public static Subject.Factory<ToolchainCollectionSubject, ToolchainCollection<?>>
    toolchainCollections() {
  return TOOLCHAIN_COLLECTION_SUBJECT_FACTORY;
}
 
Example #13
Source File: ToolchainInfoSubject.java    From bazel with Apache License 2.0 4 votes vote down vote up
public Subject getValue(String name) throws EvalException {
  return check("getValue(%s)", name).that(actual.getValue(name));
}
 
Example #14
Source File: NotificationSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<NotificationSubject, Notification> notifications() {
  return NotificationSubject::new;
}
 
Example #15
Source File: DeadlineSubject.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<DeadlineSubject, Deadline> deadline() {
  return deadlineFactory;
}
 
Example #16
Source File: PathSubject.java    From jimfs with Apache License 2.0 4 votes vote down vote up
/** Returns the subject factory for doing assertions on paths. */
public static Subject.Factory<PathSubject, Path> paths() {
  return new PathSubjectFactory();
}
 
Example #17
Source File: JavaFileObjectSubject.java    From compile-testing with Apache License 2.0 4 votes vote down vote up
/** Returns a {@link Subject.Factory} for {@link JavaFileObjectSubject}s. */
public static Subject.Factory<JavaFileObjectSubject, JavaFileObject> javaFileObjects() {
  return FACTORY;
}
 
Example #18
Source File: CompilationSubject.java    From compile-testing with Apache License 2.0 4 votes vote down vote up
/** Returns a {@link Subject.Factory} for a {@link Compilation}. */
public static Subject.Factory<CompilationSubject, Compilation> compilations() {
  return FACTORY;
}
 
Example #19
Source File: NotificationActionSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<NotificationActionSubject, Action> notificationActions() {
  return NotificationActionSubject::new;
}
 
Example #20
Source File: PendingIntentSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<PendingIntentSubject, PendingIntent> pendingIntents() {
  return PendingIntentSubject::new;
}
 
Example #21
Source File: DeadlineSubject.java    From grpc-nebula-java with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<DeadlineSubject, Deadline> deadline() {
  return deadlineFactory;
}
 
Example #22
Source File: BundleSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public <T extends Parcelable, SubjectT extends Subject> SubjectT parcelableAsType(
    String key, Subject.Factory<SubjectT, T> subjectFactory) {
  return check("getParcelable(%s)", key).about(subjectFactory).that(actual.<T>getParcelable(key));
}
 
Example #23
Source File: BundleSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<BundleSubject, Bundle> bundles() {
  return BundleSubject::new;
}
 
Example #24
Source File: ParcelableSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static <T extends Parcelable> Subject.Factory<ParcelableSubject<T>, T> parcelables() {
  return ParcelableSubject<T>::new;
}
 
Example #25
Source File: MotionEventSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<MotionEventSubject, MotionEvent> motionEvents() {
  return MotionEventSubject::new;
}
 
Example #26
Source File: PointerPropertiesSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<PointerPropertiesSubject, PointerProperties> pointerProperties() {
  return PointerPropertiesSubject::new;
}
 
Example #27
Source File: PointerCoordsSubject.java    From android-test with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<PointerCoordsSubject, PointerCoords> pointerCoords() {
  return PointerCoordsSubject::new;
}
 
Example #28
Source File: TextDiffSubject.java    From nomulus with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<TextDiffSubject, ImmutableList<String>> textFactory() {
  return TEXT_DIFF_SUBJECT_TEXT_FACTORY;
}
 
Example #29
Source File: LogDataSubject.java    From flogger with Apache License 2.0 4 votes vote down vote up
/**
 * Asserts about the log site of the log record.
 */
public Subject logSite() {
  return check("getLogSite()").that(actual.getLogSite());
}
 
Example #30
Source File: LogDataSubject.java    From flogger with Apache License 2.0 4 votes vote down vote up
public static Subject.Factory<LogDataSubject, LogData> logData() {
  return LOG_DATA_SUBJECT_FACTORY;
}