[Demonstration 1]

[Buggy Method]
@Test
@Override
public void testSave() throws Exception {
    String title = "incident test title";
    String description = "incident test description";
    int cat1Id = 1;
    int cat2Id = 3;
    int priorId = 1;
    int pup1Id = 10;
    int pup2Id = 11;
    JSONObject incident = new JSONObject();
    incident.put("title", title);
    incident.put("description", "incident test description");
    JSONArray categories = new JSONArray();
    categories.put(new JSONObject().put("id", cat1Id));
    categories.put(new JSONObject().put("id", cat2Id));
    incident.put("categories", categories);
    incident.put("priority", new JSONObject().put("id", priorId));
    JSONArray pupils = new JSONArray();
    pupils.put(new JSONObject().put("id", pup1Id));
    pupils.put(new JSONObject().put("id", pup2Id));
    incident.put("pupils", pupils);
    String incidentJson = super.requestUtil.makeRequest(RequestUtil.genRelUrl(getAllURL()), incident, "POST");
    JSONObject incidentJSONObject = new JSONObject(incidentJson);
    savedId = incidentJSONObject.getInt("id");
    assertEquals(incidentJSONObject.getString("title"), title);
    assertEquals(incidentJSONObject.getString("description"), description);
    JSONArray categoryResponse = incidentJSONObject.getJSONArray("categories");
    JSONObject priorityResponse = incidentJSONObject.getJSONObject("priority");
    JSONArray pupilsResponse = incidentJSONObject.getJSONArray("pupils");
    assertEquals(categoryResponse.getJSONObject(0).getInt("id"), cat1Id);
    assertEquals(categoryResponse.getJSONObject(1).getInt("id"), cat2Id);
    assertEquals(priorityResponse.getInt("id"), priorId);
    assertEquals(pupilsResponse.getJSONObject(0).getInt("id"), pup1Id);
    assertEquals(pupilsResponse.getJSONObject(1).getInt("id"), pup2Id);
}

[Buggy Hunk]
String incidentJson = super.requestUtil.makeRequest(RequestUtil.genRelUrl(getAllURL()), incident, "POST");

[Patch]
String incidentJson = requestUtil.makeRequest(RequestUtil.genRelUrl(getAllURL()), incident, "POST");

[Demonstration 2]

[Buggy Method]
public VerticalLayout createTab(Group g) {
    User u = UserUtils.getCurrent();
    groupSettingsLayout = new VerticalLayout();
    GridLayout tabContent;
    TextField textFieldName = new TextField();
    if (GroupUtils.isAdmin(g, u)) {
        tabContent = new GridLayout(3, 2);
        Language.set(Word.NAME, textFieldName);
        textFieldName.setWidth("100%");
        textFieldName.setValue(g.getName());
        textFieldName.setMaxLength(255);
        tabContent.addComponent(textFieldName);
        tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    } else {
        tabContent = new GridLayout(3, 1);
    }
    buttonLeave = new Button();
    Language.set(Word.LEAVE, buttonLeave);
    buttonLeave.setIcon(VaadinIcons.MINUS);
    buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonLeave.addClickListener(ce -> {
        ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> {
            long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count();
            if (amountAdmins > 1) {
                GroupUtils.removeUser(g, u);
                accordion.removeTab(accordion.getTab(groupSettingsLayout));
            } else {
                VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP));
            }
        });
    });
    buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> {
            GroupUtils.removeGroup(g);
            accordion.removeTab(accordion.getTab(groupSettingsLayout));
        });
    });
    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        if (GroupUtils.isAdmin(g, u)) {
            GroupUtils.changeName(g, textFieldName.getValue());
            accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue());
        }
        VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    Label placeholder = new Label();
    Label placeholder2 = new Label();
    placeholder2.setWidth("100%");
    Label placeholder3 = new Label();
    GridLayout footer = new GridLayout(4, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(false, true));
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    if (GroupUtils.isAdmin(g, u)) {
        footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave);
        footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    } else {
        footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave);
    }
    footer.setColumnExpandRatio(0, 5);
    footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);
    if (GroupUtils.isAdmin(g, u)) {
        tabContent.addComponent(getProfiles(g), 0, 1, 1, 1);
        tabContent.addComponent(getMembers(g), 2, 1);
    } else {
        tabContent.addComponent(getProfiles(g), 0, 0, 1, 0);
        tabContent.addComponent(getMembers(g), 2, 0);
    }
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    groupSettingsLayout.addComponents(tabContent, footer);
    groupSettingsLayout.setMargin(false);
    groupSettingsLayout.setSpacing(false);
    groupSettingsLayout.setWidth("100%");
    return groupSettingsLayout;
}

[Buggy Hunk]
if (amountAdmins > 1) {

[Patch]
if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) {

[Demonstration 3]

[Buggy Method]
private void addGameOverTextToScreen() {
    Label gameOverLabel = new Label("GAME OVER!");
    gameOverLabel.setId("gameOverLabel");
    gameOverLabel.setLayoutX(30);
    gameOverLabel.setLayoutY(30);
    gameScreenLayout.getChildren().add(gameOverLabel);
}

[Buggy Hunk]
Label gameOverLabel = new Label("GAME OVER!");

[Patch]
gameOverLabel = new Label("GAME OVER!");