### Question:
LDAPFilter extends RawFilter { public static LDAPFilter decode(String filterString) throws LDAPException { if (filterString == null) { LocalizableMessage message = ERR_LDAP_FILTER_STRING_NULL.get(); throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); } try { return decode(filterString, 0, filterString.length()); } catch (LDAPException le) { logger.traceException(le); throw le; } catch (Exception e) { logger.traceException(e); LocalizableMessage message = ERR_LDAP_FILTER_UNCAUGHT_EXCEPTION.get(filterString, e); throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message, e); } } LDAPFilter(FilterType filterType,
                    ArrayList<RawFilter> filterComponents,
                    RawFilter notComponent, String attributeType,
                    ByteString assertionValue, ByteString subInitialElement,
                    ArrayList<ByteString> subAnyElements,
                    ByteString subFinalElement, String matchingRuleID,
                    boolean dnAttributes);  LDAPFilter(SearchFilter filter); static LDAPFilter decode(String filterString); @Override FilterType getFilterType(); @Override ArrayList<RawFilter> getFilterComponents(); @Override RawFilter getNOTComponent(); @Override String getAttributeType(); @Override ByteString getAssertionValue(); @Override ByteString getSubInitialElement(); void setSubInitialElement(ByteString subInitialElement); @Override ArrayList<ByteString> getSubAnyElements(); @Override ByteString getSubFinalElement(); @Override String getMatchingRuleID(); @Override boolean getDNAttributes(); @Override SearchFilter toSearchFilter(); @Override void toString(StringBuilder buffer); static LDAPFilter objectClassPresent();  }### Answer:
@Test(dataProvider = "filterstrings") public void testDecode(String filterStr, LDAPFilter filter) throws Exception { LDAPFilter decoded = LDAPFilter.decode(filterStr); assertEquals(decoded.toString(), filter.toString()); assertEquals(decoded.getAssertionValue(), filter.getAssertionValue()); assertEquals(decoded.getAttributeType(), filter.getAttributeType()); assertEquals(decoded.getDNAttributes(), filter.getDNAttributes()); if(decoded.getFilterComponents() != null || filter.getFilterComponents() != null) { assertEquals(decoded.getFilterComponents().toString(), filter.getFilterComponents().toString()); } assertEquals(decoded.getFilterType(), filter.getFilterType()); assertEquals(decoded.getMatchingRuleID(), filter.getMatchingRuleID()); if(decoded.getNOTComponent() != null || filter.getNOTComponent() != null) { assertEquals(decoded.getNOTComponent().toString(), filter.getNOTComponent().toString()); } if(isNotEmpty(decoded.getSubAnyElements()) || isNotEmpty(filter.getSubAnyElements())) { assertEquals(decoded.getSubAnyElements(), filter.getSubAnyElements()); } if(isNotEmpty(decoded.getSubFinalElement()) || isNotEmpty(filter.getSubFinalElement())) { assertEquals(decoded.getSubFinalElement(), filter.getSubFinalElement()); } if(isNotEmpty(decoded.getSubInitialElement()) || isNotEmpty(filter.getSubInitialElement())) { assertEquals(decoded.getSubInitialElement(), filter.getSubInitialElement()); } }
@Test(dataProvider = "badfilterstrings", expectedExceptions = LDAPException.class) public void testDecodeException (String filterStr, LDAPFilter filter) throws Exception { LDAPFilter.decode(filterStr); }