query.put("instanceId", "testId1");
verifyEvents(findEvents(query, new Date(0)));
verify(sdbMock, times(2)).select(arg.capture());
SelectRequest req = arg.getValue();
StringBuilder sb = new StringBuilder();
sb.append("select * from `DOMAIN` where region = 'region'");
sb.append(" and instanceId = 'testId1'");
Assert.assertEquals(req.getSelectExpression(), sb.toString() + " and eventTime > '0' order by eventTime desc");
// reset for next test
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyEvents(findEvents(Type.MONKEY, query, new Date(0)));
verify(sdbMock, times(4)).select(arg.capture());
req = arg.getValue();
sb.append(" and monkeyType = 'MONKEY|com.netflix.simianarmy.aws.TestSimpleDBRecorder$Type'");
Assert.assertEquals(req.getSelectExpression(), sb.toString() + " and eventTime > '0' order by eventTime desc");
// reset for next test
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyEvents(findEvents(Type.MONKEY, EventTypes.EVENT, query, new Date(0)));
verify(sdbMock, times(6)).select(arg.capture());
req = arg.getValue();
sb.append(" and eventType = 'EVENT|com.netflix.simianarmy.aws.TestSimpleDBRecorder$EventTypes'");
Assert.assertEquals(req.getSelectExpression(), sb.toString() + " and eventTime > '0' order by eventTime desc");
// reset for next test
when(sdbMock.select(any(SelectRequest.class))).thenReturn(result1).thenReturn(result2);
verifyEvents(findEvents(Type.MONKEY, EventTypes.EVENT, query, new Date(1330538400000L)));
verify(sdbMock, times(8)).select(arg.capture());
req = arg.getValue();
sb.append(" and eventTime > '1330538400000' order by eventTime desc");
Assert.assertEquals(req.getSelectExpression(), sb.toString());
}