Upgrade Truth to 0.36 and adapt to deprecations
Version 0.36 deprecates SubjectFactory [1] in favor of Subject.Factory which takes FailureMetadata instead of FailureStrategy, and renames the getSubject method to createSubject. [1] https://google.github.io/truth/api/0.36/com/google/common/truth/SubjectFactory.html Change-Id: Ic8c767b3da9e936e77639856d9f02af5c9059fdd
This commit is contained in:
		@@ -709,18 +709,18 @@ maven_jar(
 | 
			
		||||
    sha1 = "4785a3c21320980282f9f33d0d1264a69040538f",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
TRUTH_VERS = "0.35"
 | 
			
		||||
TRUTH_VERS = "0.36"
 | 
			
		||||
 | 
			
		||||
maven_jar(
 | 
			
		||||
    name = "truth",
 | 
			
		||||
    artifact = "com.google.truth:truth:" + TRUTH_VERS,
 | 
			
		||||
    sha1 = "c08a7fde45e058323bcfa3f510d4fe1e2b028f37",
 | 
			
		||||
    sha1 = "7485219d2c1d341097a19382c02bde07e69ff5d2",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
maven_jar(
 | 
			
		||||
    name = "truth-java8-extension",
 | 
			
		||||
    artifact = "com.google.truth.extensions:truth-java8-extension:" + TRUTH_VERS,
 | 
			
		||||
    sha1 = "5457fdf91b1e954b070ad7f2db9bea5505da4bca",
 | 
			
		||||
    sha1 = "dcc60988c8f9a051840766ef192a2ef41e7992f1",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# When bumping the easymock version number, make sure to also move powermock to a compatible version
 | 
			
		||||
 
 | 
			
		||||
@@ -21,9 +21,8 @@ import static com.google.gerrit.extensions.api.changes.RecipientType.TO;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.Joiner;
 | 
			
		||||
import com.google.common.collect.ImmutableList;
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.common.Nullable;
 | 
			
		||||
import com.google.gerrit.extensions.api.changes.RecipientType;
 | 
			
		||||
@@ -62,18 +61,8 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
 | 
			
		||||
    gApi.projects().name(project.get()).config(conf);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<FakeEmailSenderSubject, FakeEmailSender>
 | 
			
		||||
      FAKE_EMAIL_SENDER_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<FakeEmailSenderSubject, FakeEmailSender>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public FakeEmailSenderSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, FakeEmailSender target) {
 | 
			
		||||
              return new FakeEmailSenderSubject(failureStrategy, target);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  protected static FakeEmailSenderSubject assertThat(FakeEmailSender sender) {
 | 
			
		||||
    return assertAbout(FAKE_EMAIL_SENDER_SUBJECT_FACTORY).that(sender);
 | 
			
		||||
    return assertAbout(FakeEmailSenderSubject::new).that(sender);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected void setEmailStrategy(TestAccount account, EmailStrategy strategy) throws Exception {
 | 
			
		||||
@@ -98,8 +87,8 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
 | 
			
		||||
    private Map<RecipientType, List<String>> recipients = new HashMap<>();
 | 
			
		||||
    private Set<String> accountedFor = new HashSet<>();
 | 
			
		||||
 | 
			
		||||
    FakeEmailSenderSubject(FailureStrategy failureStrategy, FakeEmailSender target) {
 | 
			
		||||
      super(failureStrategy, target);
 | 
			
		||||
    FakeEmailSenderSubject(FailureMetadata failureMetadata, FakeEmailSender target) {
 | 
			
		||||
      super(failureMetadata, target);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public FakeEmailSenderSubject notSent() {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,10 +17,9 @@ package com.google.gerrit.server.edit.tree;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.io.CharStreams;
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.extensions.restapi.RawInput;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -30,26 +29,14 @@ import java.nio.charset.StandardCharsets;
 | 
			
		||||
public class ChangeFileContentModificationSubject
 | 
			
		||||
    extends Subject<ChangeFileContentModificationSubject, ChangeFileContentModification> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<
 | 
			
		||||
          ChangeFileContentModificationSubject, ChangeFileContentModification>
 | 
			
		||||
      MODIFICATION_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<
 | 
			
		||||
              ChangeFileContentModificationSubject, ChangeFileContentModification>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public ChangeFileContentModificationSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, ChangeFileContentModification modification) {
 | 
			
		||||
              return new ChangeFileContentModificationSubject(failureStrategy, modification);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  public static ChangeFileContentModificationSubject assertThat(
 | 
			
		||||
      ChangeFileContentModification modification) {
 | 
			
		||||
    return assertAbout(MODIFICATION_SUBJECT_FACTORY).that(modification);
 | 
			
		||||
    return assertAbout(ChangeFileContentModificationSubject::new).that(modification);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private ChangeFileContentModificationSubject(
 | 
			
		||||
      FailureStrategy failureStrategy, ChangeFileContentModification modification) {
 | 
			
		||||
    super(failureStrategy, modification);
 | 
			
		||||
      FailureMetadata failureMetadata, ChangeFileContentModification modification) {
 | 
			
		||||
    super(failureMetadata, modification);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public StringSubject filePath() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,26 +16,15 @@ package com.google.gerrit.server.edit.tree;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.gerrit.truth.ListSubject;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class TreeModificationSubject extends Subject<TreeModificationSubject, TreeModification> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<TreeModificationSubject, TreeModification>
 | 
			
		||||
      TREE_MODIFICATION_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<TreeModificationSubject, TreeModification>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public TreeModificationSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, TreeModification treeModification) {
 | 
			
		||||
              return new TreeModificationSubject(failureStrategy, treeModification);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  public static TreeModificationSubject assertThat(TreeModification treeModification) {
 | 
			
		||||
    return assertAbout(TREE_MODIFICATION_SUBJECT_FACTORY).that(treeModification);
 | 
			
		||||
    return assertAbout(TreeModificationSubject::new).that(treeModification);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static ListSubject<TreeModificationSubject, TreeModification> assertThatList(
 | 
			
		||||
@@ -45,8 +34,8 @@ public class TreeModificationSubject extends Subject<TreeModificationSubject, Tr
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private TreeModificationSubject(
 | 
			
		||||
      FailureStrategy failureStrategy, TreeModification treeModification) {
 | 
			
		||||
    super(failureStrategy, treeModification);
 | 
			
		||||
      FailureMetadata failureMetadata, TreeModification treeModification) {
 | 
			
		||||
    super(failureMetadata, treeModification);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ChangeFileContentModificationSubject asChangeFileContentModification() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,28 +16,19 @@ package com.google.gerrit.extensions.client;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.IntegerSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
 | 
			
		||||
public class RangeSubject extends Subject<RangeSubject, Comment.Range> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<RangeSubject, Comment.Range> RANGE_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<RangeSubject, Comment.Range>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public RangeSubject getSubject(FailureStrategy failureStrategy, Comment.Range range) {
 | 
			
		||||
          return new RangeSubject(failureStrategy, range);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static RangeSubject assertThat(Comment.Range range) {
 | 
			
		||||
    return assertAbout(RANGE_SUBJECT_FACTORY).that(range);
 | 
			
		||||
    return assertAbout(RangeSubject::new).that(range);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private RangeSubject(FailureStrategy failureStrategy, Comment.Range range) {
 | 
			
		||||
    super(failureStrategy, range);
 | 
			
		||||
  private RangeSubject(FailureMetadata failureMetadata, Comment.Range range) {
 | 
			
		||||
    super(failureMetadata, range);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public IntegerSubject startLine() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,30 +16,20 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.truth.ListSubject;
 | 
			
		||||
 | 
			
		||||
public class CommitInfoSubject extends Subject<CommitInfoSubject, CommitInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<CommitInfoSubject, CommitInfo> COMMIT_INFO_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<CommitInfoSubject, CommitInfo>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public CommitInfoSubject getSubject(
 | 
			
		||||
            FailureStrategy failureStrategy, CommitInfo commitInfo) {
 | 
			
		||||
          return new CommitInfoSubject(failureStrategy, commitInfo);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static CommitInfoSubject assertThat(CommitInfo commitInfo) {
 | 
			
		||||
    return assertAbout(COMMIT_INFO_SUBJECT_FACTORY).that(commitInfo);
 | 
			
		||||
    return assertAbout(CommitInfoSubject::new).that(commitInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private CommitInfoSubject(FailureStrategy failureStrategy, CommitInfo commitInfo) {
 | 
			
		||||
    super(failureStrategy, commitInfo);
 | 
			
		||||
  private CommitInfoSubject(FailureMetadata failureMetadata, CommitInfo commitInfo) {
 | 
			
		||||
    super(failureMetadata, commitInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public StringSubject commit() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,31 +16,21 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.extensions.common.DiffInfo.ContentEntry;
 | 
			
		||||
import com.google.gerrit.truth.ListSubject;
 | 
			
		||||
 | 
			
		||||
public class ContentEntrySubject extends Subject<ContentEntrySubject, ContentEntry> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<ContentEntrySubject, ContentEntry> DIFF_INFO_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<ContentEntrySubject, ContentEntry>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public ContentEntrySubject getSubject(
 | 
			
		||||
            FailureStrategy failureStrategy, ContentEntry contentEntry) {
 | 
			
		||||
          return new ContentEntrySubject(failureStrategy, contentEntry);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static ContentEntrySubject assertThat(ContentEntry contentEntry) {
 | 
			
		||||
    return assertAbout(DIFF_INFO_SUBJECT_FACTORY).that(contentEntry);
 | 
			
		||||
    return assertAbout(ContentEntrySubject::new).that(contentEntry);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private ContentEntrySubject(FailureStrategy failureStrategy, ContentEntry contentEntry) {
 | 
			
		||||
    super(failureStrategy, contentEntry);
 | 
			
		||||
  private ContentEntrySubject(FailureMetadata failureMetadata, ContentEntry contentEntry) {
 | 
			
		||||
    super(failureMetadata, contentEntry);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public void isDueToRebase() {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,29 +17,20 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.ComparableSubject;
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.extensions.common.DiffInfo.ContentEntry;
 | 
			
		||||
import com.google.gerrit.truth.ListSubject;
 | 
			
		||||
 | 
			
		||||
public class DiffInfoSubject extends Subject<DiffInfoSubject, DiffInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<DiffInfoSubject, DiffInfo> DIFF_INFO_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<DiffInfoSubject, DiffInfo>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public DiffInfoSubject getSubject(FailureStrategy failureStrategy, DiffInfo diffInfo) {
 | 
			
		||||
          return new DiffInfoSubject(failureStrategy, diffInfo);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static DiffInfoSubject assertThat(DiffInfo diffInfo) {
 | 
			
		||||
    return assertAbout(DIFF_INFO_SUBJECT_FACTORY).that(diffInfo);
 | 
			
		||||
    return assertAbout(DiffInfoSubject::new).that(diffInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private DiffInfoSubject(FailureStrategy failureStrategy, DiffInfo diffInfo) {
 | 
			
		||||
    super(failureStrategy, diffInfo);
 | 
			
		||||
  private DiffInfoSubject(FailureMetadata failureMetadata, DiffInfo diffInfo) {
 | 
			
		||||
    super(failureMetadata, diffInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ListSubject<ContentEntrySubject, ContentEntry> content() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,26 +16,17 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.truth.OptionalSubject;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
public class EditInfoSubject extends Subject<EditInfoSubject, EditInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<EditInfoSubject, EditInfo> EDIT_INFO_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<EditInfoSubject, EditInfo>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public EditInfoSubject getSubject(FailureStrategy failureStrategy, EditInfo editInfo) {
 | 
			
		||||
          return new EditInfoSubject(failureStrategy, editInfo);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static EditInfoSubject assertThat(EditInfo editInfo) {
 | 
			
		||||
    return assertAbout(EDIT_INFO_SUBJECT_FACTORY).that(editInfo);
 | 
			
		||||
    return assertAbout(EditInfoSubject::new).that(editInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static OptionalSubject<EditInfoSubject, EditInfo> assertThat(
 | 
			
		||||
@@ -43,8 +34,8 @@ public class EditInfoSubject extends Subject<EditInfoSubject, EditInfo> {
 | 
			
		||||
    return OptionalSubject.assertThat(editInfoOptional, EditInfoSubject::assertThat);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private EditInfoSubject(FailureStrategy failureStrategy, EditInfo editInfo) {
 | 
			
		||||
    super(failureStrategy, editInfo);
 | 
			
		||||
  private EditInfoSubject(FailureMetadata failureMetadata, EditInfo editInfo) {
 | 
			
		||||
    super(failureMetadata, editInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public CommitInfoSubject commit() {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,28 +17,19 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.ComparableSubject;
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.IntegerSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
 | 
			
		||||
public class FileInfoSubject extends Subject<FileInfoSubject, FileInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<FileInfoSubject, FileInfo> FILE_INFO_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<FileInfoSubject, FileInfo>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public FileInfoSubject getSubject(FailureStrategy failureStrategy, FileInfo fileInfo) {
 | 
			
		||||
          return new FileInfoSubject(failureStrategy, fileInfo);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static FileInfoSubject assertThat(FileInfo fileInfo) {
 | 
			
		||||
    return assertAbout(FILE_INFO_SUBJECT_FACTORY).that(fileInfo);
 | 
			
		||||
    return assertAbout(FileInfoSubject::new).that(fileInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private FileInfoSubject(FailureStrategy failureStrategy, FileInfo fileInfo) {
 | 
			
		||||
    super(failureStrategy, fileInfo);
 | 
			
		||||
  private FileInfoSubject(FailureMetadata failureMetadata, FileInfo fileInfo) {
 | 
			
		||||
    super(failureMetadata, fileInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public IntegerSubject linesInserted() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,33 +16,22 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.extensions.client.RangeSubject;
 | 
			
		||||
 | 
			
		||||
public class FixReplacementInfoSubject
 | 
			
		||||
    extends Subject<FixReplacementInfoSubject, FixReplacementInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<FixReplacementInfoSubject, FixReplacementInfo>
 | 
			
		||||
      FIX_REPLACEMENT_INFO_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<FixReplacementInfoSubject, FixReplacementInfo>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public FixReplacementInfoSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, FixReplacementInfo fixReplacementInfo) {
 | 
			
		||||
              return new FixReplacementInfoSubject(failureStrategy, fixReplacementInfo);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  public static FixReplacementInfoSubject assertThat(FixReplacementInfo fixReplacementInfo) {
 | 
			
		||||
    return assertAbout(FIX_REPLACEMENT_INFO_SUBJECT_FACTORY).that(fixReplacementInfo);
 | 
			
		||||
    return assertAbout(FixReplacementInfoSubject::new).that(fixReplacementInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private FixReplacementInfoSubject(
 | 
			
		||||
      FailureStrategy failureStrategy, FixReplacementInfo fixReplacementInfo) {
 | 
			
		||||
    super(failureStrategy, fixReplacementInfo);
 | 
			
		||||
      FailureMetadata failureMetadata, FixReplacementInfo fixReplacementInfo) {
 | 
			
		||||
    super(failureMetadata, fixReplacementInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public StringSubject path() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,32 +16,21 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.truth.ListSubject;
 | 
			
		||||
 | 
			
		||||
public class FixSuggestionInfoSubject extends Subject<FixSuggestionInfoSubject, FixSuggestionInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<FixSuggestionInfoSubject, FixSuggestionInfo>
 | 
			
		||||
      FIX_SUGGESTION_INFO_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<FixSuggestionInfoSubject, FixSuggestionInfo>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public FixSuggestionInfoSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, FixSuggestionInfo fixSuggestionInfo) {
 | 
			
		||||
              return new FixSuggestionInfoSubject(failureStrategy, fixSuggestionInfo);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  public static FixSuggestionInfoSubject assertThat(FixSuggestionInfo fixSuggestionInfo) {
 | 
			
		||||
    return assertAbout(FIX_SUGGESTION_INFO_SUBJECT_FACTORY).that(fixSuggestionInfo);
 | 
			
		||||
    return assertAbout(FixSuggestionInfoSubject::new).that(fixSuggestionInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private FixSuggestionInfoSubject(
 | 
			
		||||
      FailureStrategy failureStrategy, FixSuggestionInfo fixSuggestionInfo) {
 | 
			
		||||
    super(failureStrategy, fixSuggestionInfo);
 | 
			
		||||
      FailureMetadata failureMetadata, FixSuggestionInfo fixSuggestionInfo) {
 | 
			
		||||
    super(failureMetadata, fixSuggestionInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public StringSubject fixId() {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,28 +17,19 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.ComparableSubject;
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import java.sql.Timestamp;
 | 
			
		||||
 | 
			
		||||
public class GitPersonSubject extends Subject<GitPersonSubject, GitPerson> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<GitPersonSubject, GitPerson> GIT_PERSON_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<GitPersonSubject, GitPerson>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public GitPersonSubject getSubject(FailureStrategy failureStrategy, GitPerson gitPerson) {
 | 
			
		||||
          return new GitPersonSubject(failureStrategy, gitPerson);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  public static GitPersonSubject assertThat(GitPerson gitPerson) {
 | 
			
		||||
    return assertAbout(GIT_PERSON_SUBJECT_FACTORY).that(gitPerson);
 | 
			
		||||
    return assertAbout(GitPersonSubject::new).that(gitPerson);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private GitPersonSubject(FailureStrategy failureStrategy, GitPerson gitPerson) {
 | 
			
		||||
    super(failureStrategy, gitPerson);
 | 
			
		||||
  private GitPersonSubject(FailureMetadata failureMetadata, GitPerson gitPerson) {
 | 
			
		||||
    super(failureMetadata, gitPerson);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ComparableSubject<?, Timestamp> creationDate() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,25 +16,16 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import java.nio.file.Path;
 | 
			
		||||
 | 
			
		||||
public class PathSubject extends Subject<PathSubject, Path> {
 | 
			
		||||
  private static final SubjectFactory<PathSubject, Path> PATH_SUBJECT_FACTORY =
 | 
			
		||||
      new SubjectFactory<PathSubject, Path>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        public PathSubject getSubject(FailureStrategy failureStrategy, Path path) {
 | 
			
		||||
          return new PathSubject(failureStrategy, path);
 | 
			
		||||
        }
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  private PathSubject(FailureStrategy failureStrategy, Path path) {
 | 
			
		||||
    super(failureStrategy, path);
 | 
			
		||||
  private PathSubject(FailureMetadata failureMetadata, Path path) {
 | 
			
		||||
    super(failureMetadata, path);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static PathSubject assertThat(Path path) {
 | 
			
		||||
    return assertAbout(PATH_SUBJECT_FACTORY).that(path);
 | 
			
		||||
    return assertAbout(PathSubject::new).that(path);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,24 +16,13 @@ package com.google.gerrit.extensions.common;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.gerrit.truth.ListSubject;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class RobotCommentInfoSubject extends Subject<RobotCommentInfoSubject, RobotCommentInfo> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<RobotCommentInfoSubject, RobotCommentInfo>
 | 
			
		||||
      ROBOT_COMMENT_INFO_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<RobotCommentInfoSubject, RobotCommentInfo>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public RobotCommentInfoSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, RobotCommentInfo robotCommentInfo) {
 | 
			
		||||
              return new RobotCommentInfoSubject(failureStrategy, robotCommentInfo);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  public static ListSubject<RobotCommentInfoSubject, RobotCommentInfo> assertThatList(
 | 
			
		||||
      List<RobotCommentInfo> robotCommentInfos) {
 | 
			
		||||
    return ListSubject.assertThat(robotCommentInfos, RobotCommentInfoSubject::assertThat)
 | 
			
		||||
@@ -41,12 +30,12 @@ public class RobotCommentInfoSubject extends Subject<RobotCommentInfoSubject, Ro
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static RobotCommentInfoSubject assertThat(RobotCommentInfo robotCommentInfo) {
 | 
			
		||||
    return assertAbout(ROBOT_COMMENT_INFO_SUBJECT_FACTORY).that(robotCommentInfo);
 | 
			
		||||
    return assertAbout(RobotCommentInfoSubject::new).that(robotCommentInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private RobotCommentInfoSubject(
 | 
			
		||||
      FailureStrategy failureStrategy, RobotCommentInfo robotCommentInfo) {
 | 
			
		||||
    super(failureStrategy, robotCommentInfo);
 | 
			
		||||
      FailureMetadata failureMetadata, RobotCommentInfo robotCommentInfo) {
 | 
			
		||||
    super(failureMetadata, robotCommentInfo);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ListSubject<FixSuggestionInfoSubject, FixSuggestionInfo> fixSuggestions() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,11 +16,10 @@ package com.google.gerrit.extensions.restapi;
 | 
			
		||||
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.PrimitiveByteArraySubject;
 | 
			
		||||
import com.google.common.truth.StringSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import com.google.gerrit.truth.OptionalSubject;
 | 
			
		||||
import java.io.ByteArrayOutputStream;
 | 
			
		||||
@@ -29,18 +28,8 @@ import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
public class BinaryResultSubject extends Subject<BinaryResultSubject, BinaryResult> {
 | 
			
		||||
 | 
			
		||||
  private static final SubjectFactory<BinaryResultSubject, BinaryResult>
 | 
			
		||||
      BINARY_RESULT_SUBJECT_FACTORY =
 | 
			
		||||
          new SubjectFactory<BinaryResultSubject, BinaryResult>() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public BinaryResultSubject getSubject(
 | 
			
		||||
                FailureStrategy failureStrategy, BinaryResult binaryResult) {
 | 
			
		||||
              return new BinaryResultSubject(failureStrategy, binaryResult);
 | 
			
		||||
            }
 | 
			
		||||
          };
 | 
			
		||||
 | 
			
		||||
  public static BinaryResultSubject assertThat(BinaryResult binaryResult) {
 | 
			
		||||
    return assertAbout(BINARY_RESULT_SUBJECT_FACTORY).that(binaryResult);
 | 
			
		||||
    return assertAbout(BinaryResultSubject::new).that(binaryResult);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static OptionalSubject<BinaryResultSubject, BinaryResult> assertThat(
 | 
			
		||||
@@ -48,8 +37,8 @@ public class BinaryResultSubject extends Subject<BinaryResultSubject, BinaryResu
 | 
			
		||||
    return OptionalSubject.assertThat(binaryResultOptional, BinaryResultSubject::assertThat);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private BinaryResultSubject(FailureStrategy failureStrategy, BinaryResult binaryResult) {
 | 
			
		||||
    super(failureStrategy, binaryResult);
 | 
			
		||||
  private BinaryResultSubject(FailureMetadata failureMetadata, BinaryResult binaryResult) {
 | 
			
		||||
    super(failureMetadata, binaryResult);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public StringSubject asString() throws IOException {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,10 +17,9 @@ package com.google.gerrit.truth;
 | 
			
		||||
import static com.google.common.base.Preconditions.checkArgument;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.IterableSubject;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.function.Function;
 | 
			
		||||
 | 
			
		||||
@@ -38,8 +37,8 @@ public class ListSubject<S extends Subject<S, E>, E> extends IterableSubject {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private ListSubject(
 | 
			
		||||
      FailureStrategy failureStrategy, List<E> list, Function<E, S> elementAssertThatFunction) {
 | 
			
		||||
    super(failureStrategy, list);
 | 
			
		||||
      FailureMetadata failureMetadata, List<E> list, Function<E, S> elementAssertThatFunction) {
 | 
			
		||||
    super(failureMetadata, list);
 | 
			
		||||
    this.elementAssertThatFunction = elementAssertThatFunction;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -71,7 +70,7 @@ public class ListSubject<S extends Subject<S, E>, E> extends IterableSubject {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static class ListSubjectFactory<S extends Subject<S, T>, T>
 | 
			
		||||
      extends SubjectFactory<IterableSubject, Iterable<?>> {
 | 
			
		||||
      implements Subject.Factory<IterableSubject, Iterable<?>> {
 | 
			
		||||
 | 
			
		||||
    private Function<T, S> elementAssertThatFunction;
 | 
			
		||||
 | 
			
		||||
@@ -81,10 +80,10 @@ public class ListSubject<S extends Subject<S, E>, E> extends IterableSubject {
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings("unchecked")
 | 
			
		||||
    @Override
 | 
			
		||||
    public ListSubject<S, T> getSubject(FailureStrategy failureStrategy, Iterable<?> objects) {
 | 
			
		||||
    public ListSubject<S, T> createSubject(FailureMetadata failureMetadata, Iterable<?> objects) {
 | 
			
		||||
      // The constructor of ListSubject only accepts lists.
 | 
			
		||||
      // -> Casting is appropriate.
 | 
			
		||||
      return new ListSubject<>(failureStrategy, (List<T>) objects, elementAssertThatFunction);
 | 
			
		||||
      return new ListSubject<>(failureMetadata, (List<T>) objects, elementAssertThatFunction);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,8 @@ package com.google.gerrit.truth;
 | 
			
		||||
import static com.google.common.truth.Truth.assertAbout;
 | 
			
		||||
 | 
			
		||||
import com.google.common.truth.DefaultSubject;
 | 
			
		||||
import com.google.common.truth.FailureStrategy;
 | 
			
		||||
import com.google.common.truth.FailureMetadata;
 | 
			
		||||
import com.google.common.truth.Subject;
 | 
			
		||||
import com.google.common.truth.SubjectFactory;
 | 
			
		||||
import com.google.common.truth.Truth;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
import java.util.function.Function;
 | 
			
		||||
@@ -47,10 +46,10 @@ public class OptionalSubject<S extends Subject<S, ? super T>, T>
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private OptionalSubject(
 | 
			
		||||
      FailureStrategy failureStrategy,
 | 
			
		||||
      FailureMetadata failureMetadata,
 | 
			
		||||
      Optional<T> optional,
 | 
			
		||||
      Function<? super T, ? extends S> valueAssertThatFunction) {
 | 
			
		||||
    super(failureStrategy, optional);
 | 
			
		||||
    super(failureMetadata, optional);
 | 
			
		||||
    this.valueAssertThatFunction = valueAssertThatFunction;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -82,7 +81,7 @@ public class OptionalSubject<S extends Subject<S, ? super T>, T>
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private static class OptionalSubjectFactory<S extends Subject<S, ? super T>, T>
 | 
			
		||||
      extends SubjectFactory<OptionalSubject<S, T>, Optional<T>> {
 | 
			
		||||
      implements Subject.Factory<OptionalSubject<S, T>, Optional<T>> {
 | 
			
		||||
 | 
			
		||||
    private Function<? super T, ? extends S> valueAssertThatFunction;
 | 
			
		||||
 | 
			
		||||
@@ -91,8 +90,9 @@ public class OptionalSubject<S extends Subject<S, ? super T>, T>
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public OptionalSubject<S, T> getSubject(FailureStrategy failureStrategy, Optional<T> optional) {
 | 
			
		||||
      return new OptionalSubject<>(failureStrategy, optional, valueAssertThatFunction);
 | 
			
		||||
    public OptionalSubject<S, T> createSubject(
 | 
			
		||||
        FailureMetadata failureMetadata, Optional<T> optional) {
 | 
			
		||||
      return new OptionalSubject<>(failureMetadata, optional, valueAssertThatFunction);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user