Program: 11287
Project: 11287
Buggy source:
@Test public void shouldNotFetch_withAmazonServiceException() throws Exception {
  final AttributeQuery query=mock(AttributeQuery.class);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  final String stringProperty=randomString(10);
  final Set<String> stringPropertyValues=new HashSet<>(Arrays.asList(stringProperty));
  when(mockCondition.getValues()).thenReturn(stringPropertyValues);
  when(mockCondition.containsRequiredComparisonValues()).thenReturn(true);
  when(query.getAttributeName()).thenReturn("String_Node_Str");
  when(query.getCondition()).thenReturn(mockCondition);
  final ItemConfiguration itemConfiguration=new ItemConfiguration(StubItem.class,tableName);
  final Collection<ItemConfiguration> itemConfigurations=Arrays.asList(itemConfiguration);
  when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
  when(mockAmazonDynamoDbClient.query(any(QueryRequest.class))).thenThrow(AmazonServiceException.class);
  final DynamoDbTemplate dynamoDbTemplate=new DynamoDbTemplate(mockDatabaseSchemaHolder);
  dynamoDbTemplate.initialize(mockAmazonDynamoDbClient);
  PersistenceResourceFailureException actualException=null;
  try {
    dynamoDbTemplate.fetch(query,StubItem.class);
  }
 catch (  final PersistenceResourceFailureException e) {
    actualException=e;
  }
  assertNotNull(actualException);
  final ArgumentCaptor<QueryRequest> queryRequestArgumentCaptor=ArgumentCaptor.forClass(QueryRequest.class);
  verify(mockAmazonDynamoDbClient).query(queryRequestArgumentCaptor.capture());
  final QueryRequest queryRequest=queryRequestArgumentCaptor.getValue();
  assertEquals(schemaName + "String_Node_Str" + tableName,queryRequest.getTableName());
  assertNull(queryRequest.getIndexName());
  assertEquals(1,queryRequest.getKeyConditions().size());
  assertEquals("String_Node_Str",queryRequest.getKeyConditions().get("String_Node_Str").getComparisonOperator());
  assertEquals(1,queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().size());
  assertEquals(new AttributeValue(stringProperty),queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().get(0));
}

Fixed version (ground truth):
@Test public void shouldNotFetch_withAmazonServiceException() throws Exception {
  final AttributeQuery query=mock(AttributeQuery.class);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  final String stringProperty=randomString(10);
  final Set<String> stringPropertyValues=new HashSet<>(Arrays.asList(stringProperty));
  when(mockCondition.getValues()).thenReturn(stringPropertyValues);
  when(mockCondition.hasMissingComparisonValues()).thenReturn(false);
  when(query.getAttributeName()).thenReturn("String_Node_Str");
  when(query.getCondition()).thenReturn(mockCondition);
  final ItemConfiguration itemConfiguration=new ItemConfiguration(StubItem.class,tableName);
  final Collection<ItemConfiguration> itemConfigurations=Arrays.asList(itemConfiguration);
  when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
  when(mockAmazonDynamoDbClient.query(any(QueryRequest.class))).thenThrow(AmazonServiceException.class);
  final DynamoDbTemplate dynamoDbTemplate=new DynamoDbTemplate(mockDatabaseSchemaHolder);
  dynamoDbTemplate.initialize(mockAmazonDynamoDbClient);
  PersistenceResourceFailureException actualException=null;
  try {
    dynamoDbTemplate.fetch(query,StubItem.class);
  }
 catch (  final PersistenceResourceFailureException e) {
    actualException=e;
  }
  assertNotNull(actualException);
  final ArgumentCaptor<QueryRequest> queryRequestArgumentCaptor=ArgumentCaptor.forClass(QueryRequest.class);
  verify(mockAmazonDynamoDbClient).query(queryRequestArgumentCaptor.capture());
  final QueryRequest queryRequest=queryRequestArgumentCaptor.getValue();
  assertEquals(schemaName + "String_Node_Str" + tableName,queryRequest.getTableName());
  assertNull(queryRequest.getIndexName());
  assertEquals(1,queryRequest.getKeyConditions().size());
  assertEquals("String_Node_Str",queryRequest.getKeyConditions().get("String_Node_Str").getComparisonOperator());
  assertEquals(1,queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().size());
  assertEquals(new AttributeValue(stringProperty),queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().get(0));
}