### Question:
FilterIdAttribute extends Attribute { public String getFilterId() { return filterId; } FilterIdAttribute(String filter);  FilterIdAttribute(byte[] octets); String getFilterId(); String toStringImpl();  }### Answer:
@Test public void testTruncationOfString() throws IOException { String f253 = get253CharString(); String f259 = get259CharString(); FilterIdAttribute a = new FilterIdAttribute(f259); Assert.assertEquals(a.getFilterId(), f253, "filter id string should have been truncated to 254 chars"); byte[] bytes = a.getOctets(); Assert.assertEquals(bytes[0], AttributeType.FILTER_ID.getTypeCode()); Assert.assertEquals(bytes[1], ((byte) 255)); Assert.assertEquals(new String(bytes, 2, 253, Charset.forName("utf-8")), f253); }
@Test public void test253StringFits() throws IOException { String f253 = get253CharString(); FilterIdAttribute a = new FilterIdAttribute(f253); Assert.assertEquals(a.getFilterId(), f253, "253 byte filter id string should have been allowed"); byte[] bytes = a.getOctets(); Assert.assertEquals(bytes[0], AttributeType.FILTER_ID.getTypeCode()); Assert.assertEquals(bytes[1], ((byte) 255)); Assert.assertEquals(new String(bytes, 2, 253, Charset.forName("utf-8")), f253); }