Skip to content

Commit d96558a

Browse files
author
Reşat SABIQ
committed
Allow & account for pre-existing users other than ROOT to avoid unnecessary failures in src/test/java/com/arangodb/ArangoDBTest: fixes issue #196.
1 parent 9083330 commit d96558a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/test/java/com/arangodb/ArangoDBTest.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
import static org.junit.Assert.assertThat;
3333
import static org.junit.Assert.fail;
3434

35+
import java.util.ArrayList;
3536
import java.util.Arrays;
3637
import java.util.Collection;
3738
import java.util.HashMap;
39+
import java.util.List;
3840
import java.util.Map;
3941

42+
import org.hamcrest.Matcher;
4043
import org.junit.Test;
4144
import org.junit.runner.RunWith;
4245
import org.junit.runners.Parameterized;
@@ -191,12 +194,25 @@ public void getUsersOnlyRoot() {
191194
@Test
192195
public void getUsers() {
193196
try {
197+
// Allow & account for pre-existing users other than ROOT
198+
final Collection<UserEntity> initialUsers = arangoDB.getUsers();
194199
arangoDB.createUser(USER, PW, null);
195200
final Collection<UserEntity> users = arangoDB.getUsers();
196201
assertThat(users, is(notNullValue()));
197-
assertThat(users.size(), is(2));
202+
assertThat(users.size(), is(initialUsers.size()+1));
203+
204+
List<Matcher<? super String>> matchers = new ArrayList<Matcher<? super String>>(users.size());
205+
// Add initial users, including root
206+
for (UserEntity userEntity : initialUsers) {
207+
Matcher<String> matcher = is(userEntity.getUser());
208+
if (!matchers.contains(matcher))
209+
matchers.add(matcher);
210+
}
211+
// Add USER
212+
matchers.add(is(USER));
213+
198214
for (final UserEntity user : users) {
199-
assertThat(user.getUser(), anyOf(is(ROOT), is(USER)));
215+
assertThat(user.getUser(), anyOf(matchers));
200216
}
201217
} finally {
202218
arangoDB.deleteUser(USER);

0 commit comments

Comments
 (0)