Package com.amazonaws.services.dynamodb.model

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


    public Boolean supports(Class clazz) {
        return ScanRequest.class.isAssignableFrom(clazz);
    }

    public List<Error> validate(Object target) {
        ScanRequest instance = (ScanRequest) target;
      List<Error> errors = ValidatorUtils.invokeValidator(new TableNameValidator(), instance.getTableName());
        return removeNulls(errors);
    }
View Full Code Here


    return result;
  }

  public com.amazonaws.services.dynamodbv2.model.ScanResult scanV2(com.amazonaws.services.dynamodbv2.model.ScanRequest v2Request) {
        Table table = this.tables.get(v2Request.getTableName());
        ScanRequest request = AlternatorDBApiVersion2Mapper.MapV2ScanRequestToV1(v2Request, table);
        ScanResult result = scan(request);
        return AlternatorDBApiVersion2Mapper.MapV1ScanResultToV2(result, table);
  }
View Full Code Here


public class ScanRequestJsonUnmarshaller implements Unmarshaller<ScanRequest, JsonUnmarshallerContext> {

    public ScanRequest unmarshall(JsonUnmarshallerContext context) throws Exception {
        ScanRequest request = new ScanRequest();

        int originalDepth = context.getCurrentDepth();
        int targetDepth = originalDepth + 1;

        JsonToken token = context.currentToken;
        if (token == null) token = context.nextToken();
        while (true) {
            if (token == null) break;

            if (token == JsonToken.FIELD_NAME || token == JsonToken.START_OBJECT) {
                if (context.testExpression("TableName", targetDepth)) {
                    context.nextToken();
                    request.setTableName(SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("Limit", targetDepth)) {
                    context.nextToken();
                    request.setLimit(SimpleTypeJsonUnmarshallers.IntegerJsonUnmarshaller.getInstance().unmarshall(context));
                }if (context.testExpression("ScanFilter", targetDepth)) {
                    request.setScanFilter(new MapUnmarshaller<String, Condition>(SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance(), ConditionJsonUnmarshaller.getInstance()).unmarshall(context));
                }
                if (context.testExpression("ExclusiveStartKey", targetDepth)) {
                    request.setExclusiveStartKey(KeyJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("AttributesToGet", targetDepth)) {
                    request.setAttributesToGet(new ListUnmarshaller<String>(SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance()).unmarshall(context));
                }
            } else if (token == JsonToken.END_ARRAY || token == JsonToken.END_OBJECT) {
                if (context.getCurrentDepth() <= originalDepth) break;
            }
            token = context.nextToken();
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);
        Assert.assertNotNull(result.getItems());
        for (Map<String, AttributeValue> item : result.getItems()) {
//            Assert.assertEquals(item.get("range"), rangeKey);
View Full Code Here

        }
    }
    // Test that expected return 0 items
    @Test
    public void scanWithScanFilterEQTestThatHasNoReturn() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        attributeValueList.add(new AttributeValue().withN("30"));
        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);
        Assert.assertNotNull(result.getItems());
        Assert.assertEquals(result.getItems().size(),0);
    }
View Full Code Here

    }


    @Test
    public void scanWithScanFilterGTTestWithReturn() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
//
        attributeValueList.add(new AttributeValue().withN("50"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.GT);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);
        ScanResult result = getClient().scan(request);
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getItems());
        for (Map<String, AttributeValue> item : result.getItems()) {
            Assert.assertTrue(new Integer(item.get("range").getN()) > new Integer(new AttributeValue().withN("50").getN()));
View Full Code Here

        }
    }

    @Test
    public void scanWithScanFilterGTTestWithNoReturn() {
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();

        attributeValueList.add(new AttributeValue().withN("120"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.GT);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);
        ScanResult result = getClient().scan(request);
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getItems());
        Assert.assertEquals(result.getItems().size(),0);
    }
View Full Code Here

    @Test
    public void scanWithScanFilterGTTestWithLowLimit() {
        final int limit = 5;

        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
//
        attributeValueList.add(new AttributeValue().withN("50"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.GT);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);
        request.setLimit(limit);
        ScanResult result = getClient().scan(request);
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getItems());
        int itemCount = result.getItems().size();
        Assert.assertTrue(itemCount <= limit);
View Full Code Here

    @Test
    public void scanWithScanFilterGTTestWithHighLimit() {
        final int limit = 1000;

        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
//
        attributeValueList.add(new AttributeValue().withN("50"));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.GT);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);
        request.setLimit(limit);
        ScanResult result = getClient().scan(request);
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getItems());
        int itemCount = result.getItems().size();
        Assert.assertTrue(itemCount <= limit);
View Full Code Here

    }


    @Test
    public void scanWithScanFilterGETest() { //Greater or Equal
        ScanRequest request = getBasicReq();
        Condition rangeKeyCondition = new Condition();
        List<AttributeValue> attributeValueList = new ArrayList<AttributeValue>();
        String comparisonValue = "101";
        attributeValueList.add(new AttributeValue().withN(comparisonValue));
        rangeKeyCondition.setAttributeValueList(attributeValueList);
        rangeKeyCondition.setComparisonOperator(ComparisonOperator.GE);
        Map<String, Condition> conditionMap = new HashMap<String, Condition>();
        conditionMap.put("range", rangeKeyCondition);
        request.setScanFilter(conditionMap);
        ScanResult result = getClient().scan(request);
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getItems());
        Assert.assertEquals(90, result.getItems().size());
        final Integer i = new Integer(comparisonValue);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodb.model.ScanRequest

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.