### Question:
LDAPFilter extends RawFilter { @Override public SearchFilter toSearchFilter() throws DirectoryException { ArrayList<SearchFilter> subComps; if (filterComponents == null) { subComps = null; } else { subComps = new ArrayList<>(filterComponents.size()); for (RawFilter f : filterComponents) { subComps.add(f.toSearchFilter()); } } SearchFilter notComp; if (notComponent == null) { notComp = null; } else { notComp = notComponent.toSearchFilter(); } AttributeType attrType; HashSet<String> options; if (attributeType == null) { attrType = null; options = null; } else { int semicolonPos = attributeType.indexOf(';'); if (semicolonPos > 0) { String baseName = attributeType.substring(0, semicolonPos); attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(baseName), baseName); options = new HashSet<>(); StringTokenizer tokenizer = new StringTokenizer(attributeType.substring(semicolonPos+1), ";"); while (tokenizer.hasMoreTokens()) { options.add(tokenizer.nextToken()); } } else { options = null; attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeType), attributeType); } } if (assertionValue != null && attrType == null) { if (matchingRuleID == null) { throw new DirectoryException(ResultCode.PROTOCOL_ERROR, ERR_LDAP_FILTER_VALUE_WITH_NO_ATTR_OR_MR.get()); } MatchingRule mr = DirectoryServer.getMatchingRule(toLowerCase(matchingRuleID)); if (mr == null) { throw new DirectoryException(ResultCode.INAPPROPRIATE_MATCHING, ERR_LDAP_FILTER_UNKNOWN_MATCHING_RULE.get(matchingRuleID)); } } ArrayList<ByteString> subAnyComps = subAnyElements != null ? new ArrayList<ByteString>(subAnyElements) : null; return new SearchFilter(filterType, subComps, notComp, attrType, options, assertionValue, subInitialElement, subAnyComps, subFinalElement, matchingRuleID, dnAttributes); } 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 public void testToSearchFilter() throws Exception { LDAPFilter filter = LDAPFilter.decode( "(&" + "(cn>=*)" + "(:2.5.13.2:=Bob)" + "(cn:=Jane)" + "(|" + "(sn<=gh*sh*sl)" + "(!(cn:dn:2.5.13.5:=Sally))" + "(cn~=blvd)" + "(cn=*)" + ")" + "(cn=*n)" + "(cn=n*)" + "(cn=n*n)" + "(:dn:1.3.6.1.4.1.1466.109.114.1:=Doe)" + "(cn:2.5.13.2:=)" + ")"); SearchFilter searchFilter = filter.toSearchFilter(); LDAPFilter newFilter = new LDAPFilter(searchFilter); assertEquals(filter.toString(), newFilter.toString()); }