PrimaryLock extends ThemisLock { @Override public boolean equals(Object object) { if (!(object instanceof PrimaryLock)) { return false; } PrimaryLock lock = (PrimaryLock)object; if (!super.equals((ThemisLock)lock)) { return false; } if (!lock.isPrimary()) { return false; } if (this.secondaryColumns.size() != lock.secondaryColumns.size()) { return false; } for (Entry<ColumnCoordinate, Type> columnAndType : secondaryColumns.entrySet()) { Type type = lock.secondaryColumns.get(columnAndType.getKey()); if (type == null || !columnAndType.getValue().equals(type)) { return false; } } return true; } PrimaryLock();  PrimaryLock(Type type); Type getSecondaryColumn(ColumnCoordinate columnCoordinate); Map<ColumnCoordinate, Type> getSecondaryColumns(); void addSecondaryColumn(ColumnCoordinate columnCoordinate, Type put); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override boolean equals(Object object); @Override String toString(); @Override boolean isPrimary();  }
@Test public void testWriteAndReadPrimaryLock() throws IOException { PrimaryLock expect = getPrimaryLock(); ThemisLock actual = new PrimaryLock(); writeObjectToBufferAndRead(expect, actual); Assert.assertTrue(expect.equals(actual)); }
@Test public void testToByteAndParseFromByte() throws IOException { PrimaryLock expect = getPrimaryLock(); byte[] lockByte = ThemisLock.toByte(expect); ThemisLock actual = ThemisLock.parseFromByte(lockByte); Assert.assertTrue(expect.equals(actual)); }