[Demonstration 1]

[Buggy Method]
@Override
@Transactional
public void updatePolicy(long unid, Travel travel) {
    BigDecimal grossAmount = Round.to(getPremium(travel.getZone(), travel.getPackageType(), DateHelper.getNumberOfDays(travel.getDeparture(), travel.getArrival()), travel.getBelow75(), travel.getBetween76n85(), travel.getHazardFlag(), travel.getContestFlag()), 2);
    if (grossAmount == null || grossAmount.compareTo(BigDecimal.ZERO) == 0)
        throw new ServiceValidationException("no premium found");
    BigDecimal basicPremium = Round.to(MathHelper.getQuotient(grossAmount, (new BigDecimal(1.002))), 2);
    BigDecimal lgt = Round.to(basicPremium.multiply(new BigDecimal(0.002)), 2);
    PolicyHeader polhdr = policyHeaderService.get(unid);
    polhdr = PolicyHeaderTransformer.convert(travel, polhdr, null);
    if (travel.getAssuredList() != null && travel.getAssuredList().size() != 0) {
        for (TravelAssured assured : travel.getAssuredList()) {
            if (assured.getPrimary()) {
                Client client = ClientTransformer.convert(assured);
                client.setClientNo(polhdr.getClient());
                clientService.update(client);
                polhdr.setClient(client.getClientNo());
                polhdr.setAssuredName1(assured.getName());
            }
        }
        List<FoTppAssured> tppList = travelAssuredDao.getList(unid);
        if (tppList != null) {
            try {
                travelAssuredDao.deleteAll(tppList);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                throw new ServiceException("error deleting assured with unid: " + unid);
            }
        }
    } else {
        FoClientMaster client = clientDao.get(Integer.parseInt(Properties.getPropertyWithBranch(Properties.DEFAULT_CLIENT, "FO")));
        polhdr.setClient(client.getClientNo());
        polhdr.setAssuredName1(client.getFullname());
    }
    FoTppInfo travelInfo = travelInfoDao.get(unid);
    if (travelInfo == null)
        throw new ServiceValidationException(unid + " in FoTppInfo doesn't exist");
    travelInfo = TravelInfoTransformer.convert(travel, getCoverage(travel.getZone()), basicPremium, lgt, travelInfo);
    travelInfo.setUpdatedBy(Properties.getProperty(Properties.DEFAULT_CREATED_BY));
    travelInfo.setDateUpdated(new Date());
    FoPolicyFinancial financial = policyFinancialDao.get(new FoPolicyFinancialId(unid, travelInfo.getRiskno(), travelInfo.getSeqno()));
    financial = PolicyFinancialTransformer.convert(polhdr, travelInfo, financial);
    try {
        travelInfoDao.update(travelInfo);
        policyFinancialDao.update(financial);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new ServiceException("error while updating travel policy");
    }
    if (travel.getAssuredList() != null && travel.getAssuredList().size() != 0) {
        for (TravelAssured assured : travel.getAssuredList()) {
            assured.setUnid(unid);
            saveAssured(assured);
        }
    }
}

[Buggy Hunk]
polhdr = PolicyHeaderTransformer.convert(travel, polhdr,null);

[Patch]
polhdr = PolicyHeaderTransformer.convert(travel, polhdr, TravelType.TRAVEL_PROTECT);

[Demonstration 2]

[Buggy Method]
@Test
public void testArrivalTimeSatisfiesMinimumSpeed() throws Exception {
    final CongestionModel model = new GreenshieldCongestionModel();
    final LinkProperties linkProperties = new LinkPropertiesImpl(200, speed(15));
    final int numberOfAgents = 100;
    assertThat(model.calculateArrivalTime(linkProperties, numberOfAgents), is(2000));
}

[Buggy Hunk]
assertThat(model.calculateArrivalTime(linkProperties, numberOfAgents), is(2000));

[Patch]
assertThat(model.calculateTravelTime(linkProperties, numberOfAgents), is(2000));

[Demonstration 3]

[Buggy Method]
@Override
public void travel(double distance) {
    pilot.travel(distance);
}

[Buggy Hunk]
pilot.travel(distance);

[Patch]
pilot.travel(distance, true);