[Demonstration 1]

[Buggy Method]
public void changeParamObject(Integer testID) {
    Test test = (Test) HibernateUtil.get(Test.class, testID, getCurrentSession());
    paramObject = test.getParamObject();
}

[Buggy Hunk]
Test test = (Test) HibernateUtil.get(Test.class, testID, getCurrentSession());

[Patch]
Test test = (Test) HibernateUtil.get(Test.class, testID);

[Demonstration 2]

[Buggy Method]
@Test
public void registerJmxSensorTypeIdent() throws RemoteException {
    final long jmxSensorId = 50;
    long platformId = 1;
    String fqcName = "class";
    PlatformIdent platformIdent = new PlatformIdent();
    when(platformIdentDao.load(platformId)).thenReturn(platformIdent);
    when(jmxSensorTypeIdentDao.findByExample((JmxSensorTypeIdent) anyObject())).thenReturn(Collections.<JmxSensorTypeIdent>emptyList());
    Mockito.doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            JmxSensorTypeIdent jmxSensorTypeIdent = (JmxSensorTypeIdent) invocation.getArguments()[0];
            jmxSensorTypeIdent.setId(Long.valueOf(jmxSensorId));
            return null;
        }
    }).when(jmxSensorTypeIdentDao).saveOrUpdate((JmxSensorTypeIdent) anyObject());
    long registeredId = registrationService.registerJmxSensorTypeIdent(platformId, fqcName);
    assertThat(registeredId, is(equalTo(jmxSensorId)));
    ArgumentCaptor<JmxSensorTypeIdent> jmxSensorArgument = ArgumentCaptor.forClass(JmxSensorTypeIdent.class);
    verify(jmxSensorTypeIdentDao, times(1)).saveOrUpdate(jmxSensorArgument.capture());
    assertThat(jmxSensorArgument.getValue().getFullyQualifiedClassName(), is(equalTo(fqcName)));
    verify(platformIdentDao, times(1)).saveOrUpdate(platformIdent);
    assertThat(jmxSensorArgument.getValue(), is(equalTo(platformIdent.getSensorTypeIdents().toArray()[0])));
}

[Buggy Hunk]
when(jmxSensorTypeIdentDao.findByExample((JmxSensorTypeIdent) anyObject())).thenReturn(Collections.<JmxSensorTypeIdent> emptyList());

[Patch]
when(jmxSensorTypeIdentDao.findByExample(platformId, (JmxSensorTypeIdent) anyObject())).thenReturn(Collections.<JmxSensorTypeIdent> emptyList());

[Demonstration 3]

[Buggy Method]
boolean matches(ItemStack stack) {
    if (op == null || subject == null) {
        return false;
    }
    Optional<Integer> val = subject.getValue(stack);
    return val.isPresent() && op.check(val.get(), target);
}

[Buggy Hunk]
return val.isPresent() && op.check(val.get(), target);

[Patch]
return op.check(val.orElse(0), target);