Search in sources :

Example 1 with UpdateCondition

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

the class AbstractSdbCommandTest method determineUpdateCondition.

@Test
public void determineUpdateCondition() {
    assertNull(this.command.determineUpdateCondition());
    UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
    exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
    assertSame(condition, this.command.determineUpdateCondition());
}
Also used : UpdateCondition(com.amazonaws.services.simpledb.model.UpdateCondition) Test(org.junit.Test)

Example 2 with UpdateCondition

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

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

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

the class SdbComponentSpringTest 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);
        }
    });
    assertEquals("TestDomain", amazonSDBClient.putAttributesRequest.getDomainName());
    assertEquals("ITEM1", amazonSDBClient.putAttributesRequest.getItemName());
    assertEquals(updateCondition, amazonSDBClient.putAttributesRequest.getExpected());
    assertEquals(replaceableAttributes, amazonSDBClient.putAttributesRequest.getAttributes());
}
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 5 with UpdateCondition

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

the class SdbComponentTest 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);
        }
    });
    assertEquals("TestDomain", amazonSDBClient.putAttributesRequest.getDomainName());
    assertEquals("ITEM1", amazonSDBClient.putAttributesRequest.getItemName());
    assertEquals(updateCondition, amazonSDBClient.putAttributesRequest.getExpected());
    assertEquals(replaceableAttributes, amazonSDBClient.putAttributesRequest.getAttributes());
}
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