[Demonstration 1]

[Buggy Method]
@Override
public Project update(Project new_project) throws NotFoundException, ForbiddenException, BadRequestException {
    Project project = projectRepository.findFirstById(new_project.getId());
    if (!project.getName().equals(new_project.getName())) {
        throw new ForbiddenException("Forbidden to change the project name");
    }
    if (project == null) {
        throw new NotFoundException("Not found project " + new_project.getId());
    }
    project.setDescription(new_project.getDescription());
    for (String username : project.getUsers().keySet()) {
        if (new_project.getUsers().containsKey(username)) {
            if (project.getUsers().get(username).ordinal() != new_project.getUsers().get(username).ordinal()) {
                userManagement.updateRole(username, project.getName(), new_project.getUsers().get(username));
            }
        } else {
            userManagement.removeRole(username, project.getName());
        }
    }
    for (String username : new_project.getUsers().keySet()) {
        if (!project.getUsers().containsKey(username)) {
            userManagement.addRole(username, username, new_project.getUsers().get(username));
        }
    }
    return projectRepository.save(project);
}

[Buggy Hunk]
return projectRepository.save(project);

[Patch]
return projectRepository.save(new_project);

[Demonstration 2]

[Buggy Method]
@Test
public void addPet() throws Exception {
    String jsonPet = json(new Pet(null, this.category, "newPet", Arrays.asList("urlx"), this.tags, PetStatus.NOT_AVAILABLE));
    mockMvc.perform(post("/pet").contentType(jsonContentType).content(jsonPet)).andExpect(status().isCreated()).andExpect(jsonPath("$.name", is("newPet"))).andExpect(jsonPath("$.category.id", is(this.category.getId().intValue()))).andExpect(jsonPath("$.category.name", is("category1"))).andExpect(jsonPath("$.photoUrls.length()", is(2))).andExpect(jsonPath("$.photoUrls[0]", is("urlx"))).andExpect(jsonPath("$.tags.length()", is(2))).andExpect(jsonPath("$.tags[0].id", is(this.tags.get(0).getId().intValue()))).andExpect(jsonPath("$.tags[0].name", is("tag1"))).andExpect(jsonPath("$.tags[1].id", is(this.tags.get(1).getId().intValue()))).andExpect(jsonPath("$.tags[1].name", is("tag2"))).andExpect(jsonPath("$.status", is("NOT_AVAILABLE")));
}

[Buggy Hunk]
.andExpect(jsonPath("$.photoUrls.length()", is(2)))

[Patch]
.andExpect(jsonPath("$.photoUrls.length()", is(1)))

[Demonstration 3]

[Buggy Method]
public static void main(String[] args) {
    ProjectStatService service = new ProjectStatServiceImpl();
    List<BuildStatus> builds = service.getBuildStatistics(getMap1());
    for (int i = 0; i < builds.size(); i++) {
        BuildStatus temp = builds.get(i);
        System.out.println(temp.getTimePrefix());
        System.out.println(temp.getTime());
        System.out.println(temp.getTotalBuild());
        System.out.println(temp.getSuccessBuild());
        System.out.println(temp.getFailureBuild());
        for (Map.Entry<String, String> entry : temp.getBuilds().entrySet()) {
            System.out.println(entry.getKey() + ";" + entry.getValue());
        }
        System.out.println();
    }
}

[Buggy Hunk]
List<BuildStatus> builds = service.getBuildStatistics(getMap1());

[Patch]
List<BuildStatus> builds = service.getBuildStatistics(getMap1(""));