Example usage for org.apache.commons.lang StringUtils right

List of usage examples for org.apache.commons.lang StringUtils right

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils right.

Prototype

public static String right(String str, int len) 

Source Link

Document

Gets the rightmost len characters of a String.

Usage

From source file:info.magnolia.module.workflow.jcr.JCRWorkItemAPI.java

/**
 * create the jcr node path for work Item by its id
 * @param eid//ww w  . jav  a  2  s.c om
 */
public String createPathFromId(FlowExpressionId eid) {
    String wlInstId = eid.getWorkflowInstanceId();
    // FIXME someone who knows the code better should have a look
    String groupString = StringUtils.right(StringUtils.substringBefore(wlInstId, "."), 3);
    int groupNumber = Integer.parseInt(groupString) % 100;
    StringBuffer buffer = new StringBuffer(eid.getWorkflowDefinitionName());
    buffer.append(WorkflowConstants.SLASH);
    buffer.append(eid.getWorkflowDefinitionRevision());
    buffer.append(WorkflowConstants.SLASH);
    buffer.append(groupNumber);
    buffer.append(WorkflowConstants.SLASH);
    buffer.append(eid.getWorkflowInstanceId());
    buffer.append(WorkflowConstants.SLASH);
    buffer.append(eid.getExpressionName());
    buffer.append(WorkflowConstants.SLASH);
    buffer.append(eid.getExpressionId());

    return convertPath(buffer.toString());
}

From source file:mitm.common.dlp.impl.RegExpPolicyChecker.java

private String getContent(PolicyCheckerContext context) {
    /*//from  ww w.  j  a  v  a 2s .com
     * Get part of the previous content to create some overlap
     */
    LocalContext localContext = getLocalContext(context);

    String previousContent = localContext.getPreviousContent();

    String newContent = context.getContent();

    if (newContent != null) {
        /*
         * Replace the previous content with a part of the new content but only if it 
         * was partial content 
         */
        localContext.setPreviousContent(StringUtils.right(newContent, overlapLength));

        if (context.isPartial() && StringUtils.isNotEmpty(previousContent)) {
            newContent = previousContent + newContent;
        }
    }

    return newContent;
}

From source file:com.evolveum.midpoint.repo.sql.util.RUtil.java

public static QName stringToQName(String text) {
    if (StringUtils.isEmpty(text)) {
        return null;
    }//from  ww w. j av a 2 s  .c  o  m

    int index = text.lastIndexOf(QNAME_DELIMITER);
    String namespace = StringUtils.left(text, index);
    String localPart = StringUtils.right(text, text.length() - index - 1);

    if (StringUtils.isEmpty(localPart)) {
        return null;
    }

    return new QName(namespace, localPart);
}

From source file:co.propack.sample.vendor.nullPaymentGateway.web.controller.NullPaymentGatewayProcessorController.java

@RequestMapping(value = "/null-checkout/process", method = RequestMethod.POST)
public @ResponseBody String processTransparentRedirectForm(HttpServletRequest request) {
    Map<String, String[]> paramMap = request.getParameterMap();

    String transactionAmount = "";
    String orderId = "";
    String billingFirstName = "";
    String billingLastName = "";
    String billingAddressLine1 = "";
    String billingAddressLine2 = "";
    String billingCity = "";
    String billingState = "";
    String billingZip = "";
    String billingCountry = "";
    String shippingFirstName = "";
    String shippingLastName = "";
    String shippingAddressLine1 = "";
    String shippingAddressLine2 = "";
    String shippingCity = "";
    String shippingState = "";
    String shippingZip = "";
    String shippingCountry = "";
    String creditCardName = "";
    String creditCardNumber = "";
    String creditCardExpDate = "";
    String creditCardCVV = "";
    String cardType = "UNKNOWN";

    String resultMessage = "";
    String resultSuccess = "";
    String gatewayTransactionId = UUID.randomUUID().toString();

    if (paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT) != null
            && paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT).length > 0) {
        transactionAmount = paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT)[0];
    }//from   w ww .j a v  a 2  s  .  c  o m

    if (paramMap.get(NullPaymentGatewayConstants.ORDER_ID) != null
            && paramMap.get(NullPaymentGatewayConstants.ORDER_ID).length > 0) {
        orderId = paramMap.get(NullPaymentGatewayConstants.ORDER_ID)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME).length > 0) {
        billingFirstName = paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME).length > 0) {
        billingLastName = paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1).length > 0) {
        billingAddressLine1 = paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2).length > 0) {
        billingAddressLine2 = paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_CITY) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_CITY).length > 0) {
        billingCity = paramMap.get(NullPaymentGatewayConstants.BILLING_CITY)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_STATE) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_STATE).length > 0) {
        billingState = paramMap.get(NullPaymentGatewayConstants.BILLING_STATE)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP).length > 0) {
        billingZip = paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY) != null
            && paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY).length > 0) {
        billingCountry = paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME).length > 0) {
        shippingFirstName = paramMap.get(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_LAST_NAME) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_LAST_NAME).length > 0) {
        shippingLastName = paramMap.get(NullPaymentGatewayConstants.SHIPPING_LAST_NAME)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1).length > 0) {
        shippingAddressLine1 = paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2).length > 0) {
        shippingAddressLine2 = paramMap.get(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_CITY) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_CITY).length > 0) {
        shippingCity = paramMap.get(NullPaymentGatewayConstants.SHIPPING_CITY)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_STATE) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_STATE).length > 0) {
        shippingState = paramMap.get(NullPaymentGatewayConstants.SHIPPING_STATE)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_ZIP) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_ZIP).length > 0) {
        shippingZip = paramMap.get(NullPaymentGatewayConstants.SHIPPING_ZIP)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.SHIPPING_COUNTRY) != null
            && paramMap.get(NullPaymentGatewayConstants.SHIPPING_COUNTRY).length > 0) {
        shippingCountry = paramMap.get(NullPaymentGatewayConstants.SHIPPING_COUNTRY)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME) != null
            && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME).length > 0) {
        creditCardName = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NUMBER) != null
            && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NUMBER).length > 0) {
        creditCardNumber = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NUMBER)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE) != null
            && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE).length > 0) {
        creditCardExpDate = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE)[0];
    }

    if (paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_CVV) != null
            && paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_CVV).length > 0) {
        creditCardCVV = paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_CVV)[0];
    }

    CreditCardValidator visaValidator = new CreditCardValidator(CreditCardValidator.VISA);
    CreditCardValidator amexValidator = new CreditCardValidator(CreditCardValidator.AMEX);
    CreditCardValidator mcValidator = new CreditCardValidator(CreditCardValidator.MASTERCARD);
    CreditCardValidator discoverValidator = new CreditCardValidator(CreditCardValidator.DISCOVER);

    if (StringUtils.isNotBlank(transactionAmount) && StringUtils.isNotBlank(creditCardNumber)
            && StringUtils.isNotBlank(creditCardExpDate)) {

        boolean validCard = false;
        if (visaValidator.isValid(creditCardNumber)) {
            validCard = true;
            cardType = "VISA";
        } else if (amexValidator.isValid(creditCardNumber)) {
            validCard = true;
            cardType = "AMEX";
        } else if (mcValidator.isValid(creditCardNumber)) {
            validCard = true;
            cardType = "MASTERCARD";
        } else if (discoverValidator.isValid(creditCardNumber)) {
            validCard = true;
            cardType = "DISCOVER";
        }

        boolean validDateFormat = false;
        boolean validDate = false;
        String[] parsedDate = creditCardExpDate.split("/");
        if (parsedDate.length == 2) {
            String expMonth = parsedDate[0];
            String expYear = parsedDate[1];
            try {
                DateTime expirationDate = new DateTime(Integer.parseInt("20" + expYear),
                        Integer.parseInt(expMonth), 1, 0, 0);
                expirationDate = expirationDate.dayOfMonth().withMaximumValue();
                validDate = expirationDate.isAfterNow();
                validDateFormat = true;
            } catch (Exception e) {
                //invalid date format
            }
        }

        if (!validDate || !validDateFormat) {
            transactionAmount = "0";
            resultMessage = "cart.payment.expiration.invalid";
            resultSuccess = "false";
        } else if (!validCard) {
            transactionAmount = "0";
            resultMessage = "cart.payment.card.invalid";
            resultSuccess = "false";
        } else {
            resultMessage = "Success!";
            resultSuccess = "true";
        }

    } else {
        transactionAmount = "0";
        resultMessage = "cart.payment.invalid";
        resultSuccess = "false";
    }

    StringBuffer response = new StringBuffer();
    response.append("<!DOCTYPE HTML>");
    response.append("<!--[if lt IE 7]> <html class=\"no-js lt-ie9 lt-ie8 lt-ie7\" lang=\"en\"> <![endif]-->");
    response.append("<!--[if IE 7]> <html class=\"no-js lt-ie9 lt-ie8\" lang=\"en\"> <![endif]-->");
    response.append("<!--[if IE 8]> <html class=\"no-js lt-ie9\" lang=\"en\"> <![endif]-->");
    response.append("<!--[if gt IE 8]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->");
    response.append("<body>");
    response.append("<form action=\"" + paymentGatewayConfiguration.getTransparentRedirectReturnUrl()
            + "\" method=\"POST\" id=\"NullPaymentGatewayRedirectForm\" name=\"NullPaymentGatewayRedirectForm\">");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.TRANSACTION_AMT
            + "\" value=\"" + transactionAmount + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.ORDER_ID + "\" value=\""
            + orderId + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.GATEWAY_TRANSACTION_ID
            + "\" value=\"" + gatewayTransactionId + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.RESULT_MESSAGE
            + "\" value=\"" + resultMessage + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.RESULT_SUCCESS
            + "\" value=\"" + resultSuccess + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_FIRST_NAME
            + "\" value=\"" + billingFirstName + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_LAST_NAME
            + "\" value=\"" + billingLastName + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1
            + "\" value=\"" + billingAddressLine1 + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2
            + "\" value=\"" + billingAddressLine2 + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_CITY + "\" value=\""
            + billingCity + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_STATE + "\" value=\""
            + billingState + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_ZIP + "\" value=\""
            + billingZip + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.BILLING_COUNTRY
            + "\" value=\"" + billingCountry + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_FIRST_NAME
            + "\" value=\"" + shippingFirstName + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_LAST_NAME
            + "\" value=\"" + shippingLastName + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1
            + "\" value=\"" + shippingAddressLine1 + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2
            + "\" value=\"" + shippingAddressLine2 + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_CITY + "\" value=\""
            + shippingCity + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_STATE
            + "\" value=\"" + shippingState + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_ZIP + "\" value=\""
            + shippingZip + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.SHIPPING_COUNTRY
            + "\" value=\"" + shippingCountry + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_NAME
            + "\" value=\"" + creditCardName + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_LAST_FOUR
            + "\" value=\"" + StringUtils.right(creditCardNumber, 4) + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_TYPE
            + "\" value=\"" + cardType + "\"/>");
    response.append("<input type=\"hidden\" name=\"" + NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE
            + "\" value=\"" + creditCardExpDate + "\"/>");

    response.append("<input type=\"submit\" value=\"Please Click Here To Complete Checkout\"/>");
    response.append("</form>");
    response.append("<script type=\"text/javascript\">");
    response.append("document.getElementById('NullPaymentGatewayRedirectForm').submit();");
    response.append("</script>");
    response.append("</body>");
    response.append("</html>");

    return response.toString();
}

From source file:module.siadap.domain.SiadapYearConfiguration.java

public String getLabel() {
    if (getBiannual() == null || getBiannual() == false) {
        return String.valueOf(getYear());
    } else {/*from  w ww.j  av a 2  s.co  m*/
        String shortVersionOfSecondYear = StringUtils.right(String.valueOf(getYear() + 1), 2);
        return String.valueOf(getYear()) + "-" + shortVersionOfSecondYear;
    }

}

From source file:org.apache.cocoon.util.log.ExtensiblePatternFormatter.java

/**
 * Utility to append a string to buffer given certain constraints.
 *
 * @param sb the StringBuffer//from ww w .  j  a  v a  2s.com
 * @param minSize the minimum size of output (0 to ignore)
 * @param maxSize the maximum size of output (0 to ignore)
 * @param rightJustify true if the string is to be right justified in it's box.
 * @param output the input string
 */
protected void append(final StringBuffer sb, final int minSize, final int maxSize, final boolean rightJustify,
        final String output) {
    if (output.length() < minSize) {
        if (rightJustify) {
            sb.append(StringUtils.leftPad(output, minSize));
        } else {
            sb.append(StringUtils.rightPad(output, minSize));
        }
    } else if (maxSize > 0) {
        if (rightJustify) {
            sb.append(StringUtils.right(output, maxSize));
        } else {
            sb.append(StringUtils.left(output, maxSize));
        }
    } else {
        sb.append(output);
    }
}

From source file:org.broadleafcommerce.core.payment.service.module.NullCreditCardPaymentModule.java

/**
 * The following method:/* w  w  w  .j  a  va2 s  .co m*/
 * validates a credit card number against the Apache Commons CreditCardValidator.
 * validates the expiration date.
 * validates that the cvv != "000" in order to demonstrate a PaymentException
 *
 * This method will set the TransactionSuccess to false on the PaymentResponseItem
 * if any of the conditions above are invalid.
 *
 * This does NOT integrate with any Payment Gateway and should not be used in any production environment.
 * This class is for demonstration purposes only.
 *
 * @param paymentContext - the payment context injected from the workflow (see: blAuthorizeAndDebitWorkflow in bl-framework-applicationContext-workflow.xml)
 * @return PaymentResponseItem - the response item
 */
@Override
public PaymentResponseItem authorizeAndDebit(PaymentContext paymentContext) throws PaymentException {
    //Note that you cannot perform operations on paymentContext.getPaymentInfo() directly because that is a copy of the actual payment on the order.
    //In order to persist custom attributes to the credit card payment info on the order we must look it up first.
    PaymentInfo paymentInfo = null;
    for (PaymentInfo pi : paymentContext.getPaymentInfo().getOrder().getPaymentInfos()) {
        if (PaymentInfoType.CREDIT_CARD.equals(pi.getType())) {
            paymentInfo = pi;
        }
    }

    if (paymentInfo == null) {
        throw new PaymentException("PaymentInfo of type CREDIT_CARD must be on the order");
    }

    CreditCardPaymentInfo ccInfo = (CreditCardPaymentInfo) paymentContext.getReferencedPaymentInfo();
    String nameOnCard = ccInfo.getNameOnCard();
    String ccNumber = ccInfo.getPan().replaceAll("[\\s-]+", "");
    Integer expMonth = ccInfo.getExpirationMonth();
    Integer expYear = ccInfo.getExpirationYear();
    String cvv = ccInfo.getCvvCode();

    CreditCardValidator visaValidator = new CreditCardValidator(CreditCardValidator.VISA);
    CreditCardValidator amexValidator = new CreditCardValidator(CreditCardValidator.AMEX);
    CreditCardValidator mcValidator = new CreditCardValidator(CreditCardValidator.MASTERCARD);
    CreditCardValidator discoverValidator = new CreditCardValidator(CreditCardValidator.DISCOVER);

    boolean validCard = false;
    String cardType = "UNKNOWN";
    if (visaValidator.isValid(ccNumber)) {
        validCard = true;
        cardType = "VISA";
    } else if (amexValidator.isValid(ccNumber)) {
        validCard = true;
        cardType = "AMEX";
    } else if (mcValidator.isValid(ccNumber)) {
        validCard = true;
        cardType = "MASTERCARD";
    } else if (discoverValidator.isValid(ccNumber)) {
        validCard = true;
        cardType = "DISCOVER";
    }

    DateTime expirationDate = new DateTime(expYear, expMonth, 1, 0, 0);
    boolean validDate = expirationDate.isAfterNow();

    boolean validCVV = !cvv.equals("000");

    PaymentResponseItem responseItem = new PaymentResponseItemImpl();
    responseItem.setTransactionTimestamp(SystemTime.asDate());
    responseItem.setTransactionSuccess(validDate && validCard && validCVV);
    responseItem.setAmountPaid(paymentInfo.getAmount());
    responseItem.setCurrency(paymentInfo.getOrder().getCurrency());
    if (responseItem.getTransactionSuccess()) {
        Map<String, String> additionalFields = new HashMap<String, String>();
        additionalFields.put(PaymentInfoAdditionalFieldType.NAME_ON_CARD.getType(), nameOnCard);
        additionalFields.put(PaymentInfoAdditionalFieldType.CARD_TYPE.getType(), cardType);
        additionalFields.put(PaymentInfoAdditionalFieldType.EXP_MONTH.getType(), expMonth + "");
        additionalFields.put(PaymentInfoAdditionalFieldType.EXP_YEAR.getType(), expYear + "");
        additionalFields.put(PaymentInfoAdditionalFieldType.LAST_FOUR.getType(),
                StringUtils.right(ccNumber, 4));
        paymentInfo.setAdditionalFields(additionalFields);
    }

    return responseItem;
}

From source file:org.codice.ddf.configuration.migration.MigrationEntryImplTest.java

@Test
public void testCompareToWithGreaterName() throws Exception {
    Mockito.when(entry2.getName()).thenReturn(StringUtils.right(ENTRY_NAME, ENTRY_NAME.length() - 1));

    Assert.assertThat(entry.compareTo(entry2), Matchers.greaterThan(0));
}

From source file:org.codice.ddf.configuration.migration.MigrationEntryImplTest.java

@Test
public void testCompareToWithGreaterId() throws Exception {
    Mockito.when(context2.getId())/*from w ww . j  a v  a 2  s  .  c om*/
            .thenReturn('a' + StringUtils.right(MIGRATABLE_ID, MIGRATABLE_ID.length() - 1));

    Assert.assertThat(entry.compareTo(entry2), Matchers.greaterThan(0));
}

From source file:org.cubictest.common.utils.TextUtil.java

public static String normalizeWithPossibleSingleTrailingSpace(String s) {
    if (StringUtils.isBlank(s)) {
        return "";
    }//from   w  w  w .  j  a  v  a  2  s  .  co  m
    char originalLastChar = StringUtils.right(s, 1).toCharArray()[0];
    return normalizeAndTrim(s) + (Character.isWhitespace(originalLastChar) ? " " : "");
}