Search in sources :

Example 16 with AttributeValue

use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.

the class AmazonDDBClientMock method query.

@SuppressWarnings("unchecked")
@Override
public QueryResult query(QueryRequest queryRequest) {
    this.queryRequest = queryRequest;
    ConsumedCapacity consumed = new ConsumedCapacity();
    consumed.setCapacityUnits(1.0);
    Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>();
    lastEvaluatedKey.put("1", new AttributeValue("LAST_KEY"));
    return new QueryResult().withConsumedCapacity(consumed).withCount(1).withItems(getAttributes()).withLastEvaluatedKey(lastEvaluatedKey);
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) QueryResult(com.amazonaws.services.dynamodbv2.model.QueryResult) HashMap(java.util.HashMap) ConsumedCapacity(com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)

Example 17 with AttributeValue

use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.

the class AmazonDDBClientMock method getAttributes.

private Map<String, AttributeValue> getAttributes() {
    Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
    attributes.put("attrName", new AttributeValue("attrValue"));
    return attributes;
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) HashMap(java.util.HashMap)

Example 18 with AttributeValue

use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.

the class AmazonDDBClientMock method scan.

@SuppressWarnings("unchecked")
@Override
public ScanResult scan(ScanRequest scanRequest) {
    this.scanRequest = scanRequest;
    ConsumedCapacity consumed = new ConsumedCapacity();
    consumed.setCapacityUnits(1.0);
    Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>();
    lastEvaluatedKey.put("1", new AttributeValue("LAST_KEY"));
    return new ScanResult().withConsumedCapacity(consumed).withCount(1).withItems(getAttributes()).withScannedCount(10).withLastEvaluatedKey(lastEvaluatedKey);
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) HashMap(java.util.HashMap) ConsumedCapacity(com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)

Example 19 with AttributeValue

use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.

the class BatchGetItemsCommandTest method execute.

@Test
public void execute() {
    Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
    key.put("1", new AttributeValue("Key_1"));
    Map<String, AttributeValue> unprocessedKey = new HashMap<String, AttributeValue>();
    unprocessedKey.put("1", new AttributeValue("UNPROCESSED_KEY"));
    Map<String, KeysAndAttributes> keysAndAttributesMap = new HashMap<String, KeysAndAttributes>();
    KeysAndAttributes keysAndAttributes = new KeysAndAttributes().withKeys(key);
    keysAndAttributesMap.put("DOMAIN1", keysAndAttributes);
    exchange.getIn().setHeader(DdbConstants.BATCH_ITEMS, keysAndAttributesMap);
    command.execute();
    assertEquals(keysAndAttributesMap, ddbClient.batchGetItemRequest.getRequestItems());
    List<Map<String, AttributeValue>> batchResponse = (List<Map<String, AttributeValue>>) exchange.getIn().getHeader(DdbConstants.BATCH_RESPONSE, Map.class).get("DOMAIN1");
    AttributeValue value = batchResponse.get(0).get("attrName");
    KeysAndAttributes unProcessedAttributes = (KeysAndAttributes) exchange.getIn().getHeader(DdbConstants.UNPROCESSED_KEYS, Map.class).get("DOMAIN1");
    Map<String, AttributeValue> next = unProcessedAttributes.getKeys().iterator().next();
    assertEquals(new AttributeValue("attrValue"), value);
    assertEquals(unprocessedKey, next);
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) HashMap(java.util.HashMap) List(java.util.List) KeysAndAttributes(com.amazonaws.services.dynamodbv2.model.KeysAndAttributes) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 20 with AttributeValue

use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.

the class GetItemCommandTest method execute.

@Test
public void execute() {
    Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
    key.put("1", new AttributeValue("Key_1"));
    exchange.getIn().setHeader(DdbConstants.KEY, key);
    List<String> attrNames = Arrays.asList("attrName");
    exchange.getIn().setHeader(DdbConstants.ATTRIBUTE_NAMES, attrNames);
    exchange.getIn().setHeader(DdbConstants.CONSISTENT_READ, true);
    command.execute();
    assertEquals("DOMAIN1", ddbClient.getItemRequest.getTableName());
    assertEquals(attrNames, ddbClient.getItemRequest.getAttributesToGet());
    assertEquals(true, ddbClient.getItemRequest.getConsistentRead());
    assertEquals(key, ddbClient.getItemRequest.getKey());
    assertEquals(new AttributeValue("attrValue"), exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get("attrName"));
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)33 HashMap (java.util.HashMap)23 Test (org.junit.Test)8 Condition (com.amazonaws.services.dynamodbv2.model.Condition)5 AmazonServiceException (com.amazonaws.AmazonServiceException)4 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)4 ConsumedCapacity (com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)4 Map (java.util.Map)4 ExpectedAttributeValue (com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue)3 GetItemRequest (com.amazonaws.services.dynamodbv2.model.GetItemRequest)3 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TicketDefinition (org.apereo.cas.ticket.TicketDefinition)3 DynamoDBScanExpression (com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression)2 AttributeValueUpdate (com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate)2 ComparisonOperator (com.amazonaws.services.dynamodbv2.model.ComparisonOperator)2 DeleteItemRequest (com.amazonaws.services.dynamodbv2.model.DeleteItemRequest)2 DeleteItemResult (com.amazonaws.services.dynamodbv2.model.DeleteItemResult)2 KeysAndAttributes (com.amazonaws.services.dynamodbv2.model.KeysAndAttributes)2