[Demonstration 1]

[Buggy Method]
@Security.Authenticated(LoggedInAuthenticator.class)
public static Result addMember() {
    String newMemberUsername = Form.form().bindFromRequest().get("username");
    String teamIdStr = Form.form().bindFromRequest().get("teamID");
    if (!checkStringIsLongValidator.isValid(teamIdStr)) {
        return badRequest(Messages.get("page.badRequest"));
    }
    System.out.println(newMemberUsername);
    User user = User.find.where().eq("username", newMemberUsername).findUnique();
    if (user == null) {
        return badRequest(Messages.get("page.team.validate.suchUsernameDoesNotExist"));
    }
    Long teamId = Long.parseLong(teamIdStr);
    Team team = Team.find.byId(teamId);
    if (team.users.contains(user)) {
        return badRequest(Messages.get("page.team.validate.alreadyMember"));
    }
    team.users.add(user);
    team.save();
    return ok(teamonemember.render(team, user));
}

[Buggy Hunk]
return ok(teamonemember.render(team, user));

[Patch]
return ok(teamOneMember.render(team, user));

[Demonstration 2]

[Buggy Method]
@Override
public boolean isValid(UserDTO user, ConstraintValidatorContext context) {
    return user.getDateOfBirth().isBefore(user.getRegistrationDate());
}

[Buggy Hunk]
return user.getDateOfBirth().isBefore(user.getRegistrationDate());

[Patch]
return (user.getDateOfBirth()!= null) &&(user.getDateOfBirth().isBefore(user.getRegistrationDate()));

[Demonstration 3]

[Buggy Method]
@Override
public Order order(Cart cart, Customer customer, ShopContext shopContext) throws OrderServiceException {
    TransactionData transactionData = null;
    String shopCode = shopContext.getShopCode();
    try {
        Order order = newOrder(cart, customer, shopContext);
        try {
            orderDaos.get(shopCode).saveOrUpdateOrder(order);
        } catch (OrderDaoException e1) {
            throw new OrderServiceException(new MessageImpl(MessageImpl.TYPE_ERROR, "internal.error"));
        }
        try {
            transactionData = inventoryService.decrement(order);
        } catch (InventoryServiceException ise) {
            throw new OrderServiceException(ise.getMessages());
        }
        if (!cart.getCoupons().isEmpty()) {
            try {
                Coupon coupon = cart.getCoupons().get(0);
                cartService.setIndividualUse(coupon, customer.getId(), order.getId(), cart, shopContext.getShopCode());
                coupon.getCode();
            } catch (CartServiceException cse) {
                cart.getCoupons().clear();
                throw new OrderServiceException(cse.getMessages());
            }
        }
        try {
            paymentService.doOrder(order);
            // TODO: get order status from payment serviec
            order.setStatus(Order.STATUS_SUBMIT);
        } catch (PaymentServiceException pse) {
            throw new OrderServiceException(pse.getMessages());
        }
        try {
            orderDaos.get(shopCode).saveOrUpdateOrder(order);
        } catch (OrderDaoException e1) {
            throw new OrderServiceException(new MessageImpl(MessageImpl.TYPE_ERROR, "internal.error"));
        }
        try {
            inventoryService.confirm(transactionData, order);
        } catch (InventoryServiceException ise) {
            log.error(ExceptionUtils.getStackTrace(ise));
        }
        sendOrderMessage(order);
        return order;
    } catch (OrderServiceException e) {
        try {
            inventoryService.rollBack(transactionData);
        } catch (InventoryServiceException ise) {
            log.error(ExceptionUtils.getStackTrace(ise));
        }
        throw e;
    }
}

[Buggy Hunk]
if (!cart.getCoupons().isEmpty()) {

[Patch]
if (CollectionUtils.isNotEmpty(cart.getCoupons())) {