WakeupRequestFilter implements RequestFilter { @Override public Request filter(Request request) { if (this.wakeupWord != null) { request.setText(request.getText().replace(this.wakeupWord, "").trim()); } return request; } WakeupRequestFilter(String wakeupWord); @Override Request filter(Request request);  }
@Test public void wakeupFilter() { String strRequest = "Dorset 2 + 2"; String strFilteredRequest = "2 + 2"; RequestFilter requestFilter = new WakeupRequestFilter("Dorset"); Request request = new Request(strRequest); request = requestFilter.filter(request); assertEquals(strFilteredRequest, request.getText()); }
@Test public void wakeupFilterNull() { String strRequest = "Dorset 2 + 2"; RequestFilter requestFilter = new WakeupRequestFilter(null); Request request = new Request(strRequest); request = requestFilter.filter(request); assertEquals(strRequest, request.getText()); }