Merge "Migrate off AtomicLongMapSubject, which is being removed."

This commit is contained in:
Alice Kober-Sotzek
2019-06-17 12:17:57 +00:00
committed by Gerrit Code Review
4 changed files with 19 additions and 42 deletions

View File

@@ -37,17 +37,12 @@ public class ChangeIndexedCounter implements ChangeIndexedListener {
countsByChange.clear();
}
long getCount(ChangeInfo info) {
return countsByChange.get(info._number);
}
public void assertReindexOf(ChangeInfo info) {
assertReindexOf(info, 1);
}
public void assertReindexOf(ChangeInfo info, int expectedCount) {
assertThat(getCount(info)).isEqualTo(expectedCount);
assertThat(countsByChange).hasSize(1);
public void assertReindexOf(ChangeInfo info, long expectedCount) {
assertThat(countsByChange.asMap()).containsExactly(info._number, expectedCount);
clear();
}
}

View File

@@ -3291,10 +3291,6 @@ public class AccountIT extends AbstractDaemonTest {
countsByAccount.clear();
}
long getCount(Account.Id accountId) {
return countsByAccount.get(accountId.get());
}
void assertReindexOf(TestAccount testAccount) {
assertReindexOf(testAccount, 1);
}
@@ -3303,19 +3299,18 @@ public class AccountIT extends AbstractDaemonTest {
assertReindexOf(Account.id(accountInfo._accountId), 1);
}
void assertReindexOf(TestAccount testAccount, int expectedCount) {
assertThat(getCount(testAccount.id())).isEqualTo(expectedCount);
assertThat(countsByAccount).hasSize(1);
void assertReindexOf(TestAccount testAccount, long expectedCount) {
assertThat(countsByAccount.asMap()).containsExactly(testAccount.id().get(), expectedCount);
clear();
}
void assertReindexOf(Account.Id accountId, int expectedCount) {
assertThat(getCount(accountId)).isEqualTo(expectedCount);
void assertReindexOf(Account.Id accountId, long expectedCount) {
assertThat(countsByAccount.asMap()).containsEntry(accountId.get(), expectedCount);
countsByAccount.remove(accountId.get());
}
void assertNoReindex() {
assertThat(countsByAccount).isEmpty();
assertThat(countsByAccount.asMap()).isEmpty();
}
}
@@ -3339,23 +3334,17 @@ public class AccountIT extends AbstractDaemonTest {
countsByProjectRefs.clear();
}
long getCount(String projectRef) {
return countsByProjectRefs.get(projectRef);
}
void assertRefUpdateFor(String... projectRefs) {
Map<String, Integer> expectedRefUpdateCounts = new HashMap<>();
Map<String, Long> expectedRefUpdateCounts = new HashMap<>();
for (String projectRef : projectRefs) {
expectedRefUpdateCounts.put(projectRef, 1);
expectedRefUpdateCounts.put(projectRef, 1L);
}
assertRefUpdateFor(expectedRefUpdateCounts);
}
void assertRefUpdateFor(Map<String, Integer> expectedProjectRefUpdateCounts) {
for (Map.Entry<String, Integer> e : expectedProjectRefUpdateCounts.entrySet()) {
assertThat(getCount(e.getKey())).isEqualTo(e.getValue());
}
assertThat(countsByProjectRefs).hasSize(expectedProjectRefUpdateCounts.size());
void assertRefUpdateFor(Map<String, Long> expectedProjectRefUpdateCounts) {
assertThat(countsByProjectRefs.asMap())
.containsExactlyEntriesIn(expectedProjectRefUpdateCounts);
clear();
}
}

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.acceptance.api.group;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.acceptance.GitUtil.deleteRef;
import static com.google.gerrit.acceptance.GitUtil.fetch;
@@ -31,6 +30,7 @@ import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -1564,24 +1564,18 @@ public class GroupsIT extends AbstractDaemonTest {
countsByGroup.clear();
}
long getCount(AccountGroup.UUID groupUuid) {
return countsByGroup.get(groupUuid.get());
}
void assertReindexOf(AccountGroup.UUID groupUuid) {
assertReindexOf(ImmutableList.of(groupUuid));
}
void assertReindexOf(List<AccountGroup.UUID> groupUuids) {
for (AccountGroup.UUID groupUuid : groupUuids) {
assertWithMessage(groupUuid.get()).that(getCount(groupUuid)).isEqualTo(1);
}
assertThat(countsByGroup).hasSize(groupUuids.size());
Map<String, Long> expected = groupUuids.stream().collect(toMap(u -> u.get(), u -> 1L));
assertThat(countsByGroup.asMap()).containsExactlyEntriesIn(expected);
clear();
}
void assertNoReindex() {
assertThat(countsByGroup).isEmpty();
assertThat(countsByGroup.asMap()).isEmpty();
}
}
}

View File

@@ -723,14 +723,13 @@ public class ProjectIT extends AbstractDaemonTest {
assertReindexOf(projectName, 1);
}
void assertReindexOf(String projectName, int expectedCount) {
assertThat(getCount(projectName)).isEqualTo(expectedCount);
assertThat(countsByProject).hasSize(1);
void assertReindexOf(String projectName, long expectedCount) {
assertThat(countsByProject.asMap()).containsExactly(projectName, expectedCount);
clear();
}
void assertNoReindex() {
assertThat(countsByProject).isEmpty();
assertThat(countsByProject.asMap()).isEmpty();
}
void assertReindexExactly(ImmutableMap<String, Long> expected) {