Example usage for org.springframework.util Assert isTrue

List of usage examples for org.springframework.util Assert isTrue

Introduction

In this page you can find the example usage for org.springframework.util Assert isTrue.

Prototype

public static void isTrue(boolean expression, Supplier<String> messageSupplier) 

Source Link

Document

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false .

Usage

From source file:com.wavemaker.commons.io.ResourcePath.java

public String toStringRelativeTo(ResourcePath source) {
    Assert.notNull(source, "Source must not be null");
    if (source.equals(this)) {
        return "";
    }/* ww w.ja  v a  2 s  .  c om*/
    String sourcePath = source.toString() + "/";
    Assert.isTrue(toString().startsWith(sourcePath),
            "Source '" + source + "' must be a parent of '" + this + "'");
    return toString().substring(sourcePath.length());
}

From source file:net.javacrumbs.springws.test.common.SchemaValidator.java

/**
 * Creates {@link XmlValidator} from schemas.
 * @param schemas//from   w  w  w. ja  v  a  2 s .c om
 * @param schemaLanguage
 * @return
 * @throws IOException
 */
public XmlValidator createValidatorFromSchemas(Resource[] schemas, String schemaLanguage) throws IOException {
    Assert.hasLength(schemaLanguage, "schemaLanguage is required");
    for (int i = 0; i < schemas.length; i++) {
        Assert.isTrue(schemas[i].exists(), "schema [" + schemas[i] + "] does not exist");
    }
    if (logger.isInfoEnabled()) {
        logger.info("Validating using \"" + StringUtils.arrayToCommaDelimitedString(schemas) + "\"");
    }
    return XmlValidatorFactory.createValidator(schemas, schemaLanguage);
}

From source file:org.broadleafcommerce.payment.service.gateway.PayPalExpressTransactionServiceImpl.java

@Override
public PaymentResponseDTO authorize(PaymentRequestDTO paymentRequestDTO) throws PaymentException {
    Assert.isTrue(paymentRequestDTO.getAdditionalFields().containsKey(MessageConstants.PAYERID),
            "The RequestDTO must contain a PAYERID");
    Assert.isTrue(paymentRequestDTO.getAdditionalFields().containsKey(MessageConstants.TOKEN),
            "The RequestDTO must contain a TOKEN");

    return commonAuthorizeOrSale(paymentRequestDTO, PayPalTransactionType.AUTHORIZE,
            (String) paymentRequestDTO.getAdditionalFields().get(MessageConstants.TOKEN),
            (String) paymentRequestDTO.getAdditionalFields().get(MessageConstants.PAYERID));
}

From source file:org.obiba.onyx.spring.identifier.RandomIncrementIdentifierSequenceProviderFactoryBean.java

public void validateArgs() throws IllegalArgumentException {
    Assert.isTrue(maxIncrement >= 1, "maxIncrement must be at least 1");
}

From source file:org.broadleafcommerce.payment.service.gateway.AuthorizeNetTransactionServiceImpl.java

@Override
public PaymentResponseDTO capture(PaymentRequestDTO paymentRequestDTO) throws PaymentException {
    Assert.isTrue(
            paymentRequestDTO.getAdditionalFields().containsKey(ResponseField.TRANSACTION_ID.getFieldName()),
            "Must pass 'x_trans_id' value on the additionalFields of the Payment Request DTO");
    Assert.isTrue(paymentRequestDTO.getTransactionTotal() != null,
            "The Transaction Total must not be null on the Payment Request DTO");
    return common(paymentRequestDTO, TransactionType.PRIOR_AUTH_CAPTURE);
}

From source file:org.cleverbus.api.entity.Response.java

/**
 * Creates a new response./*www . jav  a  2 s .com*/
 *
 * @param request the corresponding request to this response; sometimes can happen that it's not possible to find
 *                 request and even so it's good to save response
 * @param response the response (response or failed reason must not be empty)
 * @param failedReason the failed reason (response or failed reason must not be empty)
 * @param msg the asynchronous message
 * @return response entity
 */
public static Response createResponse(@Nullable Request request, @Nullable String response,
        @Nullable String failedReason, @Nullable Message msg) {

    Assert.isTrue(StringUtils.isNotEmpty(response) || StringUtils.isNotEmpty(failedReason),
            "response or failedReason must not be empty");

    Date currDate = new Date();

    Response res = new Response();
    res.setRequest(request);
    res.setResTimestamp(currDate);
    res.setResponse(response);
    res.setFailedReason(failedReason);
    res.setMessage(msg);

    return res;
}

From source file:org.apache.cxf.fediz.service.idp.service.jpa.ApplicationDAOJPATest.java

@Test
public void testReadAllApplications() {
    List<Application> applications = applicationDAO.getApplications(0, 999, null);
    // Application could have been removed, Order not given as per JUnit design
    Assert.isTrue(1 < applications.size(), "Size doesn't match [" + applications.size() + "]");
}

From source file:org.cleverbus.core.common.asynch.confirm.ConfirmationServiceImpl.java

@Transactional
@Override/*from   w  w w  .j  a v a2 s  .  c om*/
public void confirmationComplete(ExternalCall extCall) {
    Assert.notNull(extCall, "the extCall must not be null");
    Assert.isTrue(ExternalCall.CONFIRM_OPERATION.equals(extCall.getOperationName()), "the extCall must be a "
            + ExternalCall.CONFIRM_OPERATION + ", but is " + extCall.getOperationName());
    Assert.isTrue(extCall.getState() == ExternalCallStateEnum.PROCESSING,
            "the confirmation must be in PROCESSING state, but state is " + extCall.getState());

    extCall.setState(ExternalCallStateEnum.OK);

    extCallDao.update(extCall);

    Log.debug("Confirmation call " + extCall.toHumanString() + " changed state to " + ExternalCallStateEnum.OK);
}

From source file:net.kamhon.ieagle.datagrid.DefaultDatagridModel.java

public int getTotalPages() {
    Assert.isTrue(pageSize > 0, "pageSize can't less or equals to 0");

    return (int) (totalRecords / pageSize);
}

From source file:com.crossover.trial.weather.metrics.impl.DropwizardMetricsService.java

@Override
public void markRequest(IATA iata, double radius) {
    Assert.isTrue(iata != null, "iata is required");

    Lock read = registryLock.readLock();
    read.lock();/*  w  w w  .j a  v a 2 s .c om*/
    try {
        registry.meter(iata.getCode()).mark();
        registry.histogram("radius").update(Double.valueOf(radius).intValue() / 10);
    } finally {
        read.unlock();
    }
}