[Demonstration 1]

[Buggy Method]
@Override
public String qnameFor(String uri) {
    int split = Util.splitNamespaceXML(uri);
    String ns = uri.substring(0, split), local = uri.substring(split);
    if (local.equals(""))
        return null;
    String prefix = getNsURIPrefix(uri);
    return prefix == null ? null : prefix + ":" + local;
}

[Buggy Hunk]
String prefix = getNsURIPrefix(uri) ;

[Patch]
String prefix = getNsURIPrefix(ns) ;

[Demonstration 2]

[Buggy Method]
@Path(path = "update", login = true, access = "access.config.admin", log = Model.METHOD_POST)
public void update() {
    String collection = this.getString("collection");
    String id = this.getString("id");
    if (method.isPost()) {
        String body = this.getHtml("body");
        if (!X.isEmpty(collection) && !X.isEmpty(body)) {
            Data.update(collection, JSONObject.fromObject(body));
            detail();
            return;
        }
    } else {
        this.set("collection", collection);
        this.set("id", id);
        Data d = Data.load(collection, id);
        if (d != null) {
            this.set("body", d.getAll().toString());
        }
    }
    this.show("/admin/data.update.html");
}

[Buggy Hunk]
this.set("body", d.getAll().toString());

[Patch]
this.set("body", d.getJSON().toString());

[Demonstration 3]

[Buggy Method]
@Test
public void findPage() {
    // mock service method
    int pageNo = 1;
    int pageSize = 25;
    long totalCount = 100;
    CommonState status = CommonState.Enabled;
    Integer id = 1;
    List<Demo> list = new ArrayList<>();
    Demo dto = mock(Demo.class);
    dto.id = id;
    list.add(dto);
    Page<Demo> page = Page.build(pageNo, pageSize, list, totalCount);
    when(service.find(pageNo, pageSize, status)).thenReturn(page);
    // execute rest
    ResponseEntity<Map> response = this.restTemplate.getForEntity("/demo/page?pageNo={0}&pageSize={1}&status={2}", Map.class, pageNo, pageSize, status);
    // verify
    verify(service, times(1)).find(pageNo, pageSize, status);
    assertThat(response.getStatusCode(), is(HttpStatus.OK));
    assertThat(response.getHeaders().getContentType(), is(MediaType.APPLICATION_JSON));
    Map body = response.getBody();
    assertThat(body.get("pageNo"), is(pageNo));
    assertThat(body.get("pageSize"), is(pageSize));
    assertThat(Long.parseLong(body.get("count").toString()), is(totalCount));
    List rows = (List) body.get("rows");
    assertThat(rows, notNullValue());
    assertThat(rows.size(), is(list.size()));
    assertThat(((Map) rows.get(0)).get("id"), is(list.get(0).id));
}

[Buggy Hunk]
assertThat(response.getHeaders().getContentType(), is(MediaType.APPLICATION_JSON));

[Patch]
assertThat(response.getHeaders().getContentType().isCompatibleWith(MediaType.APPLICATION_JSON), is(true));