#NEWLINE# def testTwoJournalEntriesAreAddedAfterTwoAddToCollectionCalls( self ) : #NEWLINE# #INDENT# self . _EnableJournaling ( ) #NEWLINE# with aff4 . FACTORY . Create ( self . collection_urn , 'PackedVersionedCollection' , mode = 'w' , token = self . token ) as _ : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# aff4 . PackedVersionedCollection . AddToCollection ( fd . collection_urn , [ rdf_flows . GrrMessage ( request_id = 1 ) , rdf_flows . GrrMessage ( request_id = 2 ) ] , token = self . token ) #NEWLINE# aff4 . PackedVersionedCollection . AddToCollection ( self . collection_urn , [ rdf_flows . GrrMessage ( request_id = 3 ) ] , token = self . token ) #NEWLINE# fd = aff4 . FACTORY . Open ( self . collection_urn , age = aff4 . ALL_TIMES , token = self . token ) #NEWLINE# addition_journal = sorted ( fd . GetValuesForAttribute ( fd . Schema . ADDITION_JOURNAL ) , key = ( lambda x : x . age ) ) #NEWLINE# self . assertEqual ( len ( addition_journal ) , 2 ) #NEWLINE# self . assertEqual ( addition_journal [ 0 ] , 2 ) #NEWLINE# self . assertEqual ( addition_journal [ 1 ] , 1 )