Search in sources :

Example 26 with QuerySpec

use of com.amazonaws.services.dynamodbv2.document.spec.QuerySpec in project BridgeServer2 by Sage-Bionetworks.

the class DynamoIndexHelperTest method testQuery.

@Test
public void testQuery() {
    helper = new TestDynamoIndexHelper("test key", "test value", null, null);
    QuerySpec spec = new QuerySpec();
    Index mockIndex = mock(Index.class);
    helper.setIndex(mockIndex);
    ItemCollection mockItemCollection = mock(ItemCollection.class);
    when(mockIndex.query(spec)).thenReturn(mockItemCollection);
    QueryOutcome mockQueryOutcome = mock(QueryOutcome.class);
    List<Item> items = Lists.newArrayList(mock(Item.class));
    Page<Item, QueryOutcome> mockPage = new TestPage<Item, QueryOutcome>(items, mockQueryOutcome);
    when(mockItemCollection.firstPage()).thenReturn(mockPage);
    QueryOutcome result = helper.query(spec);
    assertEquals(mockQueryOutcome, result);
    verify(mockIndex).query(spec);
}
Also used : Item(com.amazonaws.services.dynamodbv2.document.Item) Index(com.amazonaws.services.dynamodbv2.document.Index) ItemCollection(com.amazonaws.services.dynamodbv2.document.ItemCollection) QueryOutcome(com.amazonaws.services.dynamodbv2.document.QueryOutcome) QuerySpec(com.amazonaws.services.dynamodbv2.document.spec.QuerySpec) Test(org.testng.annotations.Test)

Aggregations

QuerySpec (com.amazonaws.services.dynamodbv2.document.spec.QuerySpec)26 Item (com.amazonaws.services.dynamodbv2.document.Item)17 QueryOutcome (com.amazonaws.services.dynamodbv2.document.QueryOutcome)17 ValueMap (com.amazonaws.services.dynamodbv2.document.utils.ValueMap)15 Table (com.amazonaws.services.dynamodbv2.document.Table)12 DynamoDB (com.amazonaws.services.dynamodbv2.document.DynamoDB)6 ConditionalCheckFailedException (com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException)4 Index (com.amazonaws.services.dynamodbv2.document.Index)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)2 ItemCollection (com.amazonaws.services.dynamodbv2.document.ItemCollection)2 DDBQueryOp (io.nosqlbench.adapter.dynamodb.optypes.DDBQueryOp)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ForwardCursorPagedResourceList (org.sagebionetworks.bridge.models.ForwardCursorPagedResourceList)2 Upload (org.sagebionetworks.bridge.models.upload.Upload)2 Test (org.testng.annotations.Test)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 BasicSessionCredentials (com.amazonaws.auth.BasicSessionCredentials)1