Skip to content

Commit

Permalink
Updated QueryProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
g-ongetta committed Jan 20, 2020
1 parent 954fa42 commit 770bc5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/com/develogical/QueryProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public String process(String query) {
"English poet, playwright, and actor, widely regarded as the greatest " +
"writer in the English language and the world's pre-eminent dramatist.";
}

if (query.toLowerCase().contains("george")) {
return "George is an excellent man";
}

return "";
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/develogical/web/IndexPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class IndexPage extends HtmlPage {
protected void writeContentTo(PrintWriter writer) {
writer.println(
"<h1>Welcome!</h1>" +
"<p>Enter your query in the box below: " +
"<p>Enter your query in the box below (try asking about george!): " +
"<form><input type=\"text\" name=\"q\" />" +
"<input type=\"submit\">" +
"</form>" +
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/develogical/QueryProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ public void knowsAboutShakespeare() throws Exception {
public void isNotCaseSensitive() throws Exception {
assertThat(queryProcessor.process("shakespeare"), containsString("playwright"));
}

@Test
public void knowsAboutGeorge() throws Exception {
assertThat(queryProcessor.process("george"), containsString("excellent"));
}
}

0 comments on commit 770bc5d

Please sign in to comment.