diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java index 1e536c85a..7e45f1628 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeyWritableRepository.java @@ -36,6 +36,7 @@ import android.database.Cursor; import android.net.Uri; import android.os.RemoteException; import android.support.annotation.NonNull; +import android.support.annotation.VisibleForTesting; import android.support.v4.util.LongSparseArray; import org.openintents.openpgp.util.OpenPgpUtils; @@ -98,15 +99,13 @@ public class KeyWritableRepository extends KeyRepository { return new KeyWritableRepository(context, localPublicKeyStorage); } - private KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage) { + @VisibleForTesting + KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage) { this(context, localPublicKeyStorage, new OperationLog(), 0); } - private KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log) { - this(context, localPublicKeyStorage, log, 0); - } - - private KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) { + private KeyWritableRepository( + Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) { super(context.getContentResolver(), localPublicKeyStorage, log, indent); mContext = context; diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java index bd75e356b..9d5a6a919 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java @@ -243,7 +243,8 @@ public class InteropTest { final Uri verifyUri = verify != null ? KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null; - KeyWritableRepository helper = new KeyWritableRepository(RuntimeEnvironment.application) { + KeyWritableRepository helper = new KeyWritableRepository(RuntimeEnvironment.application, + LocalPublicKeyStorage.getInstance(RuntimeEnvironment.application)) { @Override public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException { diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/support/KeyRepositoryStub.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/support/KeyRepositoryStub.java deleted file mode 100644 index d96019e0f..000000000 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/support/KeyRepositoryStub.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) Art O Cathain - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.support; - -import android.content.Context; -import android.net.Uri; - -import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; -import org.sufficientlysecure.keychain.provider.KeyWritableRepository; - - -class KeyRepositoryStub extends KeyWritableRepository { - public KeyRepositoryStub(Context context) { - super(context); - } - - @Override - public CanonicalizedPublicKeyRing getCanonicalizedPublicKeyRing(Uri id) throws NotFoundException { - byte[] data = TestDataUtil.readFully(getClass().getResourceAsStream("/public-key-for-sample.blob")); - return new CanonicalizedPublicKeyRing(data, 0); - } -}