public void testFirstConnection() throws Exception { accountDao.remove(); String response = WebConnectionManager.linkAccount(mContext); String expected = assetToString("account_link_test_output.json"); AccountLinkData data = JsonConverter.convertToAccountLinkData(expected); assertEquals(data.getOneTimeCode(), response); UUID token = new AccountDaoImpl(mContext).getConnectionToken(); assertEquals(data.getConnectionToken(), token); accountDao.remove(); }
public void testFailedSync() { // Creazione dati di test accountDao.remove(); UUID testToken = new UUID(0, 0); // token errato Account tempAccount = Account.createTempAccount(testToken); accountDao.set(tempAccount); List<Performance> randPerformance = new ArrayList<>(); for (int i = 0; i < 10; i++) { randPerformance.add(new PerformanceDaoImplTest().randomPerformance()); } performanceDao.add(randPerformance, true); // Sincronizzazione WebConnectionManager.Result result = WebConnectionManager.sync(mContext); assertEquals(WebConnectionManager.Result.UNLINKED, result); }
public void testSync() throws Exception { // Creazione dati di test accountDao.remove(); UUID testToken = UUID.fromString("790b9ab1-5c5c-4579-8c70-b9f433fcfbf8"); Account tempAccount = Account.createTempAccount(testToken); accountDao.set(tempAccount); List<Performance> randPerformance = new ArrayList<>(); for (int i = 0; i < 10; i++) { randPerformance.add(new PerformanceDaoImplTest().randomPerformance()); } performanceDao.add(randPerformance, true); // Sincronizzazione WebConnectionManager.Result result = WebConnectionManager.sync(mContext); assertEquals(WebConnectionManager.Result.SUCCESS, result); }