Beispiel #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));
  }
Beispiel #2
0
  @Test
  public void testGetNetworkListByStatusIntInt() {
    init();

    List<Network> infosOfDB = readDBByUserId(_info.getUserId());
    List<Network> infosOfCache =
        AdapterFactory.getNetworkAdapter()
            .getNetworkListByStatus(_info.getUserId(), _info.getStatus());
    List<Network> infosOfReaderCache =
        AdapterFactory.getNetworkReaderAdapter()
            .getNetworkListByStatus(_info.getUserId(), _info.getStatus());

    Assert.assertTrue(isEqual(infosOfDB, _infos));
    Assert.assertTrue(isEqual(infosOfCache, _infos));
    Assert.assertTrue(isEqual(infosOfReaderCache, _infos));
  }
Beispiel #3
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);
  }
Beispiel #4
0
  @Test
  public void testGetNetworkListByStatusIntIntArray() {
    init();
    Network info = genInfoCopy(1);
    int status[] = {_info.getStatus(), info.getStatus()};
    setDBAndInfos(info.getId(), info);
    AdapterFactory.getNetworkAdapter().reloadNetworkList(_info.getUserId());

    List<Network> infosOfDB = readDBByUserId(_info.getUserId());
    List<Network> infosOfCache =
        AdapterFactory.getNetworkAdapter().getNetworkListByStatus(_info.getUserId(), status);
    List<Network> infosOfReaderCache =
        AdapterFactory.getNetworkReaderAdapter().getNetworkListByStatus(_info.getUserId(), status);

    Assert.assertTrue(isEqual(infosOfDB, _infos));
    Assert.assertTrue(isEqual(infosOfCache, _infos));
    Assert.assertTrue(isEqual(infosOfReaderCache, _infos));
  }
Beispiel #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;
  }
Beispiel #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);
 }