Пример #1
0
  /** ((networkId >= 60000000) && (networkId <= 70000000) && ((status == 0) || (status == -1))) */
  @Test
  public void testGetRegionalNetwork() {
    init();
    List<Network> all = readDBByRecordId(_info.getId());
    Network infoOfDB = null;
    for (int i = 0; i < all.size(); i++) {
      if (all.get(i).getNetworkId() >= 60000000
          && all.get(i).getNetworkId() <= 70000000
          && (all.get(i).getStatus() == 0 || all.get(i).getStatus() == -1)) {
        infoOfDB = all.get(i);
      }
    }
    Network infoOfOrigin = null;
    if (_info.getNetworkId() >= 60000000
        && _info.getNetworkId() <= 70000000
        && (_info.getStatus() == 0 || _info.getStatus() == -1)) {
      infoOfOrigin = _info;
    }

    Network infoOfCache = AdapterFactory.getNetworkAdapter().getRegionalNetwork(_info.getUserId());
    Network infoOfReaderCache =
        AdapterFactory.getNetworkReaderAdapter().getRegionalNetwork(_info.getUserId());

    System.out.println(
        infoOfOrigin
            + "\n---\n"
            + infoOfDB
            + "\n---\n"
            + infoOfCache
            + "\n---\n"
            + infoOfReaderCache);
    Assert.assertTrue(isEqual(infoOfDB, infoOfOrigin));
    Assert.assertTrue(isEqual(infoOfCache, infoOfOrigin));
    Assert.assertTrue(isEqual(infoOfReaderCache, infoOfOrigin));
  }
Пример #2
0
  @Test
  public void testRemoveNetwork() {
    init();

    _infos.remove(_info);
    AdapterFactory.getNetworkAdapter().removeNetwork(_info.getUserId(), _info.getNetworkId());
    checkAll();

    // Writer
    init();

    _infos.remove(_info);
    AdapterFactory.getNetworkWriterAdapter().removeNetwork(_info.getUserId(), _info.getNetworkId());
    checkAll();
  }
Пример #3
0
  @Test
  public void testGetNetwork() {
    init();

    Network infoOfDB = readDBByInfoId(_info.getNetworkId()).get(0);
    Network infoOfCache =
        AdapterFactory.getNetworkAdapter().getNetwork(_info.getUserId(), _info.getNetworkId());
    Network infoOfReaderCache =
        AdapterFactory.getNetworkReaderAdapter()
            .getNetwork(_info.getUserId(), _info.getNetworkId());

    Assert.assertTrue(isEqual(infoOfDB, _info));
    Assert.assertTrue(isEqual(infoOfCache, _info));
    Assert.assertTrue(isEqual(infoOfReaderCache, _info));
  }
Пример #4
0
  @Test
  public void testIsExistInNetwork() {
    init();

    Network infoOfDB = readDBByInfoId(_info.getNetworkId()).get(0);
    boolean isExistInInfo = _info.getStatus() <= 0;
    boolean isExistInDB = infoOfDB.getStatus() <= 0;
    boolean isExistInCache =
        AdapterFactory.getNetworkAdapter()
            .isExistInNetwork(_info.getUserId(), _info.getNetworkId());
    boolean isExistInReaderCache =
        AdapterFactory.getNetworkReaderAdapter()
            .isExistInNetwork(_info.getUserId(), _info.getNetworkId());

    Assert.assertEquals(isExistInDB, isExistInInfo);
    Assert.assertEquals(isExistInCache, isExistInInfo);
    Assert.assertEquals(isExistInReaderCache, isExistInInfo);
  }
Пример #5
0
  /**
   * 获取一份新的数据
   *
   * @param idStep
   * @return
   */
  protected Network genInfoCopy(int idStep) {
    Network result = new Network();
    result.setId(_info.getId() + idStep);
    result.setUserId(_info.getUserId());
    result.setStage(_info.getStage());
    result.setNetworkId(_info.getNetworkId() + idStep);
    result.setNetworkName(_info.getNetworkName() + ".new");
    result.setInfoId(_info.getInfoId());
    result.setJoinTime(_info.getJoinTime());
    result.setStatus(_info.getStatus() + idStep);

    return result;
  }
Пример #6
0
 protected void setDBAndInfos(int recordId, Network info) {
   String sql =
       "replace into network_history(id,userid,stage,network_id,network_name,info_id,join_time,status) values ("
           + recordId
           + ","
           + info.getUserId()
           + ","
           + info.getStage()
           + ","
           + info.getNetworkId()
           + ",'"
           + info.getNetworkName()
           + "',"
           + info.getInfoId()
           + ",'"
           + DateFormatter.format(info.getJoinTime())
           + "',"
           + info.getStatus()
           + ")";
   writeDB(sql);
   _infos.add(info);
 }