public void testGetEventsRangeUpperOutside()
throws Exception
{
Date current = new Date();
AuditEvent event1 = createEvent( new Date( current.getTime() - 12345 ) );
Date expectedTimestamp = new Date( current.getTime() - 3000 );
AuditEvent expectedEvent2 = createEvent( expectedTimestamp );
Date ts3 = new Date( current.getTime() - 1000 );
AuditEvent expectedEvent3 = createEvent( ts3 );
EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn(
Arrays.asList( event1.getName(), expectedEvent2.getName(), expectedEvent3.getName() ) );
EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID,
expectedEvent2.getName() ) ).andReturn( expectedEvent2 );
EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID,
expectedEvent3.getName() ) ).andReturn( expectedEvent3 );
metadataRepositoryControl.replay();
List<AuditEvent> events =
auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
new Date( current.getTime() - 4000 ), current );
assertEquals( 2, events.size() );
assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
assertTestEvent( events.get( 1 ), TIMESTAMP_FORMAT.format( expectedTimestamp ), expectedEvent2.getResource() );
metadataRepositoryControl.verify();
}