Replace BinaryPredicate subclasses with lambdas
Change-Id: I9cced3e0ec0c3002cdca090321cab4cfeee5d547
This commit is contained in:
@@ -47,7 +47,6 @@ import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.common.truth.Correspondence;
|
||||
import com.google.common.truth.Correspondence.BinaryPredicate;
|
||||
import com.google.common.util.concurrent.AtomicLongMap;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@@ -2743,12 +2742,9 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
private static Correspondence<GroupInfo, String> getGroupToNameCorrespondence() {
|
||||
return Correspondence.from(
|
||||
new BinaryPredicate<GroupInfo, String>() {
|
||||
@Override
|
||||
public boolean apply(GroupInfo actualGroup, String expectedName) {
|
||||
String groupName = actualGroup == null ? null : actualGroup.name;
|
||||
return Objects.equals(groupName, expectedName);
|
||||
}
|
||||
(actualGroup, expectedName) -> {
|
||||
String groupName = actualGroup == null ? null : actualGroup.name;
|
||||
return Objects.equals(groupName, expectedName);
|
||||
},
|
||||
"has name");
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.truth.Correspondence;
|
||||
import com.google.common.truth.Correspondence.BinaryPredicate;
|
||||
import com.google.common.util.concurrent.AtomicLongMap;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
@@ -1395,12 +1394,9 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
|
||||
private static Correspondence<AccountInfo, String> getAccountToUsernameCorrespondence() {
|
||||
return Correspondence.from(
|
||||
new BinaryPredicate<AccountInfo, String>() {
|
||||
@Override
|
||||
public boolean apply(AccountInfo actualAccount, String expectedName) {
|
||||
String username = actualAccount == null ? null : actualAccount.username;
|
||||
return Objects.equals(username, expectedName);
|
||||
}
|
||||
(actualAccount, expectedName) -> {
|
||||
String username = actualAccount == null ? null : actualAccount.username;
|
||||
return Objects.equals(username, expectedName);
|
||||
},
|
||||
"has username");
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.truth.Correspondence;
|
||||
import com.google.common.truth.Correspondence.BinaryPredicate;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
@@ -651,13 +650,8 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
private static Correspondence<RelatedChangeAndCommitInfo, String>
|
||||
getRelatedChangeToStatusCorrespondence() {
|
||||
return Correspondence.from(
|
||||
new BinaryPredicate<RelatedChangeAndCommitInfo, String>() {
|
||||
@Override
|
||||
public boolean apply(
|
||||
RelatedChangeAndCommitInfo relatedChangeAndCommitInfo, String status) {
|
||||
return Objects.equals(relatedChangeAndCommitInfo.status, status);
|
||||
}
|
||||
},
|
||||
(relatedChangeAndCommitInfo, status) ->
|
||||
Objects.equals(relatedChangeAndCommitInfo.status, status),
|
||||
"has status");
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,6 @@ import static com.google.common.truth.Truth8.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.truth.Correspondence;
|
||||
import com.google.common.truth.Correspondence.BinaryPredicate;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.extensions.api.groups.GroupInput;
|
||||
@@ -615,32 +614,26 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
||||
|
||||
private static Correspondence<AccountInfo, Account.Id> getAccountToIdCorrespondence() {
|
||||
return Correspondence.from(
|
||||
new BinaryPredicate<AccountInfo, Account.Id>() {
|
||||
@Override
|
||||
public boolean apply(AccountInfo actualAccount, Account.Id expectedId) {
|
||||
Account.Id accountId =
|
||||
Optional.ofNullable(actualAccount)
|
||||
.map(account -> account._accountId)
|
||||
.map(Account.Id::new)
|
||||
.orElse(null);
|
||||
return Objects.equals(accountId, expectedId);
|
||||
}
|
||||
(actualAccount, expectedId) -> {
|
||||
Account.Id accountId =
|
||||
Optional.ofNullable(actualAccount)
|
||||
.map(account -> account._accountId)
|
||||
.map(Account.Id::new)
|
||||
.orElse(null);
|
||||
return Objects.equals(accountId, expectedId);
|
||||
},
|
||||
"has ID");
|
||||
}
|
||||
|
||||
private static Correspondence<GroupInfo, AccountGroup.UUID> getGroupToUuidCorrespondence() {
|
||||
return Correspondence.from(
|
||||
new BinaryPredicate<GroupInfo, AccountGroup.UUID>() {
|
||||
@Override
|
||||
public boolean apply(GroupInfo actualGroup, AccountGroup.UUID expectedUuid) {
|
||||
AccountGroup.UUID groupUuid =
|
||||
Optional.ofNullable(actualGroup)
|
||||
.map(group -> group.id)
|
||||
.map(AccountGroup.UUID::new)
|
||||
.orElse(null);
|
||||
return Objects.equals(groupUuid, expectedUuid);
|
||||
}
|
||||
(actualGroup, expectedUuid) -> {
|
||||
AccountGroup.UUID groupUuid =
|
||||
Optional.ofNullable(actualGroup)
|
||||
.map(group -> group.id)
|
||||
.map(AccountGroup.UUID::new)
|
||||
.orElse(null);
|
||||
return Objects.equals(groupUuid, expectedUuid);
|
||||
},
|
||||
"has UUID");
|
||||
}
|
||||
|
Reference in New Issue
Block a user