Merge "Only return an ID on a test account/group creation"
This commit is contained in:
@@ -1487,12 +1487,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
assertNotifyTo(expected.email, expected.fullName);
|
assertNotifyTo(expected.email, expected.fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNotifyTo(
|
protected void assertNotifyTo(String expectedEmail, String expectedFullname) {
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount expected) {
|
|
||||||
assertNotifyTo(expected.preferredEmail().orElse(null), expected.fullname().orElse(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertNotifyTo(String expectedEmail, String expectedFullname) {
|
|
||||||
Address expectedAddress = new Address(expectedFullname, expectedEmail);
|
Address expectedAddress = new Address(expectedFullname, expectedEmail);
|
||||||
assertThat(sender.getMessages()).hasSize(1);
|
assertThat(sender.getMessages()).hasSize(1);
|
||||||
Message m = sender.getMessages().get(0);
|
Message m = sender.getMessages().get(0);
|
||||||
@@ -1506,11 +1501,6 @@ public abstract class AbstractDaemonTest {
|
|||||||
assertNotifyCc(expected.emailAddress);
|
assertNotifyCc(expected.emailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNotifyCc(
|
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount expected) {
|
|
||||||
assertNotifyCc(expected.preferredEmail().orElse(null), expected.fullname().orElse(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void assertNotifyCc(String expectedEmail, String expectedFullname) {
|
protected void assertNotifyCc(String expectedEmail, String expectedFullname) {
|
||||||
Address expectedAddress = new Address(expectedFullname, expectedEmail);
|
Address expectedAddress = new Address(expectedFullname, expectedEmail);
|
||||||
assertNotifyCc(expectedAddress);
|
assertNotifyCc(expectedAddress);
|
||||||
@@ -1533,13 +1523,10 @@ public abstract class AbstractDaemonTest {
|
|||||||
assertThat(m.headers().get("Cc").isEmpty()).isTrue();
|
assertThat(m.headers().get("Cc").isEmpty()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNotifyBcc(
|
protected void assertNotifyBcc(String expectedEmail, String expectedFullName) {
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount expected) {
|
|
||||||
assertThat(sender.getMessages()).hasSize(1);
|
assertThat(sender.getMessages()).hasSize(1);
|
||||||
Message m = sender.getMessages().get(0);
|
Message m = sender.getMessages().get(0);
|
||||||
assertThat(m.rcpt())
|
assertThat(m.rcpt()).containsExactly(new Address(expectedFullName, expectedEmail));
|
||||||
.containsExactly(
|
|
||||||
new Address(expected.fullname().orElse(null), expected.preferredEmail().orElse(null)));
|
|
||||||
assertThat(m.headers().get("To").isEmpty()).isTrue();
|
assertThat(m.headers().get("To").isEmpty()).isTrue();
|
||||||
assertThat(m.headers().get("Cc").isEmpty()).isTrue();
|
assertThat(m.headers().get("Cc").isEmpty()).isTrue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public interface AccountOperations {
|
|||||||
* <p>Example:
|
* <p>Example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* TestAccount createdAccount = accountOperations
|
* Account.Id createdAccountId = accountOperations
|
||||||
* .newAccount()
|
* .newAccount()
|
||||||
* .username("janedoe")
|
* .username("janedoe")
|
||||||
* .preferredEmail("janedoe@example.com")
|
* .preferredEmail("janedoe@example.com")
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ public class AccountOperationsImpl implements AccountOperations {
|
|||||||
return TestAccountCreation.builder(this::createAccount);
|
return TestAccountCreation.builder(this::createAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestAccount createAccount(TestAccountCreation accountCreation) throws Exception {
|
private Account.Id createAccount(TestAccountCreation accountCreation) throws Exception {
|
||||||
AccountsUpdate.AccountUpdater accountUpdater =
|
AccountsUpdate.AccountUpdater accountUpdater =
|
||||||
(account, updateBuilder) ->
|
(account, updateBuilder) ->
|
||||||
fillBuilder(updateBuilder, accountCreation, account.getAccount().getId());
|
fillBuilder(updateBuilder, accountCreation, account.getAccount().getId());
|
||||||
AccountState createdAccount = createAccount(accountUpdater);
|
AccountState createdAccount = createAccount(accountUpdater);
|
||||||
return toTestAccount(createdAccount);
|
return createdAccount.getAccount().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
||||||
@@ -85,17 +85,6 @@ public class AccountOperationsImpl implements AccountOperations {
|
|||||||
accountCreation.active().ifPresent(builder::setActive);
|
accountCreation.active().ifPresent(builder::setActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TestAccount toTestAccount(AccountState accountState) {
|
|
||||||
Account createdAccount = accountState.getAccount();
|
|
||||||
return TestAccount.builder()
|
|
||||||
.accountId(createdAccount.getId())
|
|
||||||
.preferredEmail(Optional.ofNullable(createdAccount.getPreferredEmail()))
|
|
||||||
.fullname(Optional.ofNullable(createdAccount.getFullName()))
|
|
||||||
.username(accountState.getUserName())
|
|
||||||
.active(accountState.getAccount().isActive())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static InternalAccountUpdate.Builder setPreferredEmail(
|
private static InternalAccountUpdate.Builder setPreferredEmail(
|
||||||
InternalAccountUpdate.Builder builder, Account.Id accountId, String preferredEmail) {
|
InternalAccountUpdate.Builder builder, Account.Id accountId, String preferredEmail) {
|
||||||
return builder
|
return builder
|
||||||
@@ -133,6 +122,17 @@ public class AccountOperationsImpl implements AccountOperations {
|
|||||||
return toTestAccount(account);
|
return toTestAccount(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TestAccount toTestAccount(AccountState accountState) {
|
||||||
|
Account account = accountState.getAccount();
|
||||||
|
return TestAccount.builder()
|
||||||
|
.accountId(account.getId())
|
||||||
|
.preferredEmail(Optional.ofNullable(account.getPreferredEmail()))
|
||||||
|
.fullname(Optional.ofNullable(account.getFullName()))
|
||||||
|
.username(accountState.getUserName())
|
||||||
|
.active(accountState.getAccount().isActive())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestAccountUpdate.Builder forUpdate() {
|
public TestAccountUpdate.Builder forUpdate() {
|
||||||
return TestAccountUpdate.builder(this::updateAccount);
|
return TestAccountUpdate.builder(this::updateAccount);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.testsuite.account;
|
|||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.gerrit.acceptance.testsuite.ThrowingFunction;
|
import com.google.gerrit.acceptance.testsuite.ThrowingFunction;
|
||||||
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@AutoValue
|
@AutoValue
|
||||||
@@ -32,9 +33,9 @@ public abstract class TestAccountCreation {
|
|||||||
|
|
||||||
public abstract Optional<Boolean> active();
|
public abstract Optional<Boolean> active();
|
||||||
|
|
||||||
abstract ThrowingFunction<TestAccountCreation, TestAccount> accountCreator();
|
abstract ThrowingFunction<TestAccountCreation, Account.Id> accountCreator();
|
||||||
|
|
||||||
public static Builder builder(ThrowingFunction<TestAccountCreation, TestAccount> accountCreator) {
|
public static Builder builder(ThrowingFunction<TestAccountCreation, Account.Id> accountCreator) {
|
||||||
return new AutoValue_TestAccountCreation.Builder()
|
return new AutoValue_TestAccountCreation.Builder()
|
||||||
.accountCreator(accountCreator)
|
.accountCreator(accountCreator)
|
||||||
.httpPassword("http-pass");
|
.httpPassword("http-pass");
|
||||||
@@ -83,11 +84,11 @@ public abstract class TestAccountCreation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract Builder accountCreator(
|
abstract Builder accountCreator(
|
||||||
ThrowingFunction<TestAccountCreation, TestAccount> accountCreator);
|
ThrowingFunction<TestAccountCreation, Account.Id> accountCreator);
|
||||||
|
|
||||||
abstract TestAccountCreation autoBuild();
|
abstract TestAccountCreation autoBuild();
|
||||||
|
|
||||||
public TestAccount create() throws Exception {
|
public Account.Id create() throws Exception {
|
||||||
TestAccountCreation accountUpdate = autoBuild();
|
TestAccountCreation accountUpdate = autoBuild();
|
||||||
return accountUpdate.accountCreator().apply(accountUpdate);
|
return accountUpdate.accountCreator().apply(accountUpdate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public interface GroupOperations {
|
|||||||
* <p>Example:
|
* <p>Example:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* TestGroup createdGroup = groupOperations
|
* AccountGroup.UUID createdGroupUuid = groupOperations
|
||||||
* .newGroup()
|
* .newGroup()
|
||||||
* .name("verifiers")
|
* .name("verifiers")
|
||||||
* .description("All verifiers of this server")
|
* .description("All verifiers of this server")
|
||||||
|
|||||||
@@ -69,13 +69,13 @@ public class GroupOperationsImpl implements GroupOperations {
|
|||||||
return TestGroupCreation.builder(this::createNewGroup);
|
return TestGroupCreation.builder(this::createNewGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestGroup createNewGroup(TestGroupCreation groupCreation)
|
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation)
|
||||||
throws ConfigInvalidException, IOException, OrmException {
|
throws ConfigInvalidException, IOException, OrmException {
|
||||||
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
|
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
|
||||||
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation);
|
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation);
|
||||||
InternalGroup internalGroup =
|
InternalGroup internalGroup =
|
||||||
groupsUpdate.createGroup(internalGroupCreation, internalGroupUpdate);
|
groupsUpdate.createGroup(internalGroupCreation, internalGroupUpdate);
|
||||||
return toTestGroup(internalGroup);
|
return internalGroup.getGroupUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation)
|
private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation)
|
||||||
@@ -101,20 +101,6 @@ public class GroupOperationsImpl implements GroupOperations {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TestGroup toTestGroup(InternalGroup internalGroup) {
|
|
||||||
return TestGroup.builder()
|
|
||||||
.groupUuid(internalGroup.getGroupUUID())
|
|
||||||
.groupId(internalGroup.getId())
|
|
||||||
.nameKey(internalGroup.getNameKey())
|
|
||||||
.description(Optional.ofNullable(internalGroup.getDescription()))
|
|
||||||
.ownerGroupUuid(internalGroup.getOwnerGroupUUID())
|
|
||||||
.visibleToAll(internalGroup.isVisibleToAll())
|
|
||||||
.createdOn(internalGroup.getCreatedOn())
|
|
||||||
.members(internalGroup.getMembers())
|
|
||||||
.subgroups(internalGroup.getSubgroups())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MoreGroupOperationsImpl implements MoreGroupOperations {
|
private class MoreGroupOperationsImpl implements MoreGroupOperations {
|
||||||
private final AccountGroup.UUID groupUuid;
|
private final AccountGroup.UUID groupUuid;
|
||||||
|
|
||||||
@@ -134,6 +120,20 @@ public class GroupOperationsImpl implements GroupOperations {
|
|||||||
return toTestGroup(group.get());
|
return toTestGroup(group.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TestGroup toTestGroup(InternalGroup internalGroup) {
|
||||||
|
return TestGroup.builder()
|
||||||
|
.groupUuid(internalGroup.getGroupUUID())
|
||||||
|
.groupId(internalGroup.getId())
|
||||||
|
.nameKey(internalGroup.getNameKey())
|
||||||
|
.description(Optional.ofNullable(internalGroup.getDescription()))
|
||||||
|
.ownerGroupUuid(internalGroup.getOwnerGroupUUID())
|
||||||
|
.visibleToAll(internalGroup.isVisibleToAll())
|
||||||
|
.createdOn(internalGroup.getCreatedOn())
|
||||||
|
.members(internalGroup.getMembers())
|
||||||
|
.subgroups(internalGroup.getSubgroups())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestGroupUpdate.Builder forUpdate() {
|
public TestGroupUpdate.Builder forUpdate() {
|
||||||
return TestGroupUpdate.builder(this::updateGroup);
|
return TestGroupUpdate.builder(this::updateGroup);
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ public abstract class TestGroupCreation {
|
|||||||
|
|
||||||
public abstract ImmutableSet<AccountGroup.UUID> subgroups();
|
public abstract ImmutableSet<AccountGroup.UUID> subgroups();
|
||||||
|
|
||||||
abstract ThrowingFunction<TestGroupCreation, TestGroup> groupCreator();
|
abstract ThrowingFunction<TestGroupCreation, AccountGroup.UUID> groupCreator();
|
||||||
|
|
||||||
public static Builder builder(ThrowingFunction<TestGroupCreation, TestGroup> groupCreator) {
|
public static Builder builder(
|
||||||
|
ThrowingFunction<TestGroupCreation, AccountGroup.UUID> groupCreator) {
|
||||||
return new AutoValue_TestGroupCreation.Builder().groupCreator(groupCreator);
|
return new AutoValue_TestGroupCreation.Builder().groupCreator(groupCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,16 +94,17 @@ public abstract class TestGroupCreation {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract Builder groupCreator(ThrowingFunction<TestGroupCreation, TestGroup> groupCreator);
|
abstract Builder groupCreator(
|
||||||
|
ThrowingFunction<TestGroupCreation, AccountGroup.UUID> groupCreator);
|
||||||
|
|
||||||
abstract TestGroupCreation autoBuild();
|
abstract TestGroupCreation autoBuild();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the group creation as specified.
|
* Executes the group creation as specified.
|
||||||
*
|
*
|
||||||
* @return the created {@code TestGroup}
|
* @return the UUID of the created group
|
||||||
*/
|
*/
|
||||||
public TestGroup create() throws Exception {
|
public AccountGroup.UUID create() throws Exception {
|
||||||
TestGroupCreation groupCreation = autoBuild();
|
TestGroupCreation groupCreation = autoBuild();
|
||||||
return groupCreation.groupCreator().apply(groupCreation);
|
return groupCreation.groupCreator().apply(groupCreation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -526,9 +526,9 @@ public class AccountIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateAccountActivation() throws Exception {
|
public void validateAccountActivation() throws Exception {
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount activatableAccount =
|
Account.Id activatableAccountId =
|
||||||
accountOperations.newAccount().inactive().preferredEmail("foo@activatable.com").create();
|
accountOperations.newAccount().inactive().preferredEmail("foo@activatable.com").create();
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount deactivatableAccount =
|
Account.Id deactivatableAccountId =
|
||||||
accountOperations.newAccount().preferredEmail("foo@deactivatable.com").create();
|
accountOperations.newAccount().preferredEmail("foo@deactivatable.com").create();
|
||||||
RegistrationHandle registrationHandle =
|
RegistrationHandle registrationHandle =
|
||||||
accountActivationValidationListeners.add(
|
accountActivationValidationListeners.add(
|
||||||
@@ -554,61 +554,56 @@ public class AccountIT extends AbstractDaemonTest {
|
|||||||
/* Test account that can be activated, but not deactivated */
|
/* Test account that can be activated, but not deactivated */
|
||||||
// Deactivate account that is already inactive
|
// Deactivate account that is already inactive
|
||||||
try {
|
try {
|
||||||
gApi.accounts().id(activatableAccount.accountId().get()).setActive(false);
|
gApi.accounts().id(activatableAccountId.get()).setActive(false);
|
||||||
fail("Expected exception");
|
fail("Expected exception");
|
||||||
} catch (ResourceConflictException e) {
|
} catch (ResourceConflictException e) {
|
||||||
assertThat(e.getMessage()).isEqualTo("account not active");
|
assertThat(e.getMessage()).isEqualTo("account not active");
|
||||||
}
|
}
|
||||||
assertThat(accountOperations.account(activatableAccount.accountId()).get().active())
|
assertThat(accountOperations.account(activatableAccountId).get().active()).isFalse();
|
||||||
.isFalse();
|
|
||||||
|
|
||||||
// Activate account that can be activated
|
// Activate account that can be activated
|
||||||
gApi.accounts().id(activatableAccount.accountId().get()).setActive(true);
|
gApi.accounts().id(activatableAccountId.get()).setActive(true);
|
||||||
assertThat(accountOperations.account(activatableAccount.accountId()).get().active()).isTrue();
|
assertThat(accountOperations.account(activatableAccountId).get().active()).isTrue();
|
||||||
|
|
||||||
// Activate account that is already active
|
// Activate account that is already active
|
||||||
gApi.accounts().id(activatableAccount.accountId().get()).setActive(true);
|
gApi.accounts().id(activatableAccountId.get()).setActive(true);
|
||||||
assertThat(accountOperations.account(activatableAccount.accountId()).get().active()).isTrue();
|
assertThat(accountOperations.account(activatableAccountId).get().active()).isTrue();
|
||||||
|
|
||||||
// Try deactivating account that cannot be deactivated
|
// Try deactivating account that cannot be deactivated
|
||||||
try {
|
try {
|
||||||
gApi.accounts().id(activatableAccount.accountId().get()).setActive(false);
|
gApi.accounts().id(activatableAccountId.get()).setActive(false);
|
||||||
fail("Expected exception");
|
fail("Expected exception");
|
||||||
} catch (ResourceConflictException e) {
|
} catch (ResourceConflictException e) {
|
||||||
assertThat(e.getMessage()).isEqualTo("not allowed to deactive account");
|
assertThat(e.getMessage()).isEqualTo("not allowed to deactive account");
|
||||||
}
|
}
|
||||||
assertThat(accountOperations.account(activatableAccount.accountId()).get().active()).isTrue();
|
assertThat(accountOperations.account(activatableAccountId).get().active()).isTrue();
|
||||||
|
|
||||||
/* Test account that can be deactivated, but not activated */
|
/* Test account that can be deactivated, but not activated */
|
||||||
// Activate account that is already inactive
|
// Activate account that is already inactive
|
||||||
gApi.accounts().id(deactivatableAccount.accountId().get()).setActive(true);
|
gApi.accounts().id(deactivatableAccountId.get()).setActive(true);
|
||||||
assertThat(accountOperations.account(deactivatableAccount.accountId()).get().active())
|
assertThat(accountOperations.account(deactivatableAccountId).get().active()).isTrue();
|
||||||
.isTrue();
|
|
||||||
|
|
||||||
// Deactivate account that can be deactivated
|
// Deactivate account that can be deactivated
|
||||||
gApi.accounts().id(deactivatableAccount.accountId().get()).setActive(false);
|
gApi.accounts().id(deactivatableAccountId.get()).setActive(false);
|
||||||
assertThat(accountOperations.account(deactivatableAccount.accountId()).get().active())
|
assertThat(accountOperations.account(deactivatableAccountId).get().active()).isFalse();
|
||||||
.isFalse();
|
|
||||||
|
|
||||||
// Deactivate account that is already inactive
|
// Deactivate account that is already inactive
|
||||||
try {
|
try {
|
||||||
gApi.accounts().id(deactivatableAccount.accountId().get()).setActive(false);
|
gApi.accounts().id(deactivatableAccountId.get()).setActive(false);
|
||||||
fail("Expected exception");
|
fail("Expected exception");
|
||||||
} catch (ResourceConflictException e) {
|
} catch (ResourceConflictException e) {
|
||||||
assertThat(e.getMessage()).isEqualTo("account not active");
|
assertThat(e.getMessage()).isEqualTo("account not active");
|
||||||
}
|
}
|
||||||
assertThat(accountOperations.account(deactivatableAccount.accountId()).get().active())
|
assertThat(accountOperations.account(deactivatableAccountId).get().active()).isFalse();
|
||||||
.isFalse();
|
|
||||||
|
|
||||||
// Try activating account that cannot be activated
|
// Try activating account that cannot be activated
|
||||||
try {
|
try {
|
||||||
gApi.accounts().id(deactivatableAccount.accountId().get()).setActive(true);
|
gApi.accounts().id(deactivatableAccountId.get()).setActive(true);
|
||||||
fail("Expected exception");
|
fail("Expected exception");
|
||||||
} catch (ResourceConflictException e) {
|
} catch (ResourceConflictException e) {
|
||||||
assertThat(e.getMessage()).isEqualTo("not allowed to active account");
|
assertThat(e.getMessage()).isEqualTo("not allowed to active account");
|
||||||
}
|
}
|
||||||
assertThat(accountOperations.account(deactivatableAccount.accountId()).get().active())
|
assertThat(accountOperations.account(deactivatableAccountId).get().active()).isFalse();
|
||||||
.isFalse();
|
|
||||||
} finally {
|
} finally {
|
||||||
registrationHandle.remove();
|
registrationHandle.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ import com.google.gerrit.acceptance.NoHttpd;
|
|||||||
import com.google.gerrit.acceptance.PushOneCommit;
|
import com.google.gerrit.acceptance.PushOneCommit;
|
||||||
import com.google.gerrit.acceptance.TestProjectInput;
|
import com.google.gerrit.acceptance.TestProjectInput;
|
||||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||||
import com.google.gerrit.acceptance.testsuite.account.TestAccount;
|
|
||||||
import com.google.gerrit.common.FooterConstants;
|
import com.google.gerrit.common.FooterConstants;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
import com.google.gerrit.common.data.LabelFunction;
|
import com.google.gerrit.common.data.LabelFunction;
|
||||||
@@ -1688,7 +1687,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
// create a group named "ab" with one user: testUser
|
// create a group named "ab" with one user: testUser
|
||||||
String email = "abcd@test.com";
|
String email = "abcd@test.com";
|
||||||
String fullname = "abcd";
|
String fullname = "abcd";
|
||||||
TestAccount testUser =
|
Account.Id accountIdOfTestUser =
|
||||||
accountOperations
|
accountOperations
|
||||||
.newAccount()
|
.newAccount()
|
||||||
.username("abcd")
|
.username("abcd")
|
||||||
@@ -1721,7 +1720,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
|
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
|
||||||
assertThat(reviewers).isNotNull();
|
assertThat(reviewers).isNotNull();
|
||||||
assertThat(reviewers).hasSize(1);
|
assertThat(reviewers).hasSize(1);
|
||||||
assertThat(reviewers.iterator().next()._accountId).isEqualTo(testUser.accountId().get());
|
assertThat(reviewers.iterator().next()._accountId).isEqualTo(accountIdOfTestUser.get());
|
||||||
|
|
||||||
// Ensure ETag and lastUpdatedOn are updated.
|
// Ensure ETag and lastUpdatedOn are updated.
|
||||||
rsrc = parseResource(r);
|
rsrc = parseResource(r);
|
||||||
@@ -1748,7 +1747,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
String myGroupUserEmail = "lee@test.com";
|
String myGroupUserEmail = "lee@test.com";
|
||||||
String myGroupUserFullname = "lee";
|
String myGroupUserFullname = "lee";
|
||||||
TestAccount myGroupUser =
|
Account.Id accountIdOfGroupUser =
|
||||||
accountOperations
|
accountOperations
|
||||||
.newAccount()
|
.newAccount()
|
||||||
.username("lee")
|
.username("lee")
|
||||||
@@ -1785,7 +1784,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
|
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
|
||||||
assertThat(reviewers).isNotNull();
|
assertThat(reviewers).isNotNull();
|
||||||
assertThat(reviewers).hasSize(1);
|
assertThat(reviewers).hasSize(1);
|
||||||
assertThat(reviewers.iterator().next()._accountId).isEqualTo(myGroupUser.accountId().get());
|
assertThat(reviewers.iterator().next()._accountId).isEqualTo(accountIdOfGroupUser.get());
|
||||||
|
|
||||||
// Ensure ETag and lastUpdatedOn are updated.
|
// Ensure ETag and lastUpdatedOn are updated.
|
||||||
rsrc = parseResource(r);
|
rsrc = parseResource(r);
|
||||||
@@ -2215,7 +2214,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
// notify unrelated account as TO
|
// notify unrelated account as TO
|
||||||
String email = "user2@example.com";
|
String email = "user2@example.com";
|
||||||
TestAccount user2 =
|
Account.Id user2Id =
|
||||||
accountOperations
|
accountOperations
|
||||||
.newAccount()
|
.newAccount()
|
||||||
.username("user2")
|
.username("user2")
|
||||||
@@ -2229,7 +2228,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
in.notifyDetails = new HashMap<>();
|
in.notifyDetails = new HashMap<>();
|
||||||
in.notifyDetails.put(RecipientType.TO, new NotifyInfo(ImmutableList.of(email)));
|
in.notifyDetails.put(RecipientType.TO, new NotifyInfo(ImmutableList.of(email)));
|
||||||
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
|
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
|
||||||
assertNotifyTo(user2);
|
assertNotifyTo(email, "User2");
|
||||||
|
|
||||||
// notify unrelated account as CC
|
// notify unrelated account as CC
|
||||||
setApiUser(user);
|
setApiUser(user);
|
||||||
@@ -2239,7 +2238,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
in.notifyDetails = new HashMap<>();
|
in.notifyDetails = new HashMap<>();
|
||||||
in.notifyDetails.put(RecipientType.CC, new NotifyInfo(ImmutableList.of(email)));
|
in.notifyDetails.put(RecipientType.CC, new NotifyInfo(ImmutableList.of(email)));
|
||||||
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
|
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
|
||||||
assertNotifyCc(user2);
|
assertNotifyCc(email, "User2");
|
||||||
|
|
||||||
// notify unrelated account as BCC
|
// notify unrelated account as BCC
|
||||||
setApiUser(user);
|
setApiUser(user);
|
||||||
@@ -2249,7 +2248,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||||||
in.notifyDetails = new HashMap<>();
|
in.notifyDetails = new HashMap<>();
|
||||||
in.notifyDetails.put(RecipientType.BCC, new NotifyInfo(ImmutableList.of(email)));
|
in.notifyDetails.put(RecipientType.BCC, new NotifyInfo(ImmutableList.of(email)));
|
||||||
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
|
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
|
||||||
assertNotifyBcc(user2);
|
assertNotifyBcc(email, "User2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -183,24 +183,23 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void cachedGroupsForMemberAreUpdatedOnMemberAdditionAndRemoval() throws Exception {
|
public void cachedGroupsForMemberAreUpdatedOnMemberAdditionAndRemoval() throws Exception {
|
||||||
String username = name("user");
|
String username = name("user");
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount account =
|
Account.Id accountId = accountOperations.newAccount().username(username).create();
|
||||||
accountOperations.newAccount().username(username).create();
|
|
||||||
|
|
||||||
// Fill the cache for the observed account.
|
// Fill the cache for the observed account.
|
||||||
groupIncludeCache.getGroupsWithMember(account.accountId());
|
groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
String groupName = createGroup("users");
|
String groupName = createGroup("users");
|
||||||
AccountGroup.UUID groupUuid = new AccountGroup.UUID(gApi.groups().id(groupName).get().id);
|
AccountGroup.UUID groupUuid = new AccountGroup.UUID(gApi.groups().id(groupName).get().id);
|
||||||
|
|
||||||
gApi.groups().id(groupName).addMembers(username);
|
gApi.groups().id(groupName).addMembers(username);
|
||||||
|
|
||||||
Collection<AccountGroup.UUID> groupsWithMemberAfterAddition =
|
Collection<AccountGroup.UUID> groupsWithMemberAfterAddition =
|
||||||
groupIncludeCache.getGroupsWithMember(account.accountId());
|
groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
assertThat(groupsWithMemberAfterAddition).contains(groupUuid);
|
assertThat(groupsWithMemberAfterAddition).contains(groupUuid);
|
||||||
|
|
||||||
gApi.groups().id(groupName).removeMembers(username);
|
gApi.groups().id(groupName).removeMembers(username);
|
||||||
|
|
||||||
Collection<AccountGroup.UUID> groupsWithMemberAfterRemoval =
|
Collection<AccountGroup.UUID> groupsWithMemberAfterRemoval =
|
||||||
groupIncludeCache.getGroupsWithMember(account.accountId());
|
groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
assertThat(groupsWithMemberAfterRemoval).doesNotContain(groupUuid);
|
assertThat(groupsWithMemberAfterRemoval).doesNotContain(groupUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,19 +410,17 @@ public class GroupsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cachedGroupsForMemberAreUpdatedOnGroupCreation() throws Exception {
|
public void cachedGroupsForMemberAreUpdatedOnGroupCreation() throws Exception {
|
||||||
com.google.gerrit.acceptance.testsuite.account.TestAccount account =
|
Account.Id accountId = accountOperations.newAccount().create();
|
||||||
accountOperations.newAccount().create();
|
|
||||||
|
|
||||||
// Fill the cache for the observed account.
|
// Fill the cache for the observed account.
|
||||||
groupIncludeCache.getGroupsWithMember(account.accountId());
|
groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
|
|
||||||
GroupInput groupInput = new GroupInput();
|
GroupInput groupInput = new GroupInput();
|
||||||
groupInput.name = name("Users");
|
groupInput.name = name("Users");
|
||||||
groupInput.members = ImmutableList.of(String.valueOf(account.accountId().get()));
|
groupInput.members = ImmutableList.of(String.valueOf(accountId.get()));
|
||||||
GroupInfo group = gApi.groups().create(groupInput).get();
|
GroupInfo group = gApi.groups().create(groupInput).get();
|
||||||
|
|
||||||
Collection<AccountGroup.UUID> groups =
|
Collection<AccountGroup.UUID> groups = groupIncludeCache.getGroupsWithMember(accountId);
|
||||||
groupIncludeCache.getGroupsWithMember(account.accountId());
|
|
||||||
assertThat(groups).containsExactly(new AccountGroup.UUID(group.id));
|
assertThat(groups).containsExactly(new AccountGroup.UUID(group.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
|||||||
import com.google.gerrit.acceptance.RestResponse;
|
import com.google.gerrit.acceptance.RestResponse;
|
||||||
import com.google.gerrit.acceptance.TestAccount;
|
import com.google.gerrit.acceptance.TestAccount;
|
||||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||||
import com.google.gerrit.acceptance.testsuite.group.TestGroup;
|
|
||||||
import com.google.gerrit.common.data.Permission;
|
import com.google.gerrit.common.data.Permission;
|
||||||
import com.google.gerrit.extensions.api.config.AccessCheckInfo;
|
import com.google.gerrit.extensions.api.config.AccessCheckInfo;
|
||||||
import com.google.gerrit.extensions.api.config.AccessCheckInput;
|
import com.google.gerrit.extensions.api.config.AccessCheckInput;
|
||||||
@@ -54,8 +53,8 @@ public class CheckAccessIT extends AbstractDaemonTest {
|
|||||||
normalProject = createProject("normal");
|
normalProject = createProject("normal");
|
||||||
secretProject = createProject("secret");
|
secretProject = createProject("secret");
|
||||||
secretRefProject = createProject("secretRef");
|
secretRefProject = createProject("secretRef");
|
||||||
TestGroup privilegedGroup = groupOperations.newGroup().name(name("privilegedGroup")).create();
|
AccountGroup.UUID privilegedGroupUuid =
|
||||||
AccountGroup.UUID privilegedGroupUuid = privilegedGroup.groupUuid();
|
groupOperations.newGroup().name(name("privilegedGroup")).create();
|
||||||
|
|
||||||
privilegedUser = accountCreator.create("privilegedUser", "snowden@nsa.gov", "Ed Snowden");
|
privilegedUser = accountCreator.create("privilegedUser", "snowden@nsa.gov", "Ed Snowden");
|
||||||
groupOperations.group(privilegedGroupUuid).forUpdate().addMember(privilegedUser.id).update();
|
groupOperations.group(privilegedGroupUuid).forUpdate().addMember(privilegedUser.id).update();
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.truth.Correspondence;
|
import com.google.common.truth.Correspondence;
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||||
import com.google.gerrit.acceptance.testsuite.account.TestAccount;
|
|
||||||
import com.google.gerrit.extensions.api.GerritApi;
|
|
||||||
import com.google.gerrit.extensions.api.groups.GroupInput;
|
import com.google.gerrit.extensions.api.groups.GroupInput;
|
||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.common.GroupInfo;
|
import com.google.gerrit.extensions.common.GroupInfo;
|
||||||
@@ -42,7 +40,6 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Rule public ExpectedException expectedException = ExpectedException.none();
|
@Rule public ExpectedException expectedException = ExpectedException.none();
|
||||||
|
|
||||||
@Inject private AccountOperations accountOperations;
|
@Inject private AccountOperations accountOperations;
|
||||||
@Inject private GerritApi gApi;
|
|
||||||
|
|
||||||
@Inject private GroupOperationsImpl groupOperations;
|
@Inject private GroupOperationsImpl groupOperations;
|
||||||
|
|
||||||
@@ -50,17 +47,17 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void groupCanBeCreatedWithoutSpecifyingAnyParameters() throws Exception {
|
public void groupCanBeCreatedWithoutSpecifyingAnyParameters() throws Exception {
|
||||||
TestGroup group = groupOperations.newGroup().create();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.id).isEqualTo(group.groupUuid().get());
|
assertThat(foundGroup.id).isEqualTo(groupUuid.get());
|
||||||
assertThat(foundGroup.name).isNotEmpty();
|
assertThat(foundGroup.name).isNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void twoGroupsWithoutAnyParametersDoNotClash() throws Exception {
|
public void twoGroupsWithoutAnyParametersDoNotClash() throws Exception {
|
||||||
AccountGroup.UUID groupUuid1 = groupOperations.newGroup().create().groupUuid();
|
AccountGroup.UUID groupUuid1 = groupOperations.newGroup().create();
|
||||||
AccountGroup.UUID groupUuid2 = groupOperations.newGroup().create().groupUuid();
|
AccountGroup.UUID groupUuid2 = groupOperations.newGroup().create();
|
||||||
|
|
||||||
TestGroup group1 = groupOperations.group(groupUuid1).get();
|
TestGroup group1 = groupOperations.group(groupUuid1).get();
|
||||||
TestGroup group2 = groupOperations.group(groupUuid2).get();
|
TestGroup group2 = groupOperations.group(groupUuid2).get();
|
||||||
@@ -70,7 +67,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void groupCreatedByTestApiCanBeRetrievedViaOfficialApi() throws Exception {
|
public void groupCreatedByTestApiCanBeRetrievedViaOfficialApi() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().name("unique group created via test API").create().groupUuid();
|
groupOperations.newGroup().name("unique group created via test API").create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.id).isEqualTo(groupUuid.get());
|
assertThat(foundGroup.id).isEqualTo(groupUuid.get());
|
||||||
@@ -80,7 +77,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void specifiedNameIsRespectedForGroupCreation() throws Exception {
|
public void specifiedNameIsRespectedForGroupCreation() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().name("XYZ-123-this-name-must-be-unique").create().groupUuid();
|
groupOperations.newGroup().name("XYZ-123-this-name-must-be-unique").create();
|
||||||
|
|
||||||
GroupInfo group = getGroupFromServer(groupUuid);
|
GroupInfo group = getGroupFromServer(groupUuid);
|
||||||
assertThat(group.name).isEqualTo("XYZ-123-this-name-must-be-unique");
|
assertThat(group.name).isEqualTo("XYZ-123-this-name-must-be-unique");
|
||||||
@@ -89,7 +86,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void specifiedDescriptionIsRespectedForGroupCreation() throws Exception {
|
public void specifiedDescriptionIsRespectedForGroupCreation() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().description("All authenticated users").create().groupUuid();
|
groupOperations.newGroup().description("All authenticated users").create();
|
||||||
|
|
||||||
GroupInfo group = getGroupFromServer(groupUuid);
|
GroupInfo group = getGroupFromServer(groupUuid);
|
||||||
assertThat(group.description).isEqualTo("All authenticated users");
|
assertThat(group.description).isEqualTo("All authenticated users");
|
||||||
@@ -97,8 +94,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestingNoDescriptionIsPossibleForGroupCreation() throws Exception {
|
public void requestingNoDescriptionIsPossibleForGroupCreation() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearDescription().create();
|
||||||
groupOperations.newGroup().clearDescription().create().groupUuid();
|
|
||||||
|
|
||||||
GroupInfo group = getGroupFromServer(groupUuid);
|
GroupInfo group = getGroupFromServer(groupUuid);
|
||||||
assertThat(group.description).isNull();
|
assertThat(group.description).isNull();
|
||||||
@@ -106,22 +102,22 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specifiedOwnerIsRespectedForGroupCreation() throws Exception {
|
public void specifiedOwnerIsRespectedForGroupCreation() throws Exception {
|
||||||
TestGroup ownerGroup = groupOperations.newGroup().create();
|
AccountGroup.UUID ownerGroupUuid = groupOperations.newGroup().create();
|
||||||
|
|
||||||
TestGroup group =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().ownerGroupUuid(ownerGroup.ownerGroupUuid()).create();
|
groupOperations.newGroup().ownerGroupUuid(ownerGroupUuid).create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.ownerId).isEqualTo(ownerGroup.ownerGroupUuid().get());
|
assertThat(foundGroup.ownerId).isEqualTo(ownerGroupUuid.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specifiedVisibilityIsRespectedForGroupCreation() throws Exception {
|
public void specifiedVisibilityIsRespectedForGroupCreation() throws Exception {
|
||||||
TestGroup group1 = groupOperations.newGroup().visibleToAll(true).create();
|
AccountGroup.UUID group1Uuid = groupOperations.newGroup().visibleToAll(true).create();
|
||||||
TestGroup group2 = groupOperations.newGroup().visibleToAll(false).create();
|
AccountGroup.UUID group2Uuid = groupOperations.newGroup().visibleToAll(false).create();
|
||||||
|
|
||||||
GroupInfo foundGroup1 = getGroupFromServer(group1.groupUuid());
|
GroupInfo foundGroup1 = getGroupFromServer(group1Uuid);
|
||||||
GroupInfo foundGroup2 = getGroupFromServer(group2.groupUuid());
|
GroupInfo foundGroup2 = getGroupFromServer(group2Uuid);
|
||||||
assertThat(foundGroup1.options.visibleToAll).isTrue();
|
assertThat(foundGroup1.options.visibleToAll).isTrue();
|
||||||
// False == null
|
// False == null
|
||||||
assertThat(foundGroup2.options.visibleToAll).isNull();
|
assertThat(foundGroup2.options.visibleToAll).isNull();
|
||||||
@@ -129,97 +125,87 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specifiedMembersAreRespectedForGroupCreation() throws Exception {
|
public void specifiedMembersAreRespectedForGroupCreation() throws Exception {
|
||||||
TestAccount account1 = accountOperations.newAccount().create();
|
Account.Id account1Id = accountOperations.newAccount().create();
|
||||||
TestAccount account2 = accountOperations.newAccount().create();
|
Account.Id account2Id = accountOperations.newAccount().create();
|
||||||
TestAccount account3 = accountOperations.newAccount().create();
|
Account.Id account3Id = accountOperations.newAccount().create();
|
||||||
TestAccount account4 = accountOperations.newAccount().create();
|
Account.Id account4Id = accountOperations.newAccount().create();
|
||||||
|
|
||||||
TestGroup group =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations
|
groupOperations
|
||||||
.newGroup()
|
.newGroup()
|
||||||
.members(account1.accountId(), account2.accountId())
|
.members(account1Id, account2Id)
|
||||||
.addMember(account3.accountId())
|
.addMember(account3Id)
|
||||||
.addMember(account4.accountId())
|
.addMember(account4Id)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.members)
|
assertThat(foundGroup.members)
|
||||||
.comparingElementsUsing(getAccountToIdCorrespondence())
|
.comparingElementsUsing(getAccountToIdCorrespondence())
|
||||||
.containsExactly(
|
.containsExactly(account1Id, account2Id, account3Id, account4Id);
|
||||||
account1.accountId(), account2.accountId(), account3.accountId(), account4.accountId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void directlyAddingMembersIsPossibleForGroupCreation() throws Exception {
|
public void directlyAddingMembersIsPossibleForGroupCreation() throws Exception {
|
||||||
TestAccount account1 = accountOperations.newAccount().create();
|
Account.Id account1Id = accountOperations.newAccount().create();
|
||||||
TestAccount account2 = accountOperations.newAccount().create();
|
Account.Id account2Id = accountOperations.newAccount().create();
|
||||||
|
|
||||||
TestGroup group =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations
|
groupOperations.newGroup().addMember(account1Id).addMember(account2Id).create();
|
||||||
.newGroup()
|
|
||||||
.addMember(account1.accountId())
|
|
||||||
.addMember(account2.accountId())
|
|
||||||
.create();
|
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.members)
|
assertThat(foundGroup.members)
|
||||||
.comparingElementsUsing(getAccountToIdCorrespondence())
|
.comparingElementsUsing(getAccountToIdCorrespondence())
|
||||||
.containsExactly(account1.accountId(), account2.accountId());
|
.containsExactly(account1Id, account2Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestingNoMembersIsPossibleForGroupCreation() throws Exception {
|
public void requestingNoMembersIsPossibleForGroupCreation() throws Exception {
|
||||||
TestGroup group = groupOperations.newGroup().clearMembers().create();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearMembers().create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.members).isEmpty();
|
assertThat(foundGroup.members).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specifiedSubgroupsAreRespectedForGroupCreation() throws Exception {
|
public void specifiedSubgroupsAreRespectedForGroupCreation() throws Exception {
|
||||||
TestGroup group1 = groupOperations.newGroup().create();
|
AccountGroup.UUID group1Uuid = groupOperations.newGroup().create();
|
||||||
TestGroup group2 = groupOperations.newGroup().create();
|
AccountGroup.UUID group2Uuid = groupOperations.newGroup().create();
|
||||||
TestGroup group3 = groupOperations.newGroup().create();
|
AccountGroup.UUID group3Uuid = groupOperations.newGroup().create();
|
||||||
TestGroup group4 = groupOperations.newGroup().create();
|
AccountGroup.UUID group4Uuid = groupOperations.newGroup().create();
|
||||||
|
|
||||||
TestGroup group =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations
|
groupOperations
|
||||||
.newGroup()
|
.newGroup()
|
||||||
.subgroups(group1.groupUuid(), group2.groupUuid())
|
.subgroups(group1Uuid, group2Uuid)
|
||||||
.addSubgroup(group3.groupUuid())
|
.addSubgroup(group3Uuid)
|
||||||
.addSubgroup(group4.groupUuid())
|
.addSubgroup(group4Uuid)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.includes)
|
assertThat(foundGroup.includes)
|
||||||
.comparingElementsUsing(getGroupToUuidCorrespondence())
|
.comparingElementsUsing(getGroupToUuidCorrespondence())
|
||||||
.containsExactly(
|
.containsExactly(group1Uuid, group2Uuid, group3Uuid, group4Uuid);
|
||||||
group1.groupUuid(), group2.groupUuid(), group3.groupUuid(), group4.groupUuid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void directlyAddingSubgroupsIsPossibleForGroupCreation() throws Exception {
|
public void directlyAddingSubgroupsIsPossibleForGroupCreation() throws Exception {
|
||||||
TestGroup group1 = groupOperations.newGroup().create();
|
AccountGroup.UUID group1Uuid = groupOperations.newGroup().create();
|
||||||
TestGroup group2 = groupOperations.newGroup().create();
|
AccountGroup.UUID group2Uuid = groupOperations.newGroup().create();
|
||||||
|
|
||||||
TestGroup group =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations
|
groupOperations.newGroup().addSubgroup(group1Uuid).addSubgroup(group2Uuid).create();
|
||||||
.newGroup()
|
|
||||||
.addSubgroup(group1.groupUuid())
|
|
||||||
.addSubgroup(group2.groupUuid())
|
|
||||||
.create();
|
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.includes)
|
assertThat(foundGroup.includes)
|
||||||
.comparingElementsUsing(getGroupToUuidCorrespondence())
|
.comparingElementsUsing(getGroupToUuidCorrespondence())
|
||||||
.containsExactly(group1.groupUuid(), group2.groupUuid());
|
.containsExactly(group1Uuid, group2Uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestingNoSubgroupsIsPossibleForGroupCreation() throws Exception {
|
public void requestingNoSubgroupsIsPossibleForGroupCreation() throws Exception {
|
||||||
TestGroup group = groupOperations.newGroup().clearSubgroups().create();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create();
|
||||||
|
|
||||||
GroupInfo foundGroup = getGroupFromServer(group.groupUuid());
|
GroupInfo foundGroup = getGroupFromServer(groupUuid);
|
||||||
assertThat(foundGroup.includes).isEmpty();
|
assertThat(foundGroup.includes).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +249,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uuidOfExistingGroupCanBeRetrieved() throws Exception {
|
public void uuidOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = groupOperations.newGroup().create().groupUuid();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().create();
|
||||||
|
|
||||||
AccountGroup.UUID foundGroupUuid = groupOperations.group(groupUuid).get().groupUuid();
|
AccountGroup.UUID foundGroupUuid = groupOperations.group(groupUuid).get().groupUuid();
|
||||||
|
|
||||||
@@ -273,7 +259,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void nameOfExistingGroupCanBeRetrieved() throws Exception {
|
public void nameOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().name("ABC-789-this-name-must-be-unique").create().groupUuid();
|
groupOperations.newGroup().name("ABC-789-this-name-must-be-unique").create();
|
||||||
|
|
||||||
String groupName = groupOperations.group(groupUuid).get().name();
|
String groupName = groupOperations.group(groupUuid).get().name();
|
||||||
|
|
||||||
@@ -283,7 +269,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void nameKeyOfExistingGroupCanBeRetrieved() throws Exception {
|
public void nameKeyOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().name("ABC-789-this-name-must-be-unique").create().groupUuid();
|
groupOperations.newGroup().name("ABC-789-this-name-must-be-unique").create();
|
||||||
|
|
||||||
AccountGroup.NameKey groupName = groupOperations.group(groupUuid).get().nameKey();
|
AccountGroup.NameKey groupName = groupOperations.group(groupUuid).get().nameKey();
|
||||||
|
|
||||||
@@ -296,8 +282,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
groupOperations
|
groupOperations
|
||||||
.newGroup()
|
.newGroup()
|
||||||
.description("This is a very detailed description of this group.")
|
.description("This is a very detailed description of this group.")
|
||||||
.create()
|
.create();
|
||||||
.groupUuid();
|
|
||||||
|
|
||||||
Optional<String> description = groupOperations.group(groupUuid).get().description();
|
Optional<String> description = groupOperations.group(groupUuid).get().description();
|
||||||
|
|
||||||
@@ -306,8 +291,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyDescriptionOfExistingGroupCanBeRetrieved() throws Exception {
|
public void emptyDescriptionOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearDescription().create();
|
||||||
groupOperations.newGroup().clearDescription().create().groupUuid();
|
|
||||||
|
|
||||||
Optional<String> description = groupOperations.group(groupUuid).get().description();
|
Optional<String> description = groupOperations.group(groupUuid).get().description();
|
||||||
|
|
||||||
@@ -318,7 +302,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void ownerGroupUuidOfExistingGroupCanBeRetrieved() throws Exception {
|
public void ownerGroupUuidOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID originalOwnerGroupUuid = new AccountGroup.UUID("owner group");
|
AccountGroup.UUID originalOwnerGroupUuid = new AccountGroup.UUID("owner group");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create().groupUuid();
|
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create();
|
||||||
|
|
||||||
AccountGroup.UUID ownerGroupUuid = groupOperations.group(groupUuid).get().ownerGroupUuid();
|
AccountGroup.UUID ownerGroupUuid = groupOperations.group(groupUuid).get().ownerGroupUuid();
|
||||||
|
|
||||||
@@ -327,10 +311,8 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void visibilityOfExistingGroupCanBeRetrieved() throws Exception {
|
public void visibilityOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID visibleGroupUuid =
|
AccountGroup.UUID visibleGroupUuid = groupOperations.newGroup().visibleToAll(true).create();
|
||||||
groupOperations.newGroup().visibleToAll(true).create().groupUuid();
|
AccountGroup.UUID invisibleGroupUuid = groupOperations.newGroup().visibleToAll(false).create();
|
||||||
AccountGroup.UUID invisibleGroupUuid =
|
|
||||||
groupOperations.newGroup().visibleToAll(false).create().groupUuid();
|
|
||||||
|
|
||||||
TestGroup visibleGroup = groupOperations.group(visibleGroupUuid).get();
|
TestGroup visibleGroup = groupOperations.group(visibleGroupUuid).get();
|
||||||
TestGroup invisibleGroup = groupOperations.group(invisibleGroupUuid).get();
|
TestGroup invisibleGroup = groupOperations.group(invisibleGroupUuid).get();
|
||||||
@@ -355,7 +337,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
Account.Id memberId2 = new Account.Id(2000);
|
Account.Id memberId2 = new Account.Id(2000);
|
||||||
Account.Id memberId3 = new Account.Id(3000);
|
Account.Id memberId3 = new Account.Id(3000);
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().members(memberId1, memberId2, memberId3).create().groupUuid();
|
groupOperations.newGroup().members(memberId1, memberId2, memberId3).create();
|
||||||
|
|
||||||
ImmutableSet<Account.Id> members = groupOperations.group(groupUuid).get().members();
|
ImmutableSet<Account.Id> members = groupOperations.group(groupUuid).get().members();
|
||||||
|
|
||||||
@@ -364,7 +346,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyMembersOfExistingGroupCanBeRetrieved() throws Exception {
|
public void emptyMembersOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearMembers().create().groupUuid();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearMembers().create();
|
||||||
|
|
||||||
ImmutableSet<Account.Id> members = groupOperations.group(groupUuid).get().members();
|
ImmutableSet<Account.Id> members = groupOperations.group(groupUuid).get().members();
|
||||||
|
|
||||||
@@ -377,11 +359,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
||||||
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2, subgroupUuid3).create();
|
||||||
.newGroup()
|
|
||||||
.subgroups(subgroupUuid1, subgroupUuid2, subgroupUuid3)
|
|
||||||
.create()
|
|
||||||
.groupUuid();
|
|
||||||
|
|
||||||
ImmutableSet<AccountGroup.UUID> subgroups = groupOperations.group(groupUuid).get().subgroups();
|
ImmutableSet<AccountGroup.UUID> subgroups = groupOperations.group(groupUuid).get().subgroups();
|
||||||
|
|
||||||
@@ -390,7 +368,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptySubgroupsOfExistingGroupCanBeRetrieved() throws Exception {
|
public void emptySubgroupsOfExistingGroupCanBeRetrieved() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create().groupUuid();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create();
|
||||||
|
|
||||||
ImmutableSet<AccountGroup.UUID> subgroups = groupOperations.group(groupUuid).get().subgroups();
|
ImmutableSet<AccountGroup.UUID> subgroups = groupOperations.group(groupUuid).get().subgroups();
|
||||||
|
|
||||||
@@ -399,8 +377,8 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateWithoutAnyParametersIsANoop() throws Exception {
|
public void updateWithoutAnyParametersIsANoop() throws Exception {
|
||||||
TestGroup originalGroup = groupOperations.newGroup().create();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().create();
|
||||||
AccountGroup.UUID groupUuid = originalGroup.groupUuid();
|
TestGroup originalGroup = groupOperations.group(groupUuid).get();
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().update();
|
groupOperations.group(groupUuid).forUpdate().update();
|
||||||
|
|
||||||
@@ -411,7 +389,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateWritesToInternalGroupSystem() throws Exception {
|
public void updateWritesToInternalGroupSystem() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().description("original description").create().groupUuid();
|
groupOperations.newGroup().description("original description").create();
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().description("updated description").update();
|
groupOperations.group(groupUuid).forUpdate().description("updated description").update();
|
||||||
|
|
||||||
@@ -421,8 +399,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nameCanBeUpdated() throws Exception {
|
public void nameCanBeUpdated() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().name("original name").create();
|
||||||
groupOperations.newGroup().name("original name").create().groupUuid();
|
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().name("updated name").update();
|
groupOperations.group(groupUuid).forUpdate().name("updated name").update();
|
||||||
|
|
||||||
@@ -433,7 +410,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void descriptionCanBeUpdated() throws Exception {
|
public void descriptionCanBeUpdated() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().description("original description").create().groupUuid();
|
groupOperations.newGroup().description("original description").create();
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().description("updated description").update();
|
groupOperations.group(groupUuid).forUpdate().description("updated description").update();
|
||||||
|
|
||||||
@@ -444,7 +421,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void descriptionCanBeCleared() throws Exception {
|
public void descriptionCanBeCleared() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().description("original description").create().groupUuid();
|
groupOperations.newGroup().description("original description").create();
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().clearDescription().update();
|
groupOperations.group(groupUuid).forUpdate().clearDescription().update();
|
||||||
|
|
||||||
@@ -456,7 +433,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void ownerGroupUuidCanBeUpdated() throws Exception {
|
public void ownerGroupUuidCanBeUpdated() throws Exception {
|
||||||
AccountGroup.UUID originalOwnerGroupUuid = new AccountGroup.UUID("original owner");
|
AccountGroup.UUID originalOwnerGroupUuid = new AccountGroup.UUID("original owner");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create().groupUuid();
|
groupOperations.newGroup().ownerGroupUuid(originalOwnerGroupUuid).create();
|
||||||
|
|
||||||
AccountGroup.UUID updatedOwnerGroupUuid = new AccountGroup.UUID("updated owner");
|
AccountGroup.UUID updatedOwnerGroupUuid = new AccountGroup.UUID("updated owner");
|
||||||
groupOperations.group(groupUuid).forUpdate().ownerGroupUuid(updatedOwnerGroupUuid).update();
|
groupOperations.group(groupUuid).forUpdate().ownerGroupUuid(updatedOwnerGroupUuid).update();
|
||||||
@@ -468,8 +445,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void visibilityCanBeUpdated() throws Exception {
|
public void visibilityCanBeUpdated() throws Exception {
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().visibleToAll(true).create();
|
||||||
groupOperations.newGroup().visibleToAll(true).create().groupUuid();
|
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().visibleToAll(false).update();
|
groupOperations.group(groupUuid).forUpdate().visibleToAll(false).update();
|
||||||
|
|
||||||
@@ -479,7 +455,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void membersCanBeAdded() throws Exception {
|
public void membersCanBeAdded() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearMembers().create().groupUuid();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearMembers().create();
|
||||||
|
|
||||||
Account.Id memberId1 = new Account.Id(1000);
|
Account.Id memberId1 = new Account.Id(1000);
|
||||||
Account.Id memberId2 = new Account.Id(2000);
|
Account.Id memberId2 = new Account.Id(2000);
|
||||||
@@ -493,8 +469,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void membersCanBeRemoved() throws Exception {
|
public void membersCanBeRemoved() throws Exception {
|
||||||
Account.Id memberId1 = new Account.Id(1000);
|
Account.Id memberId1 = new Account.Id(1000);
|
||||||
Account.Id memberId2 = new Account.Id(2000);
|
Account.Id memberId2 = new Account.Id(2000);
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
|
||||||
groupOperations.newGroup().members(memberId1, memberId2).create().groupUuid();
|
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().removeMember(memberId2).update();
|
groupOperations.group(groupUuid).forUpdate().removeMember(memberId2).update();
|
||||||
|
|
||||||
@@ -506,8 +481,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void memberAdditionAndRemovalCanBeMixed() throws Exception {
|
public void memberAdditionAndRemovalCanBeMixed() throws Exception {
|
||||||
Account.Id memberId1 = new Account.Id(1000);
|
Account.Id memberId1 = new Account.Id(1000);
|
||||||
Account.Id memberId2 = new Account.Id(2000);
|
Account.Id memberId2 = new Account.Id(2000);
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
|
||||||
groupOperations.newGroup().members(memberId1, memberId2).create().groupUuid();
|
|
||||||
|
|
||||||
Account.Id memberId3 = new Account.Id(3000);
|
Account.Id memberId3 = new Account.Id(3000);
|
||||||
groupOperations
|
groupOperations
|
||||||
@@ -525,8 +499,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void membersCanBeCleared() throws Exception {
|
public void membersCanBeCleared() throws Exception {
|
||||||
Account.Id memberId1 = new Account.Id(1000);
|
Account.Id memberId1 = new Account.Id(1000);
|
||||||
Account.Id memberId2 = new Account.Id(2000);
|
Account.Id memberId2 = new Account.Id(2000);
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
|
||||||
groupOperations.newGroup().members(memberId1, memberId2).create().groupUuid();
|
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().clearMembers().update();
|
groupOperations.group(groupUuid).forUpdate().clearMembers().update();
|
||||||
|
|
||||||
@@ -538,8 +511,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
public void furtherMembersCanBeAddedAfterClearingAll() throws Exception {
|
public void furtherMembersCanBeAddedAfterClearingAll() throws Exception {
|
||||||
Account.Id memberId1 = new Account.Id(1000);
|
Account.Id memberId1 = new Account.Id(1000);
|
||||||
Account.Id memberId2 = new Account.Id(2000);
|
Account.Id memberId2 = new Account.Id(2000);
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().members(memberId1, memberId2).create();
|
||||||
groupOperations.newGroup().members(memberId1, memberId2).create().groupUuid();
|
|
||||||
|
|
||||||
Account.Id memberId3 = new Account.Id(3000);
|
Account.Id memberId3 = new Account.Id(3000);
|
||||||
groupOperations.group(groupUuid).forUpdate().clearMembers().addMember(memberId3).update();
|
groupOperations.group(groupUuid).forUpdate().clearMembers().addMember(memberId3).update();
|
||||||
@@ -550,7 +522,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subgroupsCanBeAdded() throws Exception {
|
public void subgroupsCanBeAdded() throws Exception {
|
||||||
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create().groupUuid();
|
AccountGroup.UUID groupUuid = groupOperations.newGroup().clearSubgroups().create();
|
||||||
|
|
||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
||||||
@@ -570,7 +542,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create().groupUuid();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().removeSubgroup(subgroupUuid2).update();
|
groupOperations.group(groupUuid).forUpdate().removeSubgroup(subgroupUuid2).update();
|
||||||
|
|
||||||
@@ -583,7 +555,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create().groupUuid();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
||||||
groupOperations
|
groupOperations
|
||||||
@@ -602,7 +574,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create().groupUuid();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
groupOperations.group(groupUuid).forUpdate().clearSubgroups().update();
|
groupOperations.group(groupUuid).forUpdate().clearSubgroups().update();
|
||||||
|
|
||||||
@@ -615,7 +587,7 @@ public class GroupOperationsImplTest extends AbstractDaemonTest {
|
|||||||
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
AccountGroup.UUID subgroupUuid1 = new AccountGroup.UUID("subgroup 1");
|
||||||
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
AccountGroup.UUID subgroupUuid2 = new AccountGroup.UUID("subgroup 2");
|
||||||
AccountGroup.UUID groupUuid =
|
AccountGroup.UUID groupUuid =
|
||||||
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create().groupUuid();
|
groupOperations.newGroup().subgroups(subgroupUuid1, subgroupUuid2).create();
|
||||||
|
|
||||||
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
AccountGroup.UUID subgroupUuid3 = new AccountGroup.UUID("subgroup 3");
|
||||||
groupOperations
|
groupOperations
|
||||||
|
|||||||
Reference in New Issue
Block a user