@Test(dependsOnMethods = {"initTokenHandler"}, expectedExceptions = BadRequestException.class )

public void valueReplaceMissingToken() throws BadRequestException {
    String queryString = "select ${unquoted:_fields} from ${unquoted:_resource} where firstname = ${firstname} and lastname like '${unquoted:lastname}%'";
    Map params = new HashMap();
    params.put("_fields", "*");
    params.put("_resource", "managed/user");
    // don't define firstname, should fail
    params.put("lastname", "D");
    String result = tokenHandler.replaceTokensWithValues(queryString, params);
    assertEquals(result, "select * from managed/user where firstname = 'John' and lastname like 'D%'");
}