NlmLock implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final NlmLock other = (NlmLock) obj; if (this.offset != other.offset) { return false; } if (this.length != other.length) { return false; } if (this.lockType != other.lockType) { return false; } return this.owner.equals(other.owner); } NlmLock(StateOwner owner, int lockType, long offset, long length); StateOwner getOwner(); long getOffset(); long getLength(); int getLockType(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isSameOwner(NlmLock other); boolean isOverlappingRange(NlmLock other); boolean isConflictingType(NlmLock other); boolean isConflicting(NlmLock other); @Override String toString();  }
@Test public void shouldNotBeEqualByOwner() { NlmLock lock1 = new NlmLock(lo1, nfs_lock_type4.WRITE_LT, 0, nfs4_prot.NFS4_UINT64_MAX); NlmLock lock2 = new NlmLock(lo2, nfs_lock_type4.WRITE_LT, 0, nfs4_prot.NFS4_UINT64_MAX); assertFalse("lock with different owner can't be equal", lock1.equals(lock2)); }
@Test public void shouldNotBeEqualByOffset() { NlmLock lock1 = new NlmLock(lo1, nfs_lock_type4.WRITE_LT, 0, nfs4_prot.NFS4_UINT64_MAX); NlmLock lock2 = new NlmLock(lo1, nfs_lock_type4.WRITE_LT, 1, nfs4_prot.NFS4_UINT64_MAX); assertFalse("lock with different offsets can't be equal", lock1.equals(lock2)); }
@Test public void shouldNotBeEqualByType() { NlmLock lock1 = new NlmLock(lo1, nfs_lock_type4.WRITE_LT, 0, nfs4_prot.NFS4_UINT64_MAX); NlmLock lock2 = new NlmLock(lo1, nfs_lock_type4.READ_LT, 0, nfs4_prot.NFS4_UINT64_MAX); assertFalse("lock with different types can't be equal", lock1.equals(lock2)); }
@Test public void shouldNotBeEqualByLegth() { NlmLock lock1 = new NlmLock(lo1, nfs_lock_type4.WRITE_LT, 0, 1); NlmLock lock2 = new NlmLock(lo1, nfs_lock_type4.WRITE_LT, 0, 2); assertFalse("lock with different length can't be equal", lock1.equals(lock2)); }