Search in sources :

Example 11 with Attribute

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

the class SdbComponentIntegrationTest 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);
        }
    });
}
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 12 with Attribute

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

the class SdbComponentSpringTest 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 13 with Attribute

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

the class DeleteAttributesCommandTest method execute.

@Test
public void execute() {
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(new Attribute("NAME1", "VALUE1"));
    exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
    exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
    UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
    exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
    command.execute();
    assertEquals("DOMAIN1", sdbClient.deleteAttributesRequest.getDomainName());
    assertEquals("ITEM1", sdbClient.deleteAttributesRequest.getItemName());
    assertEquals(condition, sdbClient.deleteAttributesRequest.getExpected());
    assertEquals(attributes, sdbClient.deleteAttributesRequest.getAttributes());
}
Also used : UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) Attribute(com.amazonaws.services.simpledb.model.Attribute) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with Attribute

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

the class DeleteAttributesCommandTest method executeWithoutItemName.

@Test(expected = IllegalArgumentException.class)
public void executeWithoutItemName() {
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(new Attribute("NAME1", "VALUE1"));
    exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
    UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
    exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
    command.execute();
}
Also used : UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) Attribute(com.amazonaws.services.simpledb.model.Attribute) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with Attribute

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

the class DeleteAttributesCommandTest method determineAttributes.

@Test
public void determineAttributes() {
    assertNull(this.command.determineAttributes());
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(new Attribute("NAME1", "VALUE1"));
    exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
    assertEquals(attributes, this.command.determineAttributes());
}
Also used : Attribute(com.amazonaws.services.simpledb.model.Attribute) ArrayList(java.util.ArrayList) Test(org.junit.Test)

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