### Question:
KeyStoreImpl implements KeyStore { @Override public KeyPair newAccount() throws CreateAccountException { return addKeyPairToStorage(KeyPair.random()); } KeyStoreImpl(@NonNull Store store, @NonNull BackupRestore backupRestore); @NonNull @Override List<KeyPair> loadAccounts(); @Override void deleteAccount(int index); @Override KeyPair newAccount(); @Override KeyPair importAccount(@NonNull String json, @NonNull String passphrase); @Override void clearAllAccounts();  }### Answer:
@Test public void newAccount() throws Exception { KeyStoreImpl keyStore = new KeyStoreImpl(new FakeStore(), new FakeBackupRestore()); KeyPair account = keyStore.newAccount(); assertNotNull(account); assertNotNull(account.getPublicKey()); assertNotNull(account.getSecretSeed()); }
@Test public void newAccount_JsonException_CreateAccountException() throws Exception { Store mockStore = mock(Store.class); when(mockStore.getString(anyString())) .thenReturn(KeyStoreImpl.ENCRYPTION_VERSION_NAME) .thenReturn("not a real json"); KeyStoreImpl keyStore = new KeyStoreImpl(mockStore, new FakeBackupRestore()); expectedEx.expect(CreateAccountException.class); expectedEx.expectCause(isA(JSONException.class)); keyStore.newAccount(); }