Program: 11290
Project: 11290
Buggy source:
@Test public void shouldFetch_withVariantItemAttributeQueryOnParentIndex() throws Exception {
  final AttributeQuery query=mock(AttributeQuery.class);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  final String itemId=randomId();
  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 ParentItemConfiguration parentItemConfiguration=new ParentItemConfiguration(StubItem.class,tableName);
  parentItemConfiguration.registerIndexes(Arrays.asList(new IndexDefinition("String_Node_Str")));
  final VariantItemConfiguration variantItemConfiguration=new VariantItemConfiguration(parentItemConfiguration,StubVariantItem.class,"String_Node_Str");
  final Collection<ItemConfiguration> itemConfigurations=Arrays.asList(parentItemConfiguration,variantItemConfiguration);
  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));
  mockItem.put("String_Node_Str",new AttributeValue("String_Node_Str"));
  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<StubVariantItem> returnedItems=dynamoDbTemplate.fetch(query,StubVariantItem.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());
  assertEquals("String_Node_Str",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_withVariantItemAttributeQueryOnParentIndex() throws Exception {
  final AttributeQuery query=mock(AttributeQuery.class);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  final String itemId=randomId();
  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 ParentItemConfiguration parentItemConfiguration=new ParentItemConfiguration(StubItem.class,tableName);
  parentItemConfiguration.registerIndexes(Arrays.asList(new IndexDefinition("String_Node_Str")));
  final VariantItemConfiguration variantItemConfiguration=new VariantItemConfiguration(parentItemConfiguration,StubVariantItem.class,"String_Node_Str");
  final Collection<ItemConfiguration> itemConfigurations=Arrays.asList(parentItemConfiguration,variantItemConfiguration);
  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));
  mockItem.put("String_Node_Str",new AttributeValue("String_Node_Str"));
  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<StubVariantItem> returnedItems=dynamoDbTemplate.fetch(query,StubVariantItem.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());
  assertEquals("String_Node_Str",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());
}