Example usage for org.apache.commons.lang RandomStringUtils randomAlphanumeric

List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphanumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang RandomStringUtils randomAlphanumeric.

Prototype

public static String randomAlphanumeric(int count) 

Source Link

Document

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of alpha-numeric characters.

Usage

From source file:org.apache.marmotta.platform.core.test.ld.LinkedDataTest.java

private static URI randomResource() {
    return sesameService.getRepository().getValueFactory().createURI(RestAssured.baseURI + ":"
            + RestAssured.port + RestAssured.basePath + "/resource/" + RandomStringUtils.randomAlphanumeric(8));
}

From source file:org.apache.niolex.commons.test.MockUtil.java

/**
 * Generates random string which contains only alphabetic and number.
 *
 * @param length the length of the generated string
 * @return the result/*from  ww w  .  j  a v  a2  s .c o  m*/
 */
public static final String randString(int length) {
    return RandomStringUtils.randomAlphanumeric(length);
}

From source file:org.apache.ofbiz.base.util.UtilHttp.java

public static String stashParameterMap(HttpServletRequest request) {
    HttpSession session = request.getSession();
    Map<String, Map<String, Object>> paramMapStore = UtilGenerics
            .checkMap(session.getAttribute("_PARAM_MAP_STORE_"));
    if (paramMapStore == null) {
        paramMapStore = new HashMap<String, Map<String, Object>>();
        session.setAttribute("_PARAM_MAP_STORE_", paramMapStore);
    }//from  w  ww  .j a  v  a 2 s. co  m
    Map<String, Object> parameters = getParameterMap(request);
    String paramMapId = RandomStringUtils.randomAlphanumeric(10);
    paramMapStore.put(paramMapId, parameters);
    return paramMapId;
}

From source file:org.apache.ofbiz.passport.event.GitHubEvents.java

private static String checkLoginGitHubUser(HttpServletRequest request, Map<String, Object> userInfo,
        String accessToken) {//from ww  w.j a  v  a  2s.  c om
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    String productStoreId = ProductStoreWorker.getProductStoreId(request);
    String gitHubUserId = (String) userInfo.get("login");
    GenericValue gitHubUser = null;
    try {
        gitHubUser = delegator.findOne("GitHubUser", UtilMisc.toMap("gitHubUserId", gitHubUserId), false);
    } catch (GenericEntityException e) {
        request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
        return "error";
    }
    if (UtilValidate.isNotEmpty(gitHubUser)) {
        boolean dataChanged = false;
        if (!accessToken.equals(gitHubUser.getString("accessToken"))) {
            gitHubUser.set("accessToken", accessToken);
            dataChanged = true;
        }
        if (!envPrefix.equals(gitHubUser.getString("envPrefix"))) {
            gitHubUser.set("envPrefix", envPrefix);
            dataChanged = true;
        }
        if (!productStoreId.equals(gitHubUser.getString("productStoreId"))) {
            gitHubUser.set("productStoreId", productStoreId);
            dataChanged = true;
        }
        if (dataChanged) {
            try {
                gitHubUser.store();
            } catch (GenericEntityException e) {
                Debug.logError(e.getMessage(), module);
            }
        }
    } else {
        gitHubUser = delegator.makeValue("GitHubUser", UtilMisc.toMap("accessToken", accessToken,
                "productStoreId", productStoreId, "envPrefix", envPrefix, "gitHubUserId", gitHubUserId));
        try {
            gitHubUser.create();
        } catch (GenericEntityException e) {
            Debug.logError(e.getMessage(), module);
        }
    }
    try {
        GenericValue userLogin = EntityUtil.getFirst(
                delegator.findByAnd("UserLogin", UtilMisc.toMap("externalAuthId", gitHubUserId), null, false));
        GitHubAuthenticator authn = new GitHubAuthenticator();
        authn.initialize(dispatcher);
        if (UtilValidate.isEmpty(userLogin)) {
            String userLoginId = authn.createUser(userInfo);
            userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false);
        }
        String autoPassword = RandomStringUtils.randomAlphanumeric(
                EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue());
        boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt"));
        userLogin.set("currentPassword",
                useEncryption ? HashCrypt.digestHash(LoginServices.getHashType(), null, autoPassword)
                        : autoPassword);
        userLogin.store();
        request.setAttribute("USERNAME", userLogin.getString("userLoginId"));
        request.setAttribute("PASSWORD", autoPassword);
    } catch (GenericEntityException e) {
        Debug.logError(e.getMessage(), module);
        request.setAttribute("_ERROR_MESSAGE_", e.toString());
        return "error";
    } catch (AuthenticatorException e) {
        Debug.logError(e.getMessage(), module);
        request.setAttribute("_ERROR_MESSAGE_", e.toString());
        return "error";
    }
    return "success";
}

