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);
}
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;
}
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);
}
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);
}
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"));
}
Aggregations