]> source.dussan.org Git - sonarqube.git/commitdiff
Remove dbunit usage from UserDaoTest and UserIndexerTest
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 9 Jun 2017 14:53:24 +0000 (16:53 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 20 Jun 2017 11:10:53 +0000 (04:10 -0700)
14 files changed:
server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml [deleted file]
server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml [deleted file]
server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java
server/sonar-server/src/test/resources/org/sonar/server/user/index/UserIndexerTest/index.xml [deleted file]

index c6f54ca0503d638872e9db809b8677f62599e975..ef3d48316b9d9306edd90840a28e96092661a3b3 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.db.user;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
@@ -35,6 +34,7 @@ import org.sonar.db.DbTester;
 import org.sonar.db.RowNotFoundException;
 
 import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
@@ -64,55 +64,57 @@ public class UserDaoTest {
 
   @Test
   public void selectUsersIds() {
-    db.prepareDbUnit(getClass(), "selectUsersByIds.xml");
+    UserDto user1 = db.users().insertUser(user -> user.setLogin("user1"));
+    UserDto user2 = db.users().insertUser(user -> user.setLogin("user2"));
+    UserDto user3 = db.users().insertUser(user -> user.setLogin("inactive_user").setActive(false));
 
-    Collection<UserDto> users = underTest.selectByIds(session, asList(100, 101, 987));
-    assertThat(users).hasSize(2);
-    assertThat(users).extracting("login").containsOnly("marius", "inactive_user");
-
-    assertThat(underTest.selectByIds(session, Collections.emptyList())).isEmpty();
+    assertThat(underTest.selectByIds(session, asList(user1.getId(), user2.getId(), user3.getId(), 1_000))).extracting("login")
+      .containsExactlyInAnyOrder("user1", "user2", "inactive_user");
+    assertThat(underTest.selectByIds(session, emptyList())).isEmpty();
   }
 
   @Test
   public void selectUserByLogin_ignore_inactive() {
-    db.prepareDbUnit(getClass(), "selectActiveUserByLogin.xml");
+    db.users().insertUser(user -> user.setLogin("user1"));
+    db.users().insertUser(user -> user.setLogin("user2"));
+    db.users().insertUser(user -> user.setLogin("inactive_user").setActive(false));
 
-    UserDto user = underTest.selectUserById(session, 50);
-    assertThat(user.getLogin()).isEqualTo("inactive_user");
+    UserDto user = underTest.selectActiveUserByLogin(session, "inactive_user");
 
-    user = underTest.selectActiveUserByLogin(session, "inactive_user");
     assertThat(user).isNull();
   }
 
   @Test
   public void selectUserByLogin_not_found() {
-    db.prepareDbUnit(getClass(), "selectActiveUserByLogin.xml");
+    db.users().insertUser(user -> user.setLogin("user"));
 
     UserDto user = underTest.selectActiveUserByLogin(session, "not_found");
+
     assertThat(user).isNull();
   }
 
   @Test
   public void selectUsersByLogins() {
-    db.prepareDbUnit(getClass(), "selectUsersByLogins.xml");
+    db.users().insertUser(user -> user.setLogin("user1"));
+    db.users().insertUser(user -> user.setLogin("user2"));
+    db.users().insertUser(user -> user.setLogin("inactive_user").setActive(false));
 
-    Collection<UserDto> users = underTest.selectByLogins(session, asList("marius", "inactive_user", "other"));
-    assertThat(users).hasSize(2);
-    assertThat(users).extracting("login").containsOnly("marius", "inactive_user");
+    Collection<UserDto> users = underTest.selectByLogins(session, asList("user1", "inactive_user", "other"));
+
+    assertThat(users).extracting("login").containsExactlyInAnyOrder("user1", "inactive_user");
   }
 
   @Test
   public void selectUsersByLogins_empty_logins() {
     // no need to access db
-    Collection<UserDto> users = underTest.selectByLogins(session, Collections.emptyList());
+    Collection<UserDto> users = underTest.selectByLogins(session, emptyList());
     assertThat(users).isEmpty();
   }
 
   @Test
   public void selectByOrderedLogins() {
-    underTest.insert(session, newUserDto().setLogin("U1").setActive(true));
-    underTest.insert(session, newUserDto().setLogin("U2").setActive(true));
-    session.commit();
+    db.users().insertUser(user -> user.setLogin("U1"));
+    db.users().insertUser(user -> user.setLogin("U2"));
 
     Iterable<UserDto> users = underTest.selectByOrderedLogins(session, asList("U1", "U2", "U3"));
     assertThat(users).extracting("login").containsExactly("U1", "U2");
@@ -120,61 +122,63 @@ public class UserDaoTest {
     users = underTest.selectByOrderedLogins(session, asList("U2", "U3", "U1"));
     assertThat(users).extracting("login").containsExactly("U2", "U1");
 
-    assertThat(underTest.selectByOrderedLogins(session, Collections.emptyList())).isEmpty();
+    assertThat(underTest.selectByOrderedLogins(session, emptyList())).isEmpty();
   }
 
   @Test
   public void selectUsersByQuery_all() {
-    db.prepareDbUnit(getClass(), "selectUsersByQuery.xml");
+    db.users().insertUser(user -> user.setLogin("user").setName("User"));
+    db.users().insertUser(user -> user.setLogin("inactive_user").setName("Disabled").setActive(false));
+
+    List<UserDto> users = underTest.selectUsers(session, UserQuery.builder().includeDeactivated().build());
 
-    UserQuery query = UserQuery.builder().includeDeactivated().build();
-    List<UserDto> users = underTest.selectUsers(session, query);
     assertThat(users).hasSize(2);
   }
 
   @Test
   public void selectUsersByQuery_only_actives() {
-    db.prepareDbUnit(getClass(), "selectUsersByQuery.xml");
+    db.users().insertUser(user -> user.setLogin("user").setName("User"));
+    db.users().insertUser(user -> user.setLogin("inactive_user").setName("Disabled").setActive(false));
 
-    UserQuery query = UserQuery.ALL_ACTIVES;
-    List<UserDto> users = underTest.selectUsers(session, query);
-    assertThat(users).hasSize(1);
-    assertThat(users.get(0).getName()).isEqualTo("Marius");
+    List<UserDto> users = underTest.selectUsers(session, UserQuery.ALL_ACTIVES);
+
+    assertThat(users).extracting(UserDto::getName).containsExactlyInAnyOrder("User");
   }
 
   @Test
   public void selectUsersByQuery_filter_by_login() {
-    db.prepareDbUnit(getClass(), "selectUsersByQuery.xml");
+    db.users().insertUser(user -> user.setLogin("user").setName("User"));
+    db.users().insertUser(user -> user.setLogin("inactive_user").setName("Disabled").setActive(false));
 
-    UserQuery query = UserQuery.builder().logins("marius", "john").build();
-    List<UserDto> users = underTest.selectUsers(session, query);
-    assertThat(users).hasSize(1);
-    assertThat(users.get(0).getName()).isEqualTo("Marius");
+    List<UserDto> users = underTest.selectUsers(session, UserQuery.builder().logins("user", "john").build());
+
+    assertThat(users).extracting(UserDto::getName).containsExactlyInAnyOrder("User");
   }
 
   @Test
   public void selectUsersByQuery_search_by_login_text() {
-    db.prepareDbUnit(getClass(), "selectUsersByText.xml");
+    db.users().insertUser(user -> user.setLogin("user").setName("User"));
+    db.users().insertUser(user -> user.setLogin("sbrandhof").setName("Simon Brandhof"));
 
-    UserQuery query = UserQuery.builder().searchText("sbr").build();
-    List<UserDto> users = underTest.selectUsers(session, query);
-    assertThat(users).hasSize(1);
-    assertThat(users.get(0).getLogin()).isEqualTo("sbrandhof");
+    List<UserDto> users = underTest.selectUsers(session, UserQuery.builder().searchText("sbr").build());
+
+    assertThat(users).extracting(UserDto::getLogin).containsExactlyInAnyOrder("sbrandhof");
   }
 
   @Test
   public void selectUsersByQuery_search_by_name_text() {
-    db.prepareDbUnit(getClass(), "selectUsersByText.xml");
+    db.users().insertUser(user -> user.setLogin("user").setName("User"));
+    db.users().insertUser(user -> user.setLogin("sbrandhof").setName("Simon Brandhof"));
 
-    UserQuery query = UserQuery.builder().searchText("Simon").build();
-    List<UserDto> users = underTest.selectUsers(session, query);
-    assertThat(users).hasSize(1);
-    assertThat(users.get(0).getLogin()).isEqualTo("sbrandhof");
+    List<UserDto> users = underTest.selectUsers(session, UserQuery.builder().searchText("Simon").build());
+
+    assertThat(users).extracting(UserDto::getLogin).containsExactlyInAnyOrder("sbrandhof");
   }
 
   @Test
   public void selectUsersByQuery_escape_special_characters_in_like() {
-    db.prepareDbUnit(getClass(), "selectUsersByText.xml");
+    db.users().insertUser(user -> user.setLogin("user").setName("User"));
+    db.users().insertUser(user -> user.setLogin("sbrandhof").setName("Simon Brandhof"));
 
     UserQuery query = UserQuery.builder().searchText("%s%").build();
     // we expect really a login or name containing the 3 characters "%s%"
@@ -339,7 +343,7 @@ public class UserDaoTest {
 
   @Test
   public void update_user() {
-    UserDto existingUser = new UserDto()
+    UserDto existingUser = db.users().insertUser(user -> user
       .setLogin("john")
       .setName("John")
       .setEmail("jo@hn.com")
@@ -347,9 +351,7 @@ public class UserDaoTest {
       .setUpdatedAt(1418215735482L)
       .setActive(true)
       .setLocal(true)
-      .setOnboarded(false);
-    db.getDbClient().userDao().insert(db.getSession(), existingUser);
-    db.getSession().commit();
+      .setOnboarded(false));
 
     UserDto userDto = new UserDto()
       .setId(1)
@@ -416,10 +418,21 @@ public class UserDaoTest {
 
   @Test
   public void select_by_login() {
-    db.prepareDbUnit(getClass(), "select_by_login.xml");
+    UserDto user1 = db.users().insertUser(user -> user
+      .setLogin("marius")
+      .setName("Marius")
+      .setEmail("marius@lesbronzes.fr")
+      .setActive(true)
+      .setScmAccounts("\nma\nmarius33\n")
+      .setSalt("79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365")
+      .setCryptedPassword("650d2261c98361e2f67f90ce5c65a95e7d8ea2fg")
+      .setCreatedAt(1418215735482L)
+      .setUpdatedAt(1418215735485L));
+    UserDto user2 = db.users().insertUser(user -> user.setLogin("sbrandhof"));
+    underTest.setRoot(session, user2.getLogin(), true);
 
     UserDto dto = underTest.selectOrFailByLogin(session, "marius");
-    assertThat(dto.getId()).isEqualTo(101);
+    assertThat(dto.getId()).isEqualTo(user1.getId());
     assertThat(dto.getLogin()).isEqualTo("marius");
     assertThat(dto.getName()).isEqualTo("Marius");
     assertThat(dto.getEmail()).isEqualTo("marius@lesbronzes.fr");
@@ -437,36 +450,23 @@ public class UserDaoTest {
 
   @Test
   public void select_nullable_by_scm_account() {
-    db.prepareDbUnit(getClass(), "select_nullable_by_scm_account.xml");
-
-    List<UserDto> results = underTest.selectByScmAccountOrLoginOrEmail(session, "ma");
-    assertThat(results).hasSize(1);
-    assertThat(results.get(0).getLogin()).isEqualTo("marius");
+    db.users().insertUser(user -> user.setLogin("marius").setName("Marius").setEmail("marius@lesbronzes.fr").setScmAccounts(asList("ma", "marius33")));
+    db.users().insertUser(user -> user.setLogin("sbrandhof").setName("Simon Brandhof").setEmail("sbrandhof@lesbronzes.fr").setScmAccounts((String) null));
 
-    results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius");
-    assertThat(results).hasSize(1);
-    assertThat(results.get(0).getLogin()).isEqualTo("marius");
-
-    results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr");
-    assertThat(results).hasSize(1);
-    assertThat(results.get(0).getLogin()).isEqualTo("marius");
-
-    results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr");
-    assertThat(results).hasSize(1);
-    assertThat(results.get(0).getLogin()).isEqualTo("marius");
-
-    results = underTest.selectByScmAccountOrLoginOrEmail(session, "m");
-    assertThat(results).isEmpty();
-
-    results = underTest.selectByScmAccountOrLoginOrEmail(session, "unknown");
-    assertThat(results).isEmpty();
+    assertThat(underTest.selectByScmAccountOrLoginOrEmail(session, "ma")).extracting(UserDto::getLogin).containsExactly("marius");
+    assertThat(underTest.selectByScmAccountOrLoginOrEmail(session, "marius")).extracting(UserDto::getLogin).containsExactly("marius");
+    assertThat(underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr")).extracting(UserDto::getLogin).containsExactly("marius");
+    assertThat(underTest.selectByScmAccountOrLoginOrEmail(session, "m")).isEmpty();
+    assertThat(underTest.selectByScmAccountOrLoginOrEmail(session, "unknown")).isEmpty();
   }
 
   @Test
   public void select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users() {
-    db.prepareDbUnit(getClass(), "select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml");
+    db.users().insertUser(user -> user.setLogin("marius").setName("Marius").setEmail("marius@lesbronzes.fr").setScmAccounts(asList("ma", "marius33")));
+    db.users().insertUser(user -> user.setLogin("sbrandhof").setName("Simon Brandhof").setEmail("marius@lesbronzes.fr").setScmAccounts((String) null));
 
     List<UserDto> results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr");
+
     assertThat(results).hasSize(2);
   }
 
@@ -482,10 +482,10 @@ public class UserDaoTest {
 
   @Test
   public void select_nullable_by_login() {
-    db.prepareDbUnit(getClass(), "select_by_login.xml");
+    db.users().insertUser(user -> user.setLogin("marius"));
+    db.users().insertUser(user -> user.setLogin("sbrandhof"));
 
     assertThat(underTest.selectByLogin(session, "marius")).isNotNull();
-
     assertThat(underTest.selectByLogin(session, "unknown")).isNull();
   }
 
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/exists_by_email.xml
deleted file mode 100644 (file)
index 2226bb3..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="&#10;ma&#10;marius33&#10;"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="sbrandhof"
-         name="Simon Brandhof"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="[null]"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/insert-result.xml
deleted file mode 100644 (file)
index fe3a433..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<dataset>
-  <users id="1"
-         login="john"
-         name="John"
-         email="jo@hn.com"
-         created_at="1418215735482"
-         updated_at="1418215735482"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectActiveUserByLogin.xml
deleted file mode 100644 (file)
index fba9650..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<dataset>
-  <!-- inactive -->
-  <users id="50"
-         login="inactive_user"
-         name="Disabled"
-         email="inactive@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[false]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-  <!-- active -->
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-  <users id="102"
-         login="jcdus"
-         name="Jean-Claude Dus"
-         email="jcdus@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByIds.xml
deleted file mode 100644 (file)
index 7340c94..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<dataset>
-  <users id="100"
-         login="inactive_user"
-         name="Disabled"
-         email="inactive@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[false]"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="jcdus"
-         name="Jean-Claude Dus"
-         email="jcdus@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByLogins.xml
deleted file mode 100644 (file)
index 7340c94..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<dataset>
-  <users id="100"
-         login="inactive_user"
-         name="Disabled"
-         email="inactive@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[false]"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="jcdus"
-         name="Jean-Claude Dus"
-         email="jcdus@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByQuery.xml
deleted file mode 100644 (file)
index 246d4ca..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<dataset>
-  <users id="100"
-         login="inactive_user"
-         name="Disabled"
-         email="inactive@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[false]"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/selectUsersByText.xml
deleted file mode 100644 (file)
index c4308ee..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<dataset>
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="sbrandhof"
-         name="Simon Brandhof"
-         email="marius@lesbronzes.fr"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_by_login.xml
deleted file mode 100644 (file)
index 2ac7804..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="&#10;ma&#10;marius33&#10;"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="sbrandhof"
-         name="Simon Brandhof"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="[null]"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh"
-         is_root="[true]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account.xml
deleted file mode 100644 (file)
index 54b486e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="&#10;ma&#10;marius33&#10;"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="sbrandhof"
-         name="Simon Brandhof"
-         email="sbrandhof@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="[null]"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml
deleted file mode 100644 (file)
index 2226bb3..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-
-  <users id="101"
-         login="marius"
-         name="Marius"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="&#10;ma&#10;marius33&#10;"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fg"
-         is_root="[false]"
-         onboarded="[true]"/>
-  <users id="102"
-         login="sbrandhof"
-         name="Simon Brandhof"
-         email="marius@lesbronzes.fr"
-         active="[true]"
-         scm_accounts="[null]"
-         created_at="1418215735482"
-         updated_at="1418215735485"
-         salt="79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8366"
-         crypted_password="650d2261c98361e2f67f90ce5c65a95e7d8ea2fh"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>
diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/user/UserDaoTest/update_user.xml
deleted file mode 100644 (file)
index fe3a433..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<dataset>
-  <users id="1"
-         login="john"
-         name="John"
-         email="jo@hn.com"
-         created_at="1418215735482"
-         updated_at="1418215735482"
-         active="[true]"
-         is_root="[false]"
-         onboarded="[true]"/>
-</dataset>
index 4726c05b82865b72333b4d9bc22f318cc20516ae..d17ed19990be34bf4b455914609e5ef58056d1db 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.user.index;
 
-import java.util.Arrays;
 import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
@@ -29,6 +28,7 @@ import org.sonar.db.DbTester;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.es.EsTester;
 
+import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class UserIndexerTest {
@@ -52,7 +52,14 @@ public class UserIndexerTest {
 
   @Test
   public void index_everything_on_startup() {
-    db.prepareDbUnit(getClass(), "index.xml");
+    db.users().insertUser(user -> user
+      .setLogin("user1")
+      .setName("User1")
+      .setEmail("user1@mail.com")
+      .setActive(true)
+      .setScmAccounts(asList("user_1", "u1"))
+      .setCreatedAt(1500000000000L)
+      .setUpdatedAt(1500000000000L));
 
     underTest.indexOnStartup(null);
 
@@ -98,7 +105,7 @@ public class UserIndexerTest {
     UserDto user = db.users().insertUser();
     UserDto anotherUser = db.users().insertUser();
 
-    underTest.index(Arrays.asList(user.getLogin(), anotherUser.getLogin()));
+    underTest.index(asList(user.getLogin(), anotherUser.getLogin()));
 
     List<UserDoc> docs = es.getDocuments(UserIndexDefinition.INDEX_TYPE_USER, UserDoc.class);
     assertThat(docs).hasSize(2);
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/user/index/UserIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/user/index/UserIndexerTest/index.xml
deleted file mode 100644 (file)
index c375007..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<dataset>
-
-  <users id="1"
-         login="user1"
-         name="User1"
-         email="user1@mail.com"
-         active="[true]"
-         scm_accounts="&#10;user_1&#10;u1&#10;"
-         created_at="1500000000000"
-         updated_at="1500000000000"
-         is_root="[false]"
-         onboarded="[true]"/>
-
-</dataset>