Package com.amazonaws.services.dynamodbv2.model

Examples of com.amazonaws.services.dynamodbv2.model.Condition


////    // TODO: Exception!
    @Test
    public void scanWithScanFilterINTest() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withN("100"));
        attributeValueList.add(new AttributeValue().withN("101"));
        attributeValueList.add(new AttributeValue().withN("102"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.IN);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);
        ScanResult result = getClient().scan(request);
        Assert.assertNotNull(result);
View Full Code Here


    }

    @Test
    public void scanWithScanFilterBETWEENTest() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withN("100"));
        attributeValueList.add(new AttributeValue().withN("104"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.BETWEEN);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);

        ScanResult result = getClient().scan(request);
View Full Code Here

    }

    @Test
    public void scanWithScanFilterBEGINSWITHTest() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withS("5"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.BEGINS_WITH);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("string", rangeKeyCondition);
        request.setScanFilter(conditionMap);

        ScanResult result = getClient().scan(request);
View Full Code Here

    }

    @Test
    public void scanWithScanFilterCONTAINSTest() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withN("4"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.CONTAINS);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);

        ScanResult result = getClient().scan(request);
View Full Code Here

    public void scanWithScanFilterMultipleConditionsTest() throws Exception {
        ScanRequest request = getBasicReq();
        final Map<String, Condition> conditionMap = new HashMap<String, Condition>();

        //First condition
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withN("4"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.EQ);
        conditionMap.put("range", rangeKeyCondition);

        //Second condition
        //Note: this is purely for testing; in real applications, conditions would probably use different attributes
        rangeKeyCondition = new Condition();
        attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withN("4"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.EQ);
        conditionMap.put("second", rangeKeyCondition);

        request.setScanFilter(conditionMap);

        ScanResult result = getClient().scan(request);
View Full Code Here

            new QueryRequest()
                .withTableName(tableName)
                .withKeyConditions(createHashKeyCondition("id", hashKey))
                ;

        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(createStringAttribute("Range2"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.EQ);
        request.getKeyConditions().put("range", rangeKeyCondition);

        QueryResult result = getClient().query(request);

        Assert.assertNotNull("Null result.", result);
View Full Code Here

        String hashCode = "hash2";
        TestClassWithHashRangeKey hashKeyTemplate = new TestClassWithHashRangeKey();
        hashKeyTemplate.setHashCode(hashCode);

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> rangeValues = new ArrayList<AttributeValue>();
    rangeValues.add(new AttributeValue().withS("range2c"));
    rangeValues.add(new AttributeValue().withS("range2d"));
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.BETWEEN);
    rangeKeyCondition.setAttributeValueList(rangeValues);

    DynamoDBQueryExpression<TestClassWithHashRangeKey> query = new DynamoDBQueryExpression<TestClassWithHashRangeKey>()
                .withHashKeyValues(hashKeyTemplate)
                .withRangeKeyCondition("rangeCode", rangeKeyCondition)
                ;
View Full Code Here

        String hashCode = "hash1x";

        TestClassWithHashRangeKey hashKeyTemplate = new TestClassWithHashRangeKey();
        hashKeyTemplate.setHashCode(hashCode);

        Condition rangeKeyCondition =
            new Condition()
                .withComparisonOperator(ComparisonOperator.NOT_NULL)
                ;

    DynamoDBQueryExpression<TestClassWithHashRangeKey> query = new DynamoDBQueryExpression<TestClassWithHashRangeKey>()
                .withHashKeyValues(hashKeyTemplate)
View Full Code Here

  public void queryWithUnknownHashRangeKey2() {
        putItemWithHashKeyAndRangeKey();

        String hashCode = "hash2";

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(new AttributeValue().withS("range2x"));
    attributeValueList.add(new AttributeValue().withS("range2y"));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.BETWEEN);

        TestClassWithHashRangeKey hashKeyTemplate = new TestClassWithHashRangeKey();
        hashKeyTemplate.setHashCode(hashCode);

    DynamoDBQueryExpression<TestClassWithHashRangeKey> query = new DynamoDBQueryExpression<TestClassWithHashRangeKey>()
View Full Code Here

            new QueryRequest()
                .withTableName(tableName)
                .withKeyConditions(createHashKeyCondition("id", hashKey))
                ;

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
//    attributeValueList.add(new AttributeValue().withN("1"));
    attributeValueList.add(createStringAttribute("Range2"));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.EQ);
    request.getKeyConditions().put("range", rangeKeyCondition);

        QueryResult result = getClient().query(request);

        Assert.assertNotNull("Null result.", result);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.model.Condition

Copyright © 2018 www.massapicom. 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.