// Path: fixture/src/main/java/todoapp/fixture/util/Util.java
// public final class Util {
//     
//     private Util(){}
// 
//     public static <T> T coalesce(final T... values) {
//         for (T t : values) {
//             if(t != null) { return t; }
//         }
//         return null;
//     }
// }


import org.isisaddons.module.security.dom.user.ApplicationUserRepository;
import todoapp.fixture.util.Util;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import org.isisaddons.module.security.dom.role.ApplicationRole;
import org.isisaddons.module.security.dom.role.ApplicationRoleRepository;
import org.isisaddons.module.security.dom.user.ApplicationUser;
        // required
        final String username = Util.coalesce(ec.getParameter("username"), getUsername());
        if (username == null) {
            throw new IllegalArgumentException("username is required");
        }

        // validate user
        this.applicationUser = applicationUserRepository.findByUsername(username);
        if(this.applicationUser == null) {
            throw new IllegalArgumentException(String.format("No user with username: '%s'", username));
        }

        // no defaults for roles

        // validate all roleNames
        this.applicationRoles =
                Lists.newArrayList(
                    Iterables.filter(
                        Iterables.transform(getRoleNames(), roleNameToRole()),
                        Predicates.notNull()));

        List<ApplicationRole> applicationRoleList = this.applicationRoles;
        List<String> roleNames = getRoleNames();
        if(applicationRoleList.size() != roleNames.size()) {
            throw new IllegalArgumentException("One or more roles not found");
        }

        // execute
        ec.addResult(this, applicationUser.getName(), this.applicationUser);

// Path: fixture/src/main/java/todoapp/fixture/util/Util.java
// public final class Util {
//     
//     private Util(){}
// 
//     public static <T> T coalesce(final T... values) {
//         for (T t : values) {
//             if(t != null) { return t; }
//         }
//         return null;
//     }
// }


// Path: fixture/src/main/java/todoapp/fixture/module/security/UserRolesFixtureScript.java
import org.isisaddons.module.security.dom.user.ApplicationUserRepository;
import todoapp.fixture.util.Util;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import org.isisaddons.module.security.dom.role.ApplicationRole;
import org.isisaddons.module.security.dom.role.ApplicationRoleRepository;
import org.isisaddons.module.security.dom.user.ApplicationUser;

        // required
        final String username = Util.coalesce(ec.getParameter("username"), getUsername());
        if (username == null) {
            throw new IllegalArgumentException("username is required");
        }

        // validate user
        this.applicationUser = applicationUserRepository.findByUsername(username);
        if(this.applicationUser == null) {
            throw new IllegalArgumentException(String.format("No user with username: '%s'", username));
        }

        // no defaults for roles

        // validate all roleNames
        this.applicationRoles =
                Lists.newArrayList(
                    Iterables.filter(
                        Iterables.transform(getRoleNames(), roleNameToRole()),
                        Predicates.notNull()));

        List<ApplicationRole> applicationRoleList = this.applicationRoles;
        List<String> roleNames = getRoleNames();
        if(applicationRoleList.size() != roleNames.size()) {
            throw new IllegalArgumentException("One or more roles not found");
        }

        // execute
        ec.addResult(this, applicationUser.getName(), this.applicationUser);

        for (ApplicationRole applicationRole : this.applicationRoles) {