use of com.amazonaws.services.simpledb.model.SelectResult in project SimianArmy by Netflix.
the class TestSimpleDBJanitorResourceTracker method mkSelectResult.
private SelectResult mkSelectResult(String id, AWSResourceType resourceType, Resource.CleanupState state, String description, String ownerEmail, String region, String terminationReason, Date expectedTerminationTime, Date markTime, boolean optOut, String fieldName, String fieldValue) {
Item item = new Item();
List<Attribute> attrs = new LinkedList<Attribute>();
attrs.add(new Attribute(AWSResource.FIELD_RESOURCE_ID, id));
attrs.add(new Attribute(AWSResource.FIELD_RESOURCE_TYPE, resourceType.name()));
attrs.add(new Attribute(AWSResource.FIELD_DESCRIPTION, description));
attrs.add(new Attribute(AWSResource.FIELD_REGION, region));
attrs.add(new Attribute(AWSResource.FIELD_STATE, state.name()));
attrs.add(new Attribute(AWSResource.FIELD_OWNER_EMAIL, ownerEmail));
attrs.add(new Attribute(AWSResource.FIELD_TERMINATION_REASON, terminationReason));
attrs.add(new Attribute(AWSResource.FIELD_EXPECTED_TERMINATION_TIME, AWSResource.DATE_FORMATTER.print(expectedTerminationTime.getTime())));
attrs.add(new Attribute(AWSResource.FIELD_MARK_TIME, AWSResource.DATE_FORMATTER.print(markTime.getTime())));
attrs.add(new Attribute(AWSResource.FIELD_OPT_OUT_OF_JANITOR, String.valueOf(optOut)));
attrs.add(new Attribute(fieldName, fieldValue));
item.setAttributes(attrs);
item.setName(String.format("%s-%s-%s", resourceType.name(), id, region));
SelectResult result = new SelectResult();
result.setItems(Arrays.asList(item));
return result;
}
use of com.amazonaws.services.simpledb.model.SelectResult in project SimianArmy by Netflix.
the class TestSimpleDBJanitorResourceTracker method testGetResources.
@Test
public void testGetResources() {
String id1 = "id-1";
String id2 = "id-2";
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";
SelectResult result1 = mkSelectResult(id1, resourceType, state, description, ownerEmail, region, terminationReason, expectedTerminationTime, markTime, false, fieldName, fieldValue);
result1.setNextToken("nextToken");
SelectResult result2 = mkSelectResult(id2, resourceType, state, description, ownerEmail, region, terminationReason, expectedTerminationTime, markTime, true, fieldName, fieldValue);
ArgumentCaptor<SelectRequest> arg = ArgumentCaptor.forClass(SelectRequest.class);
TestSimpleDBJanitorResourceTracker tracker = new TestSimpleDBJanitorResourceTracker();
when(tracker.sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyResources(tracker.getResources(resourceType, state, region), id1, id2, resourceType, state, description, ownerEmail, region, terminationReason, expectedTerminationTime, markTime, fieldName, fieldValue);
verify(tracker.sdbMock, times(2)).select(arg.capture());
}
Aggregations