Program: 11292
Project: 11292
Buggy source:
@Test public void shouldFetch_withCompoundAttributeQueryOnIndex() throws Exception {
  final String itemId=randomId();
  final String gsiProperty=randomString(10);
  final Integer gsiSupportingProperty=randomInt(20);
  final Set<String> stringPropertyValues=new HashSet<>(Arrays.asList(gsiProperty));
  final Set<String> stringSupportingPropertyValues=new HashSet<>(Arrays.asList(String.valueOf(gsiSupportingProperty)));
  final ItemConfiguration itemConfiguration=new ItemConfiguration(StubWithGlobalSecondaryIndexItem.class,tableName);
  itemConfiguration.registerIndexes((Arrays.asList(new CompoundIndexDefinition("String_Node_Str","String_Node_Str"))));
  final Collection<ItemConfiguration> itemConfigurations=Arrays.asList(itemConfiguration);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  when(mockCondition.getValues()).thenReturn(stringPropertyValues);
  when(mockCondition.containsRequiredComparisonValues()).thenReturn(true);
  final Condition mockSupportingCondition=mock(Condition.class);
  when(mockSupportingCondition.getComparisonOperator()).thenReturn(Operators.LESS_THAN_OR_EQUALS);
  when(mockSupportingCondition.getValues()).thenReturn(stringSupportingPropertyValues);
  final CompoundAttributeQuery query=mock(CompoundAttributeQuery.class);
  when(query.getAttributeName()).thenReturn("String_Node_Str");
  when(query.getCondition()).thenReturn(mockCondition);
  when(query.getSupportingAttributeName()).thenReturn("String_Node_Str");
  when(query.getSupportingCondition()).thenReturn(mockSupportingCondition);
  final Map<String,AttributeValue> mockItem=new HashMap<>();
  mockItem.put("String_Node_Str",new AttributeValue(itemId));
  mockItem.put("String_Node_Str",new AttributeValue(gsiProperty));
  final AttributeValue gsiSupportingPropertyAttributeValue=new AttributeValue();
  gsiSupportingPropertyAttributeValue.withN(String.valueOf(gsiSupportingProperty));
  mockItem.put("String_Node_Str",gsiSupportingPropertyAttributeValue);
  final List<Map<String,AttributeValue>> mockItems=Arrays.asList(mockItem);
  final QueryResult mockQueryResult=mock(QueryResult.class);
  when(mockQueryResult.getItems()).thenReturn(mockItems);
  when(mockQueryResult.getLastEvaluatedKey()).thenReturn(null);
  when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
  when(mockAmazonDynamoDbClient.query(any(QueryRequest.class))).thenReturn(mockQueryResult);
  final DynamoDbTemplate dynamoDbTemplate=new DynamoDbTemplate(mockDatabaseSchemaHolder);
  dynamoDbTemplate.initialize(mockAmazonDynamoDbClient);
  final Collection<StubWithGlobalSecondaryIndexItem> returnedItems=dynamoDbTemplate.fetch(query,StubWithGlobalSecondaryIndexItem.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(2,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(gsiProperty),queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().get(0));
  assertEquals("String_Node_Str",queryRequest.getKeyConditions().get("String_Node_Str").getComparisonOperator());
  assertEquals(1,queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().size());
  assertEquals(gsiSupportingPropertyAttributeValue,queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().get(0));
  assertNotNull(returnedItems);
  assertEquals(1,returnedItems.size());
}

Fixed version (ground truth):
@Test public void shouldFetch_withCompoundAttributeQueryOnIndex() throws Exception {
  final String itemId=randomId();
  final String gsiProperty=randomString(10);
  final Integer gsiSupportingProperty=randomInt(20);
  final Set<String> stringPropertyValues=new HashSet<>(Arrays.asList(gsiProperty));
  final Set<String> stringSupportingPropertyValues=new HashSet<>(Arrays.asList(String.valueOf(gsiSupportingProperty)));
  final ItemConfiguration itemConfiguration=new ItemConfiguration(StubWithGlobalSecondaryIndexItem.class,tableName);
  itemConfiguration.registerIndexes((Arrays.asList(new CompoundIndexDefinition("String_Node_Str","String_Node_Str"))));
  final Collection<ItemConfiguration> itemConfigurations=Arrays.asList(itemConfiguration);
  final Condition mockCondition=mock(Condition.class);
  when(mockCondition.getComparisonOperator()).thenReturn(Operators.EQUALS);
  when(mockCondition.getValues()).thenReturn(stringPropertyValues);
  when(mockCondition.hasMissingComparisonValues()).thenReturn(false);
  final Condition mockSupportingCondition=mock(Condition.class);
  when(mockSupportingCondition.getComparisonOperator()).thenReturn(Operators.LESS_THAN_OR_EQUALS);
  when(mockSupportingCondition.getValues()).thenReturn(stringSupportingPropertyValues);
  final CompoundAttributeQuery query=mock(CompoundAttributeQuery.class);
  when(query.getAttributeName()).thenReturn("String_Node_Str");
  when(query.getCondition()).thenReturn(mockCondition);
  when(query.getSupportingAttributeName()).thenReturn("String_Node_Str");
  when(query.getSupportingCondition()).thenReturn(mockSupportingCondition);
  final Map<String,AttributeValue> mockItem=new HashMap<>();
  mockItem.put("String_Node_Str",new AttributeValue(itemId));
  mockItem.put("String_Node_Str",new AttributeValue(gsiProperty));
  final AttributeValue gsiSupportingPropertyAttributeValue=new AttributeValue();
  gsiSupportingPropertyAttributeValue.withN(String.valueOf(gsiSupportingProperty));
  mockItem.put("String_Node_Str",gsiSupportingPropertyAttributeValue);
  final List<Map<String,AttributeValue>> mockItems=Arrays.asList(mockItem);
  final QueryResult mockQueryResult=mock(QueryResult.class);
  when(mockQueryResult.getItems()).thenReturn(mockItems);
  when(mockQueryResult.getLastEvaluatedKey()).thenReturn(null);
  when(mockDatabaseSchemaHolder.itemConfigurations()).thenReturn(itemConfigurations);
  when(mockAmazonDynamoDbClient.query(any(QueryRequest.class))).thenReturn(mockQueryResult);
  final DynamoDbTemplate dynamoDbTemplate=new DynamoDbTemplate(mockDatabaseSchemaHolder);
  dynamoDbTemplate.initialize(mockAmazonDynamoDbClient);
  final Collection<StubWithGlobalSecondaryIndexItem> returnedItems=dynamoDbTemplate.fetch(query,StubWithGlobalSecondaryIndexItem.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(2,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(gsiProperty),queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().get(0));
  assertEquals("String_Node_Str",queryRequest.getKeyConditions().get("String_Node_Str").getComparisonOperator());
  assertEquals(1,queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().size());
  assertEquals(gsiSupportingPropertyAttributeValue,queryRequest.getKeyConditions().get("String_Node_Str").getAttributeValueList().get(0));
  assertNotNull(returnedItems);
  assertEquals(1,returnedItems.size());
}