@Test
public void copyOf_updates_metadata_created_and_lastModified() {
BrokerPool mockBrokerPool = EasyMock.createMock(BrokerPool.class);
Database mockDatabase = EasyMock.createMock(Database.class);
Subject mockCurrentSubject = EasyMock.createMock(Subject.class);
Group mockCurrentSubjectGroup= EasyMock.createMock(Group.class);
SecurityManager mockSecurityManager = EasyMock.createMock(SecurityManager.class);
PermissionFactory.sm = mockSecurityManager;
//test values
final DocumentMetadata docMetadata = new TestableDocumentMetadata();
final DocumentMetadata otherMetadata = new DocumentMetadata();
final long otherCreated = System.currentTimeMillis() - 2000;
final long otherLastModified = System.currentTimeMillis() - 1000;
//expectations
expect(mockSecurityManager.getDatabase()).andReturn(mockDatabase).times(2);
expect(mockDatabase.getSubject()).andReturn(mockCurrentSubject).times(2);
expect(mockCurrentSubject.getUserMask()).andReturn(Permission.DEFAULT_UMASK).times(2);
expect(mockCurrentSubject.getId()).andReturn(RealmImpl.SYSTEM_ACCOUNT_ID).times(2);
expect(mockCurrentSubject.getDefaultGroup()).andReturn(mockCurrentSubjectGroup).times(2);
expect(mockCurrentSubjectGroup.getId()).andReturn(RealmImpl.DBA_GROUP_ID).times(2);
replay(mockBrokerPool, mockDatabase, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);
//test setup