Simplify BatchUpdateTest and CommitsCollectionTest

Both of these tests use exactly the setup provided by
InMemoryTestEnvironment. Use that JUnit rule to avoid duplicate code and
improve readability of those classes.

The previous code in BatchUpdateTest and CommitsCollectionTest closed
the created repository after use. This shouldn't be necessary as the
Javadoc of InMemoryRepository states that closing the repository has no
impact on its memory/GC.

Change-Id: I64f62a3acb38b18030f00ebb41b662be7c602900
This commit is contained in:
Alice Kober-Sotzek
2018-01-31 13:41:36 +01:00
committed by David Pursehouse
parent 25ea50afa4
commit d4967d7b90
3 changed files with 46 additions and 142 deletions

View File

@@ -121,7 +121,9 @@ public final class InMemoryTestEnvironment implements MethodRule {
schemaCreator.create(underlyingDb);
}
db = schemaFactory.open();
setApiUser(accountManager.authenticate(AuthRequest.forUser("user")).getAccountId());
// The first user is added to the "Administrators" group. See AccountManager#create().
setApiUser(accountManager.authenticate(AuthRequest.forUser("admin")).getAccountId());
// Inject target members after setting API user, so it can @Inject a ReviewDb if it wants.
injector.injectMembers(target);