TextRecord extends DiscoveryRecord { public final static TextRecord build( Set<TextRecord> txtsRec ) { StringBuilder flattened = new StringBuilder(); String owner = null; long max = Long.MIN_VALUE; for(TextRecord txt: txtsRec) { flattened.append(txt.getRData()); if(txt.getTtl() > max) max = txt.getTtl(); if(owner == null) owner = txt.getOwner(); } return new TextRecord(owner, flattened.toString(), max); } private  TextRecord( String txtData, long ttl ); private  TextRecord( String owner, String txtData, long ttl ); final static TextRecord build( Set<TextRecord> txtsRec ); final static TextRecord build( TXTRecord txtRec ); @Override String getServiceType(); @Override String getServiceZone( String dnsLabel ); @Override String getServiceName( String dnsLabel ); @Override String toString(); @Override String toDisplay();  }
@Test public void testEqualsObject () throws TextParseException { TextRecord txt1 = TextRecord.build( DiscoveryRecordUtil.createTxtRecord( "txt1", 3600 ) ); TextRecord txt2 = TextRecord.build( DiscoveryRecordUtil.createTxtRecord( "txt1", 3600 ) ); Assert.assertTrue( "Both text records should be equal", txt1.equals( txt2 ) ); }
@Test public void testNotEqualsObject () throws TextParseException { TextRecord txt1 = TextRecord.build( DiscoveryRecordUtil.createTxtRecord( "txt1", 3600 ) ); TextRecord txt2 = TextRecord.build( DiscoveryRecordUtil.createTxtRecord( "txt2", 3600 ) ); Assert.assertTrue( "Both text records should not be equal", !txt1.equals( txt2 ) ); }