Package com.amazonaws.services.dynamodb.model

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


  public void queryWithHashKeyAndRangeKeyConditionGTTest() {
        AttributeValue hashKey = setupTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(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.GT);
    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 queryWithHashKeyAndRangeKeyConditionGETest() {
        AttributeValue hashKey = setupTableWithSeveralItems();

        QueryRequest request = new QueryRequest().withTableName(tableName).withHashKeyValue(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.GE);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        Assert.assertEquals("Should return three items.", 3, result.getItems().size());
View Full Code Here

  public void queryWithHashKeyAndRangeKeyConditionINTest() {
        AttributeValue hashKey = setupTableWithSeveralItems();

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

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(new AttributeValue().withS("Range2"));
    attributeValueList.add(new AttributeValue().withS("Range4"));
    attributeValueList.add(new AttributeValue().withS("Range0"));
    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 queryWithHashKeyAndRangeKeyConditionBETWEENTest() {
        AttributeValue hashKey = setupTableWithSeveralItems();

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

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(new AttributeValue().withS("Range2"));
    attributeValueList.add(new AttributeValue().withS("Range3"));
    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 queryWithHashKeyAndRangeKeyConditionBEGINSWITHTest() {
        AttributeValue hashKey = setupTableWithSeveralItems();

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

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(new AttributeValue().withS("Range"));
    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());
        Assert.assertEquals("Should return four items.", 4, result.getItems().size());
View Full Code Here

  public void queryWithHashKeyAndRangeKeyConditionCONTAINSTest() {
        AttributeValue hashKey = setupTableWithSeveralItems();

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

    Condition rangeKeyCondition = new Condition();
    List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
    attributeValueList.add(new AttributeValue().withS("ange1"));
    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());
        Assert.assertEquals("Should return two items.", 2, result.getItems().size());
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionEQTest() {
        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.EQ);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        Assert.assertEquals("Should return one item.", 1, result.getItems().size());
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionLTTest() {
        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.LT);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        // NOTE: LT is currently a string comparison, so "11" is < "2".
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionLETest() {
        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.LE);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        // NOTE: LE is currently a string comparison, so "11" is <= "2".
View Full Code Here

  public void queryWithHashKeyAndNumericRangeKeyConditionGTTest() {
        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.GT);
    request.setRangeKeyCondition(rangeKeyCondition);
    QueryResult result = getClient().query(request);
    Assert.assertNotNull("Null result.", result);
    Assert.assertNotNull("No items returned.", result.getItems());
        // NOTE: GT is currently a string comparison, so "11" is NOT > "2".
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.