Package com.amazonaws.services.dynamodb.model

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


  public void queryWithHashKeyAndNumericRangeKeyConditionGETest() {
        AttributeValue hashKey = setupNumericRangeTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(hashKey);

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(createNumberAttribute(2));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.GE);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        // NOTE: GE is currently a string comparison, so "11" is NOT > "2".
View Full Code Here


  public void queryWithHashKeyAndNumericRangeKeyConditionINTest() {
        AttributeValue hashKey = setupNumericRangeTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(hashKey);

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(createNumberAttribute(2));
    attributeValueList.add(createNumberAttribute(4));
    attributeValueList.add(createNumberAttribute(0));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.IN);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        Assert.assertEquals("Should return two items.", 2, result.getItems().size());
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionBETWEENTest() {
        AttributeValue hashKey = setupNumericRangeTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(hashKey);

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(createNumberAttribute(2));
    attributeValueList.add(createNumberAttribute(3));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.BETWEEN);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        Assert.assertEquals("Should return two items.", 2, result.getItems().size());
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionBEGINSWITHTest() {
        AttributeValue hashKey = setupNumericRangeTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(hashKey);

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(createNumberAttribute(1));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.BEGINS_WITH);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        // NOTE: BEGINS_WITH is currently a string comparison, so "11" begins with "1".
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionCONTAINSTest() {
        AttributeValue hashKey = setupNumericRangeTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(hashKey);

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(createNumberAttribute(1));
    rangeKeyCondition.setAttributeValueList(attributeValueList);
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.CONTAINS);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        // NOTE: CONTAINS is currently a string comparison, so "1", "11", "51" all contain "1".
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

  //TODO : tests using the DynamoDBMapper instead of the Client.

    @Test
    public void scanWithScanFilterEQTestThatHasReturn() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
//        attributeValueList.add(new AttributeValue().withN(rangeKey.getN()));
        attributeValueList.add(new AttributeValue().withN("55"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.EQ);
        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

TOP

Related Classes of com.amazonaws.services.dynamodb.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.