Examples of AttributeValue


Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        command = new DeleteItemCommand(ddbClient, configuration, exchange);
    }

    @Test
    public void execute() {
        Key key = new Key(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"));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

    }

    @Test
    public void execute() {

        Key startKey = new Key(new AttributeValue("startKey"));
        AttributeValue attributeValue = new AttributeValue().withN("1985");
        Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));

        List<String> attributeNames = Arrays.asList("attrNameOne", "attrNameTwo");
        exchange.getIn().setHeader(DdbConstants.ATTRIBUTE_NAMES, attributeNames);
        exchange.getIn().setHeader(DdbConstants.EXACT_COUNT, true);
        exchange.getIn().setHeader(DdbConstants.CONSISTENT_READ, true);
        exchange.getIn().setHeader(DdbConstants.START_KEY, startKey);
        exchange.getIn().setHeader(DdbConstants.HASH_KEY_VALUE, attributeValue);
        exchange.getIn().setHeader(DdbConstants.LIMIT, 10);
        exchange.getIn().setHeader(DdbConstants.SCAN_RANGE_KEY_CONDITION, condition);
        exchange.getIn().setHeader(DdbConstants.SCAN_INDEX_FORWARD, true);

        command.execute();

        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
        assertEquals(Double.valueOf(1.0), exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY, Double.class));
        assertEquals(new Key(new AttributeValue("LAST_KEY")), exchange.getIn().getHeader(DdbConstants.LAST_EVALUATED_KEY, Key.class));

        Map<?, ?> items = (Map<?, ?>) exchange.getIn().getHeader(DdbConstants.ITEMS, List.class).get(0);
        assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        command = new UpdateItemCommand(ddbClient, configuration, exchange);
    }

    @Test
    public void execute() {
        Key key = new Key(new AttributeValue("Key_1"));
        exchange.getIn().setHeader(DdbConstants.KEY, key);

        Map<String, AttributeValueUpdate> attributeMap = new HashMap<String, AttributeValueUpdate>();
        AttributeValueUpdate attributeValue = new AttributeValueUpdate(
                new AttributeValue("new value"), AttributeAction.ADD);
        attributeMap.put("name", attributeValue);
        exchange.getIn().setHeader(DdbConstants.UPDATE_VALUES, attributeMap);

        Map<String, ExpectedAttributeValue> expectedAttributeValueMap = new HashMap<String, ExpectedAttributeValue>();
        expectedAttributeValueMap
                .put("name", new ExpectedAttributeValue(new AttributeValue("expected value")));
        exchange.getIn().setHeader(DdbConstants.UPDATE_CONDITION, expectedAttributeValueMap);
        exchange.getIn().setHeader(DdbConstants.RETURN_VALUES, "ALL_OLD");

        command.execute();

        assertEquals("DOMAIN1", ddbClient.updateItemRequest.getTableName());
        assertEquals(attributeMap, ddbClient.updateItemRequest.getAttributeUpdates());
        assertEquals(key, ddbClient.updateItemRequest.getKey());
        assertEquals(expectedAttributeValueMap, ddbClient.updateItemRequest.getExpected());
        assertEquals("ALL_OLD", ddbClient.updateItemRequest.getReturnValues());
        assertEquals(new AttributeValue("attrValue"),
                exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get(
                        "attrName"));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

    @Test
    public void execute() {
        HashMap<String, Condition> scanFilter = new HashMap<String, Condition>();
        Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));
        scanFilter.put("year", condition);
        exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, scanFilter);

        command.execute();

        assertEquals(scanFilter, ddbClient.scanRequest.getScanFilter());
        assertEquals(Integer.valueOf(10), exchange.getIn().getHeader(DdbConstants.SCANNED_COUNT, Integer.class));
        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
        assertEquals(Double.valueOf(1.0), exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY, Double.class));
        assertEquals(new Key(new AttributeValue("LAST_KEY")), exchange.getIn().getHeader(DdbConstants.LAST_EVALUATED_KEY, Key.class));

        Map<?, ?> items = (Map<?, ?>) exchange.getIn().getHeader(DdbConstants.ITEMS, List.class).get(0);
        assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        command = new GetItemCommand(ddbClient, configuration, exchange);
    }

    @Test
    public void execute() {
        Key key = new Key(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"));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        return new PutItemResult().withAttributes(getAttributes());
    }

    private Map<String, AttributeValue> getAttributes() {
        Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
        attributes.put("attrName", new AttributeValue("attrValue"));
        return attributes;
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        Map<String, BatchResponse> responseMap = new HashMap<String, BatchResponse>();
        responseMap.put("DOMAIN1", new BatchResponse().withItems(getAttributes()));

        Map<String, KeysAndAttributes> unprocessedKeys = new HashMap<String, KeysAndAttributes>();
        unprocessedKeys.put("DOMAIN1", new KeysAndAttributes().withKeys(
                new Key(new AttributeValue("UNPROCESSED_KEY"))));

        return new BatchGetItemResult()
                .withResponses(responseMap)
                .withUnprocessedKeys(unprocessedKeys);
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        return new ScanResult()
                .withConsumedCapacityUnits(1.0)
                .withCount(1)
                .withItems(getAttributes())
                .withScannedCount(10)
                .withLastEvaluatedKey(new Key(new AttributeValue("LAST_KEY")));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

        this.queryRequest = queryRequest;
        return new QueryResult()
                .withConsumedCapacityUnits(1.0)
                .withCount(1)
                .withItems(getAttributes())
                .withLastEvaluatedKey(new Key(new AttributeValue("LAST_KEY")));
    }

Examples of com.amazonaws.services.dynamodb.model.AttributeValue

    private ProducerTemplate template;

    @Test
    public void select() {
        final Map<String, AttributeValue> attributeMap = new HashMap<String, AttributeValue>();
        AttributeValue attributeValue = new AttributeValue("test value");
        attributeMap.put("name", attributeValue);

        Exchange exchange = template.send("direct:start", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setHeader(DdbConstants.OPERATION, DdbOperations.PutItem);
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.