Esempio n. 1
0
  public void testBrowseTradeHistory() {
    MasterController mc = new MasterController();
    mc.initializeController();
    UserDatabase db = mc.getUserDB();
    DatabaseController.deleteAllData();
    try {
      User bob = DatabaseController.createUser("Bob");
      User joel = DatabaseController.createUser("Joel");

      List<Skill> skillz1 = new ArrayList<Skill>(), skillz2 = new ArrayList<Skill>();
      skillz1.add(new Skill(db, "...YEP", "BAR", "desc", true, new ArrayList<Image>()));

      TradeList tl = bob.getTradeList();

      tl.createTrade(db, bob, joel, skillz2);
      Trade t1 = tl.getMostRecentTrade(db);

      tl.createTrade(db, bob, joel, skillz1);
      Trade t2 = tl.getMostRecentTrade(db);

      // Trade History Has been updated
      assertTrue(!t1.equals(t2));
    } catch (UserAlreadyExistsException e) {
      assertTrue(false);
    }
  }
Esempio n. 2
0
  public void testModifyActiveTrade() {
    MasterController mc = new MasterController();
    mc.initializeController();
    UserDatabase db = mc.getUserDB();
    DatabaseController.deleteAllData();
    try {
      User bob = DatabaseController.createUser("Bob");
      User joel = DatabaseController.createUser("Joel");

      List<Skill> skillz1 = new ArrayList<Skill>(), skillz2 = new ArrayList<Skill>();
      skillz1.add(new Skill(db, "...YEP", "FOO", "desc", true, new ArrayList<Image>()));

      TradeList tl = bob.getTradeList();
      tl.createTrade(db, bob, joel, skillz2);

      Trade t = tl.getMostRecentTrade(db);

      // Modify An Active Trade
      t.getHalfForUser(bob).setOffer(skillz1);
      List<ID> ids = new ArrayList<ID>();
      for (Skill skill : skillz1) {
        ids.add(skill.getSkillID());
      }
      assertEquals(t.getHalfForUser(bob).getOffer(), ids);

      // Delete An Active Trade
      tl.delete(t);
      assertTrue(tl.getActiveTrades(db).size() == 0);
    } catch (UserAlreadyExistsException e) {
      assertTrue(false);
    }
  }