EstEidLdapFilter extends LdapFilter { @Override String filterString() { if (isSerialNumberSearch()) { return String.format(Locale.US, "(serialNumber= PNOEE-%s)", getQuery()); } else { return String.format(Locale.US, "(cn= %s)", getQuery()); } } EstEidLdapFilter(String query);   }
@Test public void shouldReturnSerialNumberFilterStringWhenSerialNumberQuery() { String filterString = new EstEidLdapFilter(SERIAL_NUMBER_QUERY).filterString(); assertThat(filterString, is("(serialNumber= PNOEE-" + SERIAL_NUMBER_QUERY + ")")); }
@Test public void shouldReturnCnFilterStringWhenNotSerialNumberQuery() { String filterString = new EstEidLdapFilter(CN_QUERY).filterString(); assertThat(filterString, is("(cn= " + CN_QUERY + ")")); }