Search in sources :

Example 1 with Attribute

use of com.amazonaws.services.simpledb.model.Attribute in project camel by apache.

the class SdbComponentTest method deleteAttributesItemNameIsRequired.

@Test
public void deleteAttributesItemNameIsRequired() {
    final List<Attribute> attributes = Arrays.asList(new Attribute[] { new Attribute("NAME1", "VALUE1") });
    final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
    Exchange exchange = template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
            exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
            exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
        }
    });
    Exception exception = exchange.getException();
    assertTrue(exception instanceof IllegalArgumentException);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) Attribute(com.amazonaws.services.simpledb.model.Attribute) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 2 with Attribute

use of com.amazonaws.services.simpledb.model.Attribute in project camel by apache.

the class SdbComponentTest method getAttributes.

@SuppressWarnings("unchecked")
@Test
public void getAttributes() {
    final List<String> attributeNames = Arrays.asList(new String[] { "ATTRIBUTE1" });
    Exchange exchange = template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
            exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
            exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
            exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
        }
    });
    assertEquals("TestDomain", amazonSDBClient.getAttributesRequest.getDomainName());
    assertEquals("ITEM1", amazonSDBClient.getAttributesRequest.getItemName());
    assertEquals(Boolean.TRUE, amazonSDBClient.getAttributesRequest.getConsistentRead());
    assertEquals(attributeNames, amazonSDBClient.getAttributesRequest.getAttributeNames());
    List<Attribute> attributes = exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class);
    assertEquals(2, attributes.size());
    assertEquals("AttributeOne", attributes.get(0).getName());
    assertEquals("Value One", attributes.get(0).getValue());
    assertEquals("AttributeTwo", attributes.get(1).getName());
    assertEquals("Value Two", attributes.get(1).getValue());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Attribute(com.amazonaws.services.simpledb.model.Attribute) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 3 with Attribute

use of com.amazonaws.services.simpledb.model.Attribute in project camel by apache.

the class SdbComponentSpringTest method deleteAttributesItemNameIsRequired.

@Test
public void deleteAttributesItemNameIsRequired() {
    final List<Attribute> attributes = Arrays.asList(new Attribute[] { new Attribute("NAME1", "VALUE1") });
    final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
    Exchange exchange = template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
            exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
            exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
        }
    });
    Exception exception = exchange.getException();
    assertTrue(exception instanceof IllegalArgumentException);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) Attribute(com.amazonaws.services.simpledb.model.Attribute) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 4 with Attribute

use of com.amazonaws.services.simpledb.model.Attribute in project camel by apache.

the class SdbComponentTest method deleteAttributes.

@Test
public void deleteAttributes() {
    final List<Attribute> attributes = Arrays.asList(new Attribute[] { new Attribute("NAME1", "VALUE1") });
    final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
    template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
            exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
            exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
            exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
        }
    });
    assertEquals("TestDomain", amazonSDBClient.deleteAttributesRequest.getDomainName());
    assertEquals("ITEM1", amazonSDBClient.deleteAttributesRequest.getItemName());
    assertEquals(condition, amazonSDBClient.deleteAttributesRequest.getExpected());
    assertEquals(attributes, amazonSDBClient.deleteAttributesRequest.getAttributes());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) Attribute(com.amazonaws.services.simpledb.model.Attribute) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 5 with Attribute

use of com.amazonaws.services.simpledb.model.Attribute in project teiid by teiid.

the class SimpleDBQueryExecution method createAttributeMap.

protected Map<String, List<String>> createAttributeMap(List<Attribute> attributes) {
    Map<String, List<String>> map = new TreeMap<String, List<String>>();
    for (Attribute attribute : attributes) {
        if (map.get(attribute.getName()) == null) {
            List<String> list = new ArrayList<String>();
            list.add(attribute.getValue());
            map.put(attribute.getName(), list);
        } else {
            map.get(attribute.getName()).add(attribute.getValue());
        }
    }
    return map;
}
Also used : Attribute(com.amazonaws.services.simpledb.model.Attribute) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap)

Aggregations

Attribute (com.amazonaws.services.simpledb.model.Attribute)27 ReplaceableAttribute (com.amazonaws.services.simpledb.model.ReplaceableAttribute)18 Test (org.junit.Test)12 Item (com.amazonaws.services.simpledb.model.Item)8 UpdateCondition (com.amazonaws.services.simpledb.model.UpdateCondition)8 ArrayList (java.util.ArrayList)8 Exchange (org.apache.camel.Exchange)8 Processor (org.apache.camel.Processor)8 SelectResult (com.amazonaws.services.simpledb.model.SelectResult)5 LinkedList (java.util.LinkedList)3 DeleteAttributesRequest (com.amazonaws.services.simpledb.model.DeleteAttributesRequest)2 PutAttributesRequest (com.amazonaws.services.simpledb.model.PutAttributesRequest)2 SelectRequest (com.amazonaws.services.simpledb.model.SelectRequest)2 Field (java.lang.reflect.Field)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 AmazonClientException (com.amazonaws.AmazonClientException)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 AmazonSimpleDB (com.amazonaws.services.simpledb.AmazonSimpleDB)1