Program: 11294
Project: 11294
Buggy source:
@Test public void shouldFetch_withAttributeQueryOnPrimaryKey() throws Exception {
  final AttributeQuery query=mock(AttributeQuery.class);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  when(mockCondition.containsRequiredComparisonValues()).thenReturn(true);
  final String itemId=randomId();
  final String stringProperty=randomString(10);
  final Set<String> stringPropertyValues=new HashSet<>(Arrays.asList(stringProperty));
  when(mockCondition.getValues()).thenReturn(stringPropertyValues);
  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);
  final DynamoDbTemplate dynamoDbTemplate=new DynamoDbTemplate(mockDatabaseSchemaHolder);
  final QueryResult mockQueryResult=mock(QueryResult.class);
  final Map<String,AttributeValue> mockItem=new HashMap<>();
  mockItem.put("String_Node_Str",new AttributeValue(itemId));
  mockItem.put("String_Node_Str",new AttributeValue(stringProperty));
  final List<Map<String,AttributeValue>> mockItems=Arrays.asList(mockItem);
  when(mockQueryResult.getItems()).thenReturn(mockItems);
  when(mockQueryResult.getLastEvaluatedKey()).thenReturn(null);
  when(mockAmazonDynamoDbClient.query(any(QueryRequest.class))).thenReturn(mockQueryResult);
  dynamoDbTemplate.initialize(mockAmazonDynamoDbClient);
  final Collection<StubItem> returnedItems=dynamoDbTemplate.fetch(query,StubItem.class);
  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));
  assertNotNull(returnedItems);
  assertEquals(1,returnedItems.size());
}

Fixed version (ground truth):
@Test public void shouldFetch_withAttributeQueryOnPrimaryKey() throws Exception {
  final AttributeQuery query=mock(AttributeQuery.class);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  when(mockCondition.hasMissingComparisonValues()).thenReturn(false);
  final String itemId=randomId();
  final String stringProperty=randomString(10);
  final Set<String> stringPropertyValues=new HashSet<>(Arrays.asList(stringProperty));
  when(mockCondition.getValues()).thenReturn(stringPropertyValues);
  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);
  final DynamoDbTemplate dynamoDbTemplate=new DynamoDbTemplate(mockDatabaseSchemaHolder);
  final QueryResult mockQueryResult=mock(QueryResult.class);
  final Map<String,AttributeValue> mockItem=new HashMap<>();
  mockItem.put("String_Node_Str",new AttributeValue(itemId));
  mockItem.put("String_Node_Str",new AttributeValue(stringProperty));
  final List<Map<String,AttributeValue>> mockItems=Arrays.asList(mockItem);
  when(mockQueryResult.getItems()).thenReturn(mockItems);
  when(mockQueryResult.getLastEvaluatedKey()).thenReturn(null);
  when(mockAmazonDynamoDbClient.query(any(QueryRequest.class))).thenReturn(mockQueryResult);
  dynamoDbTemplate.initialize(mockAmazonDynamoDbClient);
  final Collection<StubItem> returnedItems=dynamoDbTemplate.fetch(query,StubItem.class);
  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));
  assertNotNull(returnedItems);
  assertEquals(1,returnedItems.size());
}