use of com.amazonaws.services.simpledb.model.ReplaceableAttribute 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);
}
});
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute 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);
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project camel by apache.
the class SdbComponentTest 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);
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project SimianArmy by Netflix.
the class SimpleDBConformityClusterTracker method addOrUpdate.
/** {@inheritDoc} */
@Override
public void addOrUpdate(Cluster cluster) {
List<ReplaceableAttribute> attrs = new ArrayList<ReplaceableAttribute>();
Map<String, String> fieldToValueMap = cluster.getFieldToValueMap();
for (Map.Entry<String, String> entry : fieldToValueMap.entrySet()) {
attrs.add(new ReplaceableAttribute(entry.getKey(), StringUtils.left(entry.getValue(), MAX_ATTR_SIZE), true));
}
PutAttributesRequest putReqest = new PutAttributesRequest(domain, getSimpleDBItemName(cluster), attrs);
LOGGER.debug(String.format("Saving cluster %s to SimpleDB domain %s", cluster.getName(), domain));
this.simpleDBClient.putAttributes(putReqest);
LOGGER.debug("Successfully saved.");
}
use of com.amazonaws.services.simpledb.model.ReplaceableAttribute in project SimianArmy by Netflix.
the class TestSimpleDBJanitorResourceTracker method testAddResource.
@Test
public void testAddResource() {
String id = "i-12345678901234567";
AWSResourceType resourceType = AWSResourceType.INSTANCE;
Resource.CleanupState state = Resource.CleanupState.MARKED;
String description = "This is a test resource.";
String ownerEmail = "owner@test.com";
String region = "us-east-1";
String terminationReason = "This is a test termination reason.";
DateTime now = DateTime.now();
Date expectedTerminationTime = new Date(now.plusDays(10).getMillis());
Date markTime = new Date(now.getMillis());
String fieldName = "fieldName123";
String fieldValue = "fieldValue456";
Resource resource = new AWSResource().withId(id).withResourceType(resourceType).withDescription(description).withOwnerEmail(ownerEmail).withRegion(region).withState(state).withTerminationReason(terminationReason).withExpectedTerminationTime(expectedTerminationTime).withMarkTime(markTime).withOptOutOfJanitor(false).setAdditionalField(fieldName, fieldValue);
ArgumentCaptor<PutAttributesRequest> arg = ArgumentCaptor.forClass(PutAttributesRequest.class);
TestSimpleDBJanitorResourceTracker tracker = new TestSimpleDBJanitorResourceTracker();
tracker.addOrUpdate(resource);
verify(tracker.sdbMock).putAttributes(arg.capture());
PutAttributesRequest req = arg.getValue();
Assert.assertEquals(req.getDomainName(), "DOMAIN");
Assert.assertEquals(req.getItemName(), getSimpleDBItemName(resource));
Map<String, String> map = new HashMap<String, String>();
for (ReplaceableAttribute attr : req.getAttributes()) {
map.put(attr.getName(), attr.getValue());
}
Assert.assertEquals(map.remove(AWSResource.FIELD_RESOURCE_ID), id);
Assert.assertEquals(map.remove(AWSResource.FIELD_DESCRIPTION), description);
Assert.assertEquals(map.remove(AWSResource.FIELD_EXPECTED_TERMINATION_TIME), AWSResource.DATE_FORMATTER.print(expectedTerminationTime.getTime()));
Assert.assertEquals(map.remove(AWSResource.FIELD_MARK_TIME), AWSResource.DATE_FORMATTER.print(markTime.getTime()));
Assert.assertEquals(map.remove(AWSResource.FIELD_REGION), region);
Assert.assertEquals(map.remove(AWSResource.FIELD_OWNER_EMAIL), ownerEmail);
Assert.assertEquals(map.remove(AWSResource.FIELD_RESOURCE_TYPE), resourceType.name());
Assert.assertEquals(map.remove(AWSResource.FIELD_STATE), state.name());
Assert.assertEquals(map.remove(AWSResource.FIELD_TERMINATION_REASON), terminationReason);
Assert.assertEquals(map.remove(AWSResource.FIELD_OPT_OUT_OF_JANITOR), "false");
Assert.assertEquals(map.remove(fieldName), fieldValue);
Assert.assertEquals(map.size(), 0);
}
Aggregations