[Demonstration 1]

[Buggy Method]
@Test
public void shouldReturnReadingIfValueIsNotEmptyAndNRIsNull() throws Exception {
    JsonNode valueNode = mock(JsonNode.class);
    when(valueNode.getTextValue()).thenReturn("55");
    when(jsonNode.get("value")).thenReturn(valueNode);
    when(jsonNode.get("notRecorded")).thenReturn(null);
    Reading reading = new DistributionReadingDeSerializer().deserialize(jp, mock(DeserializationContext.class));
    assertThat(reading.getValue(), is("55"));
}

[Buggy Hunk]
when(valueNode.getTextValue()).thenReturn("55");

[Patch]
when(valueNode.asText()).thenReturn("55");

[Demonstration 2]

[Buggy Method]
public String queryIsFoundEntirely(StringBuffer sb, String[] contentArray, String[] queryArray) {
    int minus = DEFAULT_WORDS_BEFORE_HIT;
    int it = 0;
    while (true) {
        it++;
        int indexFirstWordOfQueryInContent = findInArray(contentArray, queryArray[0], 0);
        int begin = Math.max(0, indexFirstWordOfQueryInContent - minus);
        String joinedBeginString = joinStringsWithSpace(contentArray, begin, indexFirstWordOfQueryInContent);
        int end = Math.min(contentArray.length, indexFirstWordOfQueryInContent + minus);
        String joinedEndString = joinStringsWithSpace(contentArray, indexFirstWordOfQueryInContent, end);
        String tempResult = sb.subSequence(sb.indexOf(joinedBeginString), sb.indexOf(joinedEndString) + joinedEndString.length()).toString();
        String[] lengthOfTempResult = tempResult.split(" ");
        if (lengthOfTempResult.length > DEFAULT_SNIPPET_SIZE || it > 15) {
            return tempResult;
        } else {
            minus++;
        }
    }
}

[Buggy Hunk]
int indexFirstWordOfQueryInContent = findInArray(contentArray, queryArray[0], 0);

[Patch]
int indexFirstWordOfQueryInContent = Math.max(0, findInArray(contentArray, queryArray[0], 0));

[Demonstration 3]

[Buggy Method]
@Test
public void UserSettingModel_CorrectProperties_assertTrue() {
    UserSetting userSetting = new UserSetting();
    userSetting.setName(FAKE_STRING);
    userSetting.setValue(FAKE_STRING_OTHER);
    assertThat(userSetting.getName(), is(FAKE_STRING));
    assertThat(userSetting.getValue(), is(FAKE_STRING_OTHER));
    userSetting.setValue(FAKE_BOOLEAN_TRUE);
    assertThat(userSetting.getValue(), is("1"));
}

[Buggy Hunk]
assertThat(userSetting.getValue(), is("1"));

[Patch]
assertThat(userSetting.getValueBoolean(), is(FAKE_BOOLEAN_TRUE));