@Test
void doDeletePartialPermissionWithInvalidReference() {

	assertThat(storageMock.getAllExecutions()).isEmpty();
	final ManagedQuery managedQuery1 = createManagedQuery();
	final ManagedQuery managedQuery2 = createManagedQuery();
	// Removing the second execution
	storageMock.removeExecution(managedQuery2.getId());
	User user = new User("test", "test");
	storageMock.updateUser(user);
	user.addPermission(
		storageMock,
		// Build a permission with multiple instances
		new WildcardPermission(List.of(
			Set.of(QueryPermission.DOMAIN),
			Set.of(Ability.READ.toString().toLowerCase()),
			Set.of(managedQuery1.getId().toString(), managedQuery2.getId().toString())), Instant.now()));
	QueryCleanupTask.deleteQueryPermissionsWithMissingRef(storageMock, storageMock.getAllUsers());
	
	assertThat(user.getPermissions()).containsOnly(QueryPermission.onInstance(Ability.READ, managedQuery1.getId()));
	
}