Skip to content

Commit 2ce59d3

Browse files
haqer1mpv1989
haqer1
authored andcommitted
Allow & account for pre-existing users other than ROOT to avoid unnecessary failures in src/test/java/com/arangodb/ArangoDBTest (#197)
* Fix-up for #178. * Allow & account for pre-existing users other than ROOT to avoid unnecessary failures in src/test/java/com/arangodb/ArangoDBTest: fixes issue #196. * Minor tweak. * Minor simplification in initial users loop.
1 parent 7146762 commit 2ce59d3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

+17-3
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;
@@ -60,7 +63,7 @@
6063

6164
/**
6265
* @author Mark Vollmary
63-
*
66+
* @author Reşat SABIQ
6467
*/
6568
@RunWith(Parameterized.class)
6669
public class ArangoDBTest {
@@ -191,12 +194,23 @@ 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();
199+
194200
arangoDB.createUser(USER, PW, null);
195201
final Collection<UserEntity> users = arangoDB.getUsers();
196202
assertThat(users, is(notNullValue()));
197-
assertThat(users.size(), is(2));
203+
assertThat(users.size(), is(initialUsers.size()+1));
204+
205+
List<Matcher<? super String>> matchers = new ArrayList<Matcher<? super String>>(users.size());
206+
// Add initial users, including root:
207+
for (final UserEntity userEntity : initialUsers)
208+
matchers.add(is(userEntity.getUser()));
209+
// Add USER:
210+
matchers.add(is(USER));
211+
198212
for (final UserEntity user : users) {
199-
assertThat(user.getUser(), anyOf(is(ROOT), is(USER)));
213+
assertThat(user.getUser(), anyOf(matchers));
200214
}
201215
} finally {
202216
arangoDB.deleteUser(USER);

0 commit comments

Comments
 (0)