Search in sources :

Example 11 with UpdateCondition

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

the class PutAttributesCommandTest method execute.

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

Example 12 with UpdateCondition

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

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

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

the class SdbComponentIntegrationTest method putAttributes.

@Test
public void putAttributes() {
    final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] { new ReplaceableAttribute("NAME1", "VALUE1", true) });
    final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
    template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
            exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
            exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
            exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
        }
    });
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 14 with UpdateCondition

use of com.amazonaws.services.simpledb.model.UpdateCondition 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 15 with UpdateCondition

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

the class SdbComponentSpringTest method putAttributesItemNameIsRequired.

@Test
public void putAttributesItemNameIsRequired() {
    final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] { new ReplaceableAttribute("NAME1", "VALUE1", true) });
    final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
    Exchange exchange = template.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
            exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
            exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
        }
    });
    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) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Aggregations

UpdateCondition (com.amazonaws.services.simpledb.model.UpdateCondition)16 Test (org.junit.Test)15 ReplaceableAttribute (com.amazonaws.services.simpledb.model.ReplaceableAttribute)13 Exchange (org.apache.camel.Exchange)10 Processor (org.apache.camel.Processor)10 Attribute (com.amazonaws.services.simpledb.model.Attribute)8 ArrayList (java.util.ArrayList)5 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 DeleteAttributesRequest (com.amazonaws.services.simpledb.model.DeleteAttributesRequest)1 PutAttributesRequest (com.amazonaws.services.simpledb.model.PutAttributesRequest)1 AnnotationInfo (com.spaceprogram.simplejpa.AnnotationInfo)1 LazyInterceptor (com.spaceprogram.simplejpa.LazyInterceptor)1 PersistentProperty (com.spaceprogram.simplejpa.PersistentProperty)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Collection (java.util.Collection)1 CascadeType (javax.persistence.CascadeType)1 ManyToOne (javax.persistence.ManyToOne)1