Ejemplo n.º 1
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   accountDao = new AccountDaoImpl(mContext);
   performanceDao = new PerformanceDaoImpl(mContext);
   WebConnectionManager.setConnUrl("http://www.shike.it/provasync/conn.php");
   WebConnectionManager.setSyncUrl("http://www.shike.it/provasync/sync.php");
 }
Ejemplo n.º 2
0
  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();
  }
Ejemplo n.º 3
0
  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);
  }
Ejemplo n.º 4
0
  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);
  }