From source file:org.apache.ofbiz.passport.event.LinkedInEvents.java

private static String checkLoginLinkedInUser(HttpServletRequest request, Document userInfo,
        String accessToken) {// ww  w .j  a va2  s  .  com
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    String productStoreId = ProductStoreWorker.getProductStoreId(request);
    String linkedInUserId = LinkedInAuthenticator.getLinkedInUserId(userInfo);
    GenericValue linkedInUser = null;
    try {
        linkedInUser = delegator.findOne("LinkedInUser", UtilMisc.toMap("linkedInUserId", linkedInUserId),
                false);
    } catch (GenericEntityException e) {
        request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
        return "error";
    }
    if (linkedInUser != null) {
        boolean dataChanged = false;
        if (!accessToken.equals(linkedInUser.getString("accessToken"))) {
            linkedInUser.set("accessToken", accessToken);
            dataChanged = true;
        }
        if (!envPrefix.equals(linkedInUser.getString("envPrefix"))) {
            linkedInUser.set("envPrefix", envPrefix);
            dataChanged = true;
        }
        if (!productStoreId.equals(linkedInUser.getString("productStoreId"))) {
            linkedInUser.set("productStoreId", productStoreId);
            dataChanged = true;
        }
        if (dataChanged) {
            try {
                linkedInUser.store();
            } catch (GenericEntityException e) {
                Debug.logError(e.getMessage(), module);
            }
        }
    } else {
        linkedInUser = delegator.makeValue("LinkedInUser", UtilMisc.toMap("accessToken", accessToken,
                "productStoreId", productStoreId, "envPrefix", envPrefix, "linkedInUserId", linkedInUserId));
        try {
            linkedInUser.create();
        } catch (GenericEntityException e) {
            Debug.logError(e.getMessage(), module);
        }
    }
    try {
        GenericValue userLogin = EntityUtil.getFirst(delegator.findByAnd("UserLogin",
                UtilMisc.toMap("externalAuthId", linkedInUserId), null, false));
        LinkedInAuthenticator authn = new LinkedInAuthenticator();
        authn.initialize(dispatcher);
        if (UtilValidate.isEmpty(userLogin)) {
            String userLoginId = authn.createUser(userInfo);
            userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", userLoginId), false);
        }
        String autoPassword = RandomStringUtils.randomAlphanumeric(
                EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue());
        boolean useEncryption = "true".equals(UtilProperties.getPropertyValue("security", "password.encrypt"));
        userLogin.set("currentPassword",
                useEncryption ? HashCrypt.digestHash(LoginServices.getHashType(), null, autoPassword)
                        : autoPassword);
        userLogin.store();
        request.setAttribute("USERNAME", userLogin.getString("userLoginId"));
        request.setAttribute("PASSWORD", autoPassword);
    } catch (GenericEntityException e) {
        Debug.logError(e.getMessage(), module);
        request.setAttribute("_ERROR_MESSAGE_", e.toString());
        return "error";
    } catch (AuthenticatorException e) {
        Debug.logError(e.getMessage(), module);
        request.setAttribute("_ERROR_MESSAGE_", e.toString());
        return "error";
    }
    return "success";
}

From source file:org.apache.ofbiz.product.promo.PromoServices.java

public static Map<String, Object> createProductPromoCodeSet(DispatchContext dctx,
        Map<String, ? extends Object> context) {
    Locale locale = (Locale) context.get("locale");
    Delegator delegator = dctx.getDelegator();
    LocalDispatcher dispatcher = dctx.getDispatcher();
    Long quantity = (Long) context.get("quantity");
    int codeLength = (Integer) context.get("codeLength");
    String promoCodeLayout = (String) context.get("promoCodeLayout");

    // For PromoCodes we give the option not to use chars that are easy to mix up like 0<>O, 1<>I, ...
    boolean useSmartLayout = false;
    boolean useNormalLayout = false;
    if ("smart".equals(promoCodeLayout)) {
        useSmartLayout = true;//from   w  w  w  .j a  v  a  2s  . c  o m
    } else if ("normal".equals(promoCodeLayout)) {
        useNormalLayout = true;
    }

    String newPromoCodeId = "";
    StringBuilder bankOfNumbers = new StringBuilder();
    bankOfNumbers.append(UtilProperties.getMessage(resource, "ProductPromoCodesCreated", locale));
    for (long i = 0; i < quantity; i++) {
        Map<String, Object> createProductPromoCodeMap = null;
        boolean foundUniqueNewCode = false;
        long count = 0;

        while (!foundUniqueNewCode) {
            if (useSmartLayout) {
                newPromoCodeId = RandomStringUtils.random(codeLength, smartChars);
            } else if (useNormalLayout) {
                newPromoCodeId = RandomStringUtils.randomAlphanumeric(codeLength);
            }
            GenericValue existingPromoCode = null;
            try {
                existingPromoCode = EntityQuery.use(delegator).from("ProductPromoCode")
                        .where("productPromoCodeId", newPromoCodeId).cache().queryOne();
            } catch (GenericEntityException e) {
                Debug.logWarning("Could not find ProductPromoCode for just generated ID: " + newPromoCodeId,
                        module);
            }
            if (existingPromoCode == null) {
                foundUniqueNewCode = true;
            }

            count++;
            if (count > 999999) {
                return ServiceUtil
                        .returnError("Unable to locate unique PromoCode! Length [" + codeLength + "]");
            }
        }
        try {
            Map<String, Object> newContext = dctx.makeValidContext("createProductPromoCode", "IN", context);
            newContext.put("productPromoCodeId", newPromoCodeId);
            createProductPromoCodeMap = dispatcher.runSync("createProductPromoCode", newContext);
        } catch (GenericServiceException err) {
            return ServiceUtil.returnError(
                    UtilProperties.getMessage(resource, "ProductPromoCodeCannotBeCreated", locale), null, null,
                    createProductPromoCodeMap);
        }
        if (ServiceUtil.isError(createProductPromoCodeMap)) {
            // what to do here? try again?
            return ServiceUtil.returnError(
                    UtilProperties.getMessage(resource, "ProductPromoCodeCannotBeCreated", locale), null, null,
                    createProductPromoCodeMap);
        }
        bankOfNumbers.append((String) createProductPromoCodeMap.get("productPromoCodeId"));
        bankOfNumbers.append(",");
    }

    return ServiceUtil.returnSuccess(bankOfNumbers.toString());
}

From source file:org.apache.ofbiz.securityext.login.LoginEvents.java

/**
 *  Email the password for the userLoginId specified in the request object.
 *
 * @param request The HTTPRequest object for the current request
 * @param response The HTTPResponse object for the current request
 * @return String specifying the exit status of this event
 *//*from  ww w . j  a va 2  s  .  c  om*/
public static String emailPassword(HttpServletRequest request, HttpServletResponse response) {
    String defaultScreenLocation = "component://securityext/widget/EmailSecurityScreens.xml#PasswordEmail";

    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    String productStoreId = ProductStoreWorker.getProductStoreId(request);

    String errMsg = null;

    boolean useEncryption = "true"
            .equals(EntityUtilProperties.getPropertyValue("security", "password.encrypt", delegator));

    String userLoginId = request.getParameter("USERNAME");

    if ((userLoginId != null) && ("true"
            .equals(EntityUtilProperties.getPropertyValue("security", "username.lowercase", delegator)))) {
        userLoginId = userLoginId.toLowerCase();
    }

    if (UtilValidate.isEmpty(userLoginId)) {
        // the password was incomplete
        errMsg = UtilProperties.getMessage(resource, "loginevents.username_was_empty_reenter",
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
        return "error";
    }

    GenericValue supposedUserLogin = null;
    String passwordToSend = null;
    String autoPassword = null;
    try {
        supposedUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId)
                .queryOne();
        if (supposedUserLogin == null) {
            // the Username was not found
            errMsg = UtilProperties.getMessage(resource, "loginevents.username_not_found_reenter",
                    UtilHttp.getLocale(request));
            request.setAttribute("_ERROR_MESSAGE_", errMsg);
            return "error";
        }
        if (useEncryption) {
            // password encrypted, can't send, generate new password and email to user
            passwordToSend = RandomStringUtils.randomAlphanumeric(
                    EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue());
            if ("true".equals(
                    EntityUtilProperties.getPropertyValue("security", "password.lowercase", delegator))) {
                passwordToSend = passwordToSend.toLowerCase();
            }
            autoPassword = RandomStringUtils.randomAlphanumeric(
                    EntityUtilProperties.getPropertyAsInteger("security", "password.length.min", 5).intValue());
            EntityCrypto entityCrypto = new EntityCrypto(delegator, null);
            try {
                passwordToSend = entityCrypto.encrypt(keyValue, EncryptMethod.TRUE, (Object) autoPassword);
            } catch (GeneralException e) {
                Debug.logWarning(e, "Problem in encryption", module);
            }
            supposedUserLogin.set("currentPassword",
                    HashCrypt.cryptUTF8(LoginServices.getHashType(), null, autoPassword));
            supposedUserLogin.set("passwordHint", "Auto-Generated Password");
            if ("true".equals(EntityUtilProperties.getPropertyValue("security",
                    "password.email_password.require_password_change", delegator))) {
                supposedUserLogin.set("requirePasswordChange", "Y");
            }
        } else {
            passwordToSend = supposedUserLogin.getString("currentPassword");
        }
        /* Its a Base64 string, it can contain + and this + will be converted to space after decoding the url.
           For example: passwordToSend "DGb1s2wgUQmwOBK9FK+fvQ==" will be converted to "DGb1s2wgUQmwOBK9FK fvQ=="
           So to fix it, done Url encoding of passwordToSend.
        */
        passwordToSend = URLEncoder.encode(passwordToSend, "UTF-8");
    } catch (GenericEntityException | UnsupportedEncodingException e) {
        Debug.logWarning(e, "", module);
        Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.toString());
        errMsg = UtilProperties.getMessage(resource, "loginevents.error_accessing_password", messageMap,
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
        return "error";
    }

    StringBuilder emails = new StringBuilder();
    GenericValue party = null;

    try {
        party = supposedUserLogin.getRelatedOne("Party", false);
    } catch (GenericEntityException e) {
        Debug.logWarning(e, "", module);
        party = null;
    }
    if (party != null) {
        Iterator<GenericValue> emailIter = UtilMisc
                .toIterator(ContactHelper.getContactMechByPurpose(party, "PRIMARY_EMAIL", false));
        while (emailIter != null && emailIter.hasNext()) {
            GenericValue email = emailIter.next();
            emails.append(emails.length() > 0 ? "," : "").append(email.getString("infoString"));
        }
    }

    if (UtilValidate.isEmpty(emails.toString())) {
        // the Username was not found
        errMsg = UtilProperties.getMessage(resource,
                "loginevents.no_primary_email_address_set_contact_customer_service",
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
        return "error";
    }

    // get the ProductStore email settings
    GenericValue productStoreEmail = null;
    try {
        productStoreEmail = EntityQuery.use(delegator).from("ProductStoreEmailSetting")
                .where("productStoreId", productStoreId, "emailType", "PRDS_PWD_RETRIEVE").queryOne();
    } catch (GenericEntityException e) {
        Debug.logError(e, "Problem getting ProductStoreEmailSetting", module);
    }

    String bodyScreenLocation = null;
    if (productStoreEmail != null) {
        bodyScreenLocation = productStoreEmail.getString("bodyScreenLocation");
    }
    if (UtilValidate.isEmpty(bodyScreenLocation)) {
        bodyScreenLocation = defaultScreenLocation;
    }

    // set the needed variables in new context
    Map<String, Object> bodyParameters = new HashMap<String, Object>();
    bodyParameters.put("useEncryption", Boolean.valueOf(useEncryption));
    bodyParameters.put("password", UtilFormatOut.checkNull(passwordToSend));
    bodyParameters.put("locale", UtilHttp.getLocale(request));
    bodyParameters.put("userLogin", supposedUserLogin);
    bodyParameters.put("productStoreId", productStoreId);

    Map<String, Object> serviceContext = new HashMap<String, Object>();
    serviceContext.put("bodyScreenUri", bodyScreenLocation);
    serviceContext.put("bodyParameters", bodyParameters);
    if (productStoreEmail != null) {
        serviceContext.put("subject", productStoreEmail.getString("subject"));
        serviceContext.put("sendFrom", productStoreEmail.get("fromAddress"));
        serviceContext.put("sendCc", productStoreEmail.get("ccAddress"));
        serviceContext.put("sendBcc", productStoreEmail.get("bccAddress"));
        serviceContext.put("contentType", productStoreEmail.get("contentType"));
    } else {
        GenericValue emailTemplateSetting = null;
        try {
            emailTemplateSetting = EntityQuery.use(delegator).from("EmailTemplateSetting")
                    .where("emailTemplateSettingId", "EMAIL_PASSWORD").cache().queryOne();
        } catch (GenericEntityException e) {
            Debug.logError(e, module);
        }
        if (emailTemplateSetting != null) {
            String subject = emailTemplateSetting.getString("subject");
            subject = FlexibleStringExpander.expandString(subject, UtilMisc.toMap("userLoginId", userLoginId));
            serviceContext.put("subject", subject);
            serviceContext.put("sendFrom", emailTemplateSetting.get("fromAddress"));
        } else {
            serviceContext.put("subject",
                    UtilProperties.getMessage(resource, "loginservices.password_reminder_subject",
                            UtilMisc.toMap("userLoginId", userLoginId), UtilHttp.getLocale(request)));
            serviceContext.put("sendFrom",
                    EntityUtilProperties.getPropertyValue("general", "defaultFromEmailAddress", delegator));
        }
    }
    serviceContext.put("sendTo", emails.toString());
    serviceContext.put("partyId", party.getString("partyId"));

    try {
        Map<String, Object> result = dispatcher.runSync("sendMailHiddenInLogFromScreen", serviceContext);

        if (ModelService.RESPOND_ERROR.equals(result.get(ModelService.RESPONSE_MESSAGE))) {
            Map<String, Object> messageMap = UtilMisc.toMap("errorMessage",
                    result.get(ModelService.ERROR_MESSAGE));
            errMsg = UtilProperties.getMessage(resource,
                    "loginevents.error_unable_email_password_contact_customer_service_errorwas", messageMap,
                    UtilHttp.getLocale(request));
            request.setAttribute("_ERROR_MESSAGE_", errMsg);
            return "error";
        }
    } catch (GenericServiceException e) {
        Debug.logWarning(e, "", module);
        errMsg = UtilProperties.getMessage(resource,
                "loginevents.error_unable_email_password_contact_customer_service",
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
        return "error";
    }

    // don't save password until after it has been sent
    if (useEncryption) {
        try {
            supposedUserLogin.store();
        } catch (GenericEntityException e) {
            Debug.logWarning(e, "", module);
            Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.toString());
            errMsg = UtilProperties.getMessage(resource,
                    "loginevents.error_saving_new_password_email_not_correct_password", messageMap,
                    UtilHttp.getLocale(request));
            request.setAttribute("_ERROR_MESSAGE_", errMsg);
            return "error";
        }
    }

    if (useEncryption) {
        errMsg = UtilProperties.getMessage(resource, "loginevents.new_password_createdandsent_check_email",
                UtilHttp.getLocale(request));
        request.setAttribute("_EVENT_MESSAGE_", errMsg);
    } else {
        errMsg = UtilProperties.getMessage(resource, "loginevents.new_password_sent_check_email",
                UtilHttp.getLocale(request));
        request.setAttribute("_EVENT_MESSAGE_", errMsg);
    }
    return "success";
}

From source file:org.apache.ofbiz.testtools.ModelTestSuite.java

public ModelTestSuite(Element mainElement, String testCase) {
    this.suiteName = mainElement.getAttribute("suite-name");

    this.originalDelegatorName = mainElement.getAttribute("delegator-name");
    if (UtilValidate.isEmpty(this.originalDelegatorName))
        this.originalDelegatorName = "test";

    this.originalDispatcherName = mainElement.getAttribute("dispatcher-name");
    if (UtilValidate.isEmpty(this.originalDispatcherName))
        this.originalDispatcherName = "test-dispatcher";

    String uniqueSuffix = "-" + RandomStringUtils.randomAlphanumeric(10);

    this.delegator = DelegatorFactory.getDelegator(this.originalDelegatorName)
            .makeTestDelegator(this.originalDelegatorName + uniqueSuffix);
    this.dispatcher = ServiceContainer.getLocalDispatcher(originalDispatcherName + uniqueSuffix, delegator);

    for (Element testCaseElement : UtilXml.childElementList(mainElement,
            UtilMisc.toSet("test-case", "test-group"))) {
        String caseName = testCaseElement.getAttribute("case-name");
        String nodeName = testCaseElement.getNodeName();
        if (testCase == null || caseName.equals(testCase)) {
            if (nodeName.equals("test-case")) {
                parseTestElement(caseName, UtilXml.firstChildElement(testCaseElement));
            } else if (nodeName.equals("test-group")) {
                int i = 0;
                for (Element childElement : UtilXml.childElementList(testCaseElement)) {
                    parseTestElement(caseName + '-' + i, childElement);
                    i++;//from  ww w  . j  a v  a 2 s  .  co m
                }
            }
        }
    }
}

From source file:org.apache.oozie.command.wf.TestSubmitXCommand.java

private String generate64kData() {
    return "<property><name>radnom</name><value>" + RandomStringUtils.randomAlphanumeric(70000)
            + "</value></property>";
}

From source file:org.apache.oozie.workflow.lite.TestLiteWorkflowLib.java

public void testJobPersistanceMoreThan64K() throws WorkflowException {
    LiteWorkflowApp def = new LiteWorkflowApp("wf", "<worklfow-app/>",
            new StartNodeDef(TestControlNodeHandler.class, "one")).addNode(
                    new NodeDef("one", null, AsynchNodeHandler.class, Arrays.asList(new String[] { "end" })))
                    .addNode(new EndNodeDef("end", TestControlNodeHandler.class));

    LiteWorkflowInstance job = new LiteWorkflowInstance(def, new XConfiguration(), "1");
    // 100k//from  w ww .  j av a 2  s  .  c  o m
    String value = RandomStringUtils.randomAlphanumeric(100 * 1024);
    job.setVar("a", value);
    assertEquals(WorkflowInstance.Status.PREP, job.getStatus());
    assertEquals(value, job.getVar("a"));

    byte[] array = WritableUtils.toByteArray(job);
    job = WritableUtils.fromByteArray(array, LiteWorkflowInstance.class);
    assertEquals(WorkflowInstance.Status.PREP, job.getStatus());
    assertEquals(value, job.getVar("a"));
}