use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.
the class AmazonDDBClientMock method batchGetItem.
@SuppressWarnings("unchecked")
@Override
public BatchGetItemResult batchGetItem(BatchGetItemRequest batchGetItemRequest) {
this.batchGetItemRequest = batchGetItemRequest;
Map<String, List<Map<String, AttributeValue>>> responseMap = new HashMap<String, List<Map<String, AttributeValue>>>();
List<Map<String, AttributeValue>> p = new ArrayList<Map<String, AttributeValue>>();
p.add(getAttributes());
responseMap.put("DOMAIN1", p);
Map<String, AttributeValue> keysMap = new HashMap<String, AttributeValue>();
keysMap.put("1", new AttributeValue("UNPROCESSED_KEY"));
Map<String, KeysAndAttributes> unprocessedKeys = new HashMap<String, KeysAndAttributes>();
unprocessedKeys.put("DOMAIN1", new KeysAndAttributes().withKeys(keysMap));
return new BatchGetItemResult().withResponses(responseMap).withUnprocessedKeys(unprocessedKeys);
}
use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project camel by apache.
the class DeleteItemCommandTest 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);
Map<String, ExpectedAttributeValue> updateCondition = new HashMap<String, ExpectedAttributeValue>();
updateCondition.put("name", new ExpectedAttributeValue(new AttributeValue("expected value")));
exchange.getIn().setHeader(DdbConstants.UPDATE_CONDITION, updateCondition);
exchange.getIn().setHeader(DdbConstants.RETURN_VALUES, "ALL_OLD");
command.execute();
assertEquals("DOMAIN1", ddbClient.deleteItemRequest.getTableName());
assertEquals(key, ddbClient.deleteItemRequest.getKey());
assertEquals(updateCondition, ddbClient.deleteItemRequest.getExpected());
assertEquals("ALL_OLD", ddbClient.deleteItemRequest.getReturnValues());
assertEquals(new AttributeValue("attrValue"), exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get("attrName"));
}
use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project cas by apereo.
the class DynamoDbServiceRegistryFacilitator method get.
/**
* Get registered service.
*
* @param id the id
* @return the registered service
*/
public RegisteredService get(final long id) {
final Map<String, AttributeValue> keys = new HashMap<>();
keys.put(ColumnNames.ID.getName(), new AttributeValue(String.valueOf(id)));
return getRegisteredServiceByKeys(keys);
}
use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project cas by apereo.
the class DynamoDbServiceRegistryFacilitator method getRegisteredServiceByKeys.
private RegisteredService getRegisteredServiceByKeys(final Map<String, AttributeValue> keys) {
final GetItemRequest request = new GetItemRequest().withKey(keys).withTableName(TABLE_NAME);
LOGGER.debug("Submitting request [{}] to get service with keys [{}]", request, keys);
final Map<String, AttributeValue> returnItem = amazonDynamoDBClient.getItem(request).getItem();
if (returnItem != null) {
final RegisteredService service = deserializeServiceFromBinaryBlob(returnItem);
LOGGER.debug("Located service [{}]", service);
return service;
}
return null;
}
use of com.amazonaws.services.dynamodbv2.model.AttributeValue in project cas by apereo.
the class DynamoDbServiceRegistryFacilitator method delete.
/**
* Delete boolean.
*
* @param service the service
* @return the boolean
*/
public boolean delete(final RegisteredService service) {
final DeleteItemRequest del = new DeleteItemRequest().withTableName(TABLE_NAME).withKey(Collections.singletonMap(ColumnNames.ID.getName(), new AttributeValue(String.valueOf(service.getId()))));
LOGGER.debug("Submitting delete request [{}] for service [{}]", del, service);
final DeleteItemResult res = amazonDynamoDBClient.deleteItem(del);
LOGGER.debug("Delete request came back with result [{}]", res);
return res != null;
}
Aggregations