@Test public void toStringTest() { UserInfo tUserInfo = new UserInfo(99); tUserInfo.addOwnBytes(2093); tUserInfo.addOwnBytes(-1029); Assert.assertEquals("UserInfo( USER_ID: 99, mOwnBytes: 1064, mLastHeartbeatMs: ", tUserInfo .toString().substring(0, 58)); }
@Override public synchronized String toString() { StringBuilder sb = new StringBuilder("UserInfo("); sb.append(" USER_ID: ").append(USER_ID); sb.append(", mOwnBytes: ").append(mOwnBytes); sb.append(", mLastHeartbeatMs: ").append(mLastHeartbeatMs); sb.append(")"); return sb.toString(); }
UserInfo { @Override public synchronized String toString() { StringBuilder sb = new StringBuilder("UserInfo("); sb.append(" USER_ID: ").append(USER_ID); sb.append(", mOwnBytes: ").append(mOwnBytes); sb.append(", mLastHeartbeatMs: ").append(mLastHeartbeatMs); sb.append(")"); return sb.toString(); } }
UserInfo { @Override public synchronized String toString() { StringBuilder sb = new StringBuilder("UserInfo("); sb.append(" USER_ID: ").append(USER_ID); sb.append(", mOwnBytes: ").append(mOwnBytes); sb.append(", mLastHeartbeatMs: ").append(mLastHeartbeatMs); sb.append(")"); return sb.toString(); } UserInfo(long userId); }
UserInfo { @Override public synchronized String toString() { StringBuilder sb = new StringBuilder("UserInfo("); sb.append(" USER_ID: ").append(USER_ID); sb.append(", mOwnBytes: ").append(mOwnBytes); sb.append(", mLastHeartbeatMs: ").append(mLastHeartbeatMs); sb.append(")"); return sb.toString(); } UserInfo(long userId); synchronized void addOwnBytes(long addOwnBytes); synchronized long getOwnBytes(); long getUserId(); synchronized void heartbeat(); synchronized boolean timeout(); @Override synchronized String toString(); }
UserInfo { @Override public synchronized String toString() { StringBuilder sb = new StringBuilder("UserInfo("); sb.append(" USER_ID: ").append(USER_ID); sb.append(", mOwnBytes: ").append(mOwnBytes); sb.append(", mLastHeartbeatMs: ").append(mLastHeartbeatMs); sb.append(")"); return sb.toString(); } UserInfo(long userId); synchronized void addOwnBytes(long addOwnBytes); synchronized long getOwnBytes(); long getUserId(); synchronized void heartbeat(); synchronized boolean timeout(); @Override synchronized String toString();  }