Source:
public void testCreate() { Book book = mock(Book.class); DataStoreTransaction tx = mock(DataStoreTransaction.class); when(tx.createNewObject(Book.class)).thenReturn(book); RequestScope scope = new RequestScope(null, null, tx, new User(1), null, getElideSettings(null, dictionary, MOCK_AUDIT_LOGGER), false); PersistentResource resource = PersistentResource.createObject(null, Book.class, scope, Optional.of("uuid")); resource.setValueChecked("title", "should not affect calls since this is create!"); resource.setValueChecked("genre", "boring books"); assertNotNull(resource); verify(book, never()).onCreatePreSecurity(scope); verify(book, never()).checkPermission(scope); scope.runQueuedPreSecurityTriggers(); verify(book, times(1)).onCreatePreSecurity(scope); verify(book, never()).onDeletePreSecurity(scope); verify(book, never()).onUpdatePreSecurityTitle(scope); verify(book, never()).onCreatePreCommit(eq(scope), any()); verify(book, times(1)).onReadPreSecurity(scope); verify(book, never()).checkPermission(scope); scope.runQueuedPreCommitTriggers(); verify(book, times(1)).onCreatePreCommit(scope); verify(book, never()).onDeletePreCommit(scope); verify(book, never()).onUpdatePreCommitTitle(scope); verify(book, times(2)).onCreatePreCommit(eq(scope), any()); verify(book, times(1)).onReadPreCommitTitle(scope); verify(book, never()).checkPermission(scope); scope.getPermissionExecutor().executeCommitChecks(); verify(book, times(3)).checkPermission(scope); scope.runQueuedPostCommitTriggers(); verify(book, times(1)).onCreatePostCommit(scope); verify(book, never()).onDeletePostCommit(scope); verify(book, never()).onUpdatePostCommitTitle(scope); verify(book, times(2)).onCreatePreCommit(eq(scope), any()); verify(book, times(1)).onReadPostCommit(scope); verify(book, times(3)).checkPermission(scope); }

Target:
public void testCreate() { Book book = mock(Book.class); DataStoreTransaction tx = mock(DataStoreTransaction.class); when(tx.createNewObject(Book.class)).thenReturn(book); RequestScope scope = new RequestScope(null, null, tx, new User(1), null, getElideSettings(null, dictionary, MOCK_AUDIT_LOGGER), false); PersistentResource resource = PersistentResource.createObject(null, Book.class, scope, Optional.of("uuid")); resource.setValueChecked("title", "should not affect calls since this is create!"); resource.setValueChecked("genre", "boring books"); assertNotNull(resource); verify(book, never()).onCreatePreSecurity(scope); verify(book, never()).checkPermission(scope); scope.runQueuedPreSecurityTriggers(); verify(book, times(1)).onCreatePreSecurity(scope); verify(book, never()).onDeletePreSecurity(scope); verify(book, never()).onUpdatePreSecurityTitle(scope); verify(book, never()).onCreatePreCommitStar(eq(scope), any()); verify(book, times(1)).onReadPreSecurity(scope); verify(book, never()).checkPermission(scope); scope.runQueuedPreCommitTriggers(); verify(book, times(1)).onCreatePreCommit(scope); verify(book, never()).onDeletePreCommit(scope); verify(book, never()).onUpdatePreCommitTitle(scope); verify(book, times(2)).onCreatePreCommitStar(eq(scope), any()); verify(book, times(1)).onReadPreCommitTitle(scope); verify(book, never()).checkPermission(scope); scope.getPermissionExecutor().executeCommitChecks(); verify(book, times(3)).checkPermission(scope); scope.runQueuedPostCommitTriggers(); verify(book, times(1)).onCreatePostCommit(scope); verify(book, never()).onDeletePostCommit(scope); verify(book, never()).onUpdatePostCommitTitle(scope); verify(book, times(2)).onCreatePreCommitStar(eq(scope), any()); verify(book, times(1)).onReadPostCommit(scope); verify(book, times(3)).checkPermission(scope); }