List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:org.apache.cxf.fediz.service.idp.service.jpa.IdpDAOJPATest.java
@Test public void testReadAllIdps() { List<Idp> idps = idpDAO.getIdps(0, 999, null); // Idp could have been removed, Order not given as per JUnit design Assert.isTrue(0 < idps.size(), "Size doesn't match [" + idps.size() + "]"); }
From source file:de.extra.client.core.builder.impl.plugins.DataSourceSingleInputDataPluginsBuilder.java
/** * Erstellt die SenderInformationen im Kontext von Header (non-Javadoc) * //from w w w .ja v a2 s .co m * @see de.extra.client.core.builder.IXmlComplexTypeBuilder#buildXmlFragment(de.extra.client.core.model.SenderDataBean, * de.extra.client.core.model.ExtraProfileConfiguration) */ @Override public Object buildXmlFragment(final IInputDataContainer senderData, final IExtraProfileConfiguration config) { Assert.notNull(senderData, "InputDataContainer is null"); final List<ISingleInputData> content = senderData.getContent(); // Hier wird vorerst nur eine InputData erwartet Assert.notEmpty(content, "Keine InputDaten vorhanden"); Assert.isTrue(content.size() == 1, "InputDataContainer beinhaltet mehr als 1 Element. Erwartet ist nur 1 Element"); final ISingleInputData iSingleInputData = content.get(0); final DataSource dataSource = new DataSource(); if (ISingleContentInputData.class.isAssignableFrom(iSingleInputData.getClass())) { final ISingleContentInputData singleContentInputData = ISingleContentInputData.class .cast(iSingleInputData); final DataSourcePluginDescription dataSourcePluginDescriptor = getDataSourcePluginDescriptor( singleContentInputData); if (dataSourcePluginDescriptor != null) { final DataContainerType dataContainer = new DataContainerType(); dataContainer.setName(dataSourcePluginDescriptor.getName()); dataSourcePluginDescriptor.getType(); dataContainer.setType(dataSourcePluginDescriptor.getType().getDataContainerCode()); // 27.12.2012 Die Semantik des Feldes ist unklar. Ist das // Erstellungsdatum des Files? final GregorianCalendar calenderCreated = new GregorianCalendar(); calenderCreated.setTime(dataSourcePluginDescriptor.getCreated()); dataContainer.setCreated(calenderCreated); dataContainer.setEncoding(dataSourcePluginDescriptor.getEncoding()); dataSource.setDataContainer(dataContainer); } } LOG.debug("DataSourcePlugin created."); return dataSource; }
From source file:com.athena.peacock.common.core.util.XMLGregorialCalendarUtil.java
/** * <pre>/* w w w . j ava 2 s. co m*/ * YYYYMMDDHH24MISS? ?? ?? XMLGregorialCalendar ? GMT(GMT+09:00) ? . * </pre> * @param dateString * @return */ public static String convertFormattedStringToXmlGregorianCalendarStr(String dateString) { Assert.notNull(dateString, "dateString must not be null."); if (dateString.length() < 14) { dateString = StringUtils.rightPad(dateString, 14, '0'); } Assert.isTrue(dateString.length() == 14, "dateString's length must be 14."); GregorianCalendar cal = null; XMLGregorianCalendar calender = null; try { cal = convertTimezone(getDate(dateString), TimeZone.getTimeZone("ROK")); calender = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); return calender.toString(); } catch (Exception e) { throw new IllegalArgumentException( " . : [Date : " + dateString + " ]"); } }
From source file:co.propack.sample.payment.service.gateway.NullPaymentGatewayTransparentRedirectServiceImpl.java
protected PaymentResponseDTO createCommonTRFields(PaymentRequestDTO requestDTO) { Assert.isTrue(requestDTO.getTransactionTotal() != null, "The Transaction Total on the Payment Request DTO must not be null"); Assert.isTrue(requestDTO.getOrderId() != null, "The Order ID on the Payment Request DTO must not be null"); //Put The shipping, billing, and transaction amount fields as hidden fields on the form //In a real implementation, the gateway will probably provide some API to tokenize this information //which you can then put on your form as a secure token. For this sample, // we will just place them as plain-text hidden fields on the form PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.CREDIT_CARD, NullPaymentGatewayType.NULL_GATEWAY) .responseMap(NullPaymentGatewayConstants.ORDER_ID, requestDTO.getOrderId()) .responseMap(NullPaymentGatewayConstants.TRANSACTION_AMT, requestDTO.getTransactionTotal()) .responseMap(NullPaymentGatewayConstants.TRANSPARENT_REDIRECT_URL, configuration.getTransparentRedirectUrl()); AddressDTO billTo = requestDTO.getBillTo(); if (billTo != null) { responseDTO.responseMap(NullPaymentGatewayConstants.BILLING_FIRST_NAME, billTo.getAddressFirstName()) .responseMap(NullPaymentGatewayConstants.BILLING_LAST_NAME, billTo.getAddressLastName()) .responseMap(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1, billTo.getAddressLine1()) .responseMap(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2, billTo.getAddressLine2()) .responseMap(NullPaymentGatewayConstants.BILLING_CITY, billTo.getAddressCityLocality()) .responseMap(NullPaymentGatewayConstants.BILLING_STATE, billTo.getAddressStateRegion()) .responseMap(NullPaymentGatewayConstants.BILLING_ZIP, billTo.getAddressPostalCode()) .responseMap(NullPaymentGatewayConstants.BILLING_COUNTRY, billTo.getAddressCountryCode()); }//from w w w . ja v a 2 s . co m AddressDTO shipTo = requestDTO.getShipTo(); if (shipTo != null) { responseDTO.responseMap(NullPaymentGatewayConstants.SHIPPING_FIRST_NAME, shipTo.getAddressFirstName()) .responseMap(NullPaymentGatewayConstants.SHIPPING_LAST_NAME, shipTo.getAddressLastName()) .responseMap(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE1, shipTo.getAddressLine1()) .responseMap(NullPaymentGatewayConstants.SHIPPING_ADDRESS_LINE2, shipTo.getAddressLine2()) .responseMap(NullPaymentGatewayConstants.SHIPPING_CITY, shipTo.getAddressCityLocality()) .responseMap(NullPaymentGatewayConstants.SHIPPING_STATE, shipTo.getAddressStateRegion()) .responseMap(NullPaymentGatewayConstants.SHIPPING_ZIP, shipTo.getAddressPostalCode()) .responseMap(NullPaymentGatewayConstants.SHIPPING_COUNTRY, shipTo.getAddressCountryCode()); } return responseDTO; }
From source file:org.cloudbyexample.dc.web.service.docker.ProvisionController.java
@Override @RequestMapping(value = SAVE_REQUEST, method = RequestMethod.POST) public ProvisionResponse create(@RequestBody Provision request) { Assert.isTrue(!isPrimaryKeyValid(request), "Create should not have a valid primary key."); logger.info("Save provision. id={}", request.getId()); return service.create(request); }
From source file:io.lavagna.common.ConstructorAnnotationRowMapper.java
@SuppressWarnings("unchecked") public ConstructorAnnotationRowMapper(Class<T> clazz) { int constructorCount = clazz.getConstructors().length; Assert.isTrue(constructorCount == 1, "The class " + clazz.getName() + " must have exactly one public constructor, " + constructorCount + " are present"); con = (Constructor<T>) clazz.getConstructors()[0]; mappedColumn = from(clazz, con.getParameterAnnotations(), con.getParameterTypes()); }
From source file:cn.newtouch.util.orm.PropertyFilter.java
/** * @param filterName//from www . ja v a 2 s . co m * ,???. eg. LIKES_NAME_OR_LOGIN_NAME * @param value * . */ public PropertyFilter(final String filterName, final String value) { String firstPart = StringUtils.substringBefore(filterName, "_"); String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1); String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length()); try { this.matchType = Enum.valueOf(MatchType.class, matchTypeCode); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } try { this.propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue(); } catch (RuntimeException e) { throw new IllegalArgumentException( "filter??" + filterName + ",.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); Assert.isTrue(StringUtils.isNotBlank(propertyNameStr), "filter??" + filterName + ",??."); this.propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR); this.matchValue = ConvertUtils.convertStringToObject(value, this.propertyClass); }
From source file:com.crossover.trial.weather.domain.DataPointRepositoryImpl.java
@Override @Transactional(readOnly = true)/*from w w w. j av a 2s. com*/ public Measurement findLatestMeasurementForIata(IATA iata) { try { Assert.isTrue(iata != null, "iata is required"); return manager .createQuery("select m from Measurement m " + "where m.airport.iata = :iata " + "order by timestamp desc", Measurement.class) .setParameter("iata", iata).setMaxResults(1).getSingleResult(); } catch (EmptyResultDataAccessException e) { return null; } }
From source file:com.azaptree.services.http.handler.AsyncSuspendContinueHttpHandlerSupport.java
/** * /* w w w .ja v a 2 s . c o m*/ * @param executor * REQUIRED * @param continuationTimeoutMillis * must be > 0 */ public AsyncSuspendContinueHttpHandlerSupport(final Executor executor, final long continuationTimeoutMillis) { this(executor); Assert.isTrue(continuationTimeoutMillis > 0, "constraint: continuationTimeoutMillis > 0"); this.continuationTimeoutMillis = continuationTimeoutMillis; log.info(toString()); }
From source file:org.cleverbus.core.common.asynch.msg.MessageServiceImpl.java
@Transactional @Override/*from w w w. j a v a 2s .c om*/ public void setStateOk(Message msg, Map<String, Object> props) { Assert.notNull(msg, "the msg must not be null"); Assert.isTrue(!msg.isParentMessage(), "the message must not be parent"); msg.setState(MsgStateEnum.OK); msg.setLastUpdateTimestamp(new Date()); // move new business errors to message: MessageHelper.updateBusinessErrors(msg, props); messageDao.update(msg); Log.debug("State of the message " + msg.toHumanString() + " was changed to " + MsgStateEnum.OK); // check parent message with HARD binding - if any if (msg.existHardParent()) { List<Message> childMessages = messageDao.findChildMessages(msg); // are all child messages processed? boolean finishedOK = true; for (Message childMsg : childMessages) { //note: input message doesn't have to be in valid state in DB if Hibernate is used ... if (childMsg.getState() != MsgStateEnum.OK && !childMsg.equals(msg)) { finishedOK = false; break; } } if (finishedOK) { // mark parent message as successfully processed Message parentMsg = messageDao.getMessage(msg.getParentMsgId()); parentMsg.setState(MsgStateEnum.OK); parentMsg.setLastUpdateTimestamp(new Date()); // extract business errors from all child messages parentMsg.setBusinessError(getBusinessErrorsFromChildMessages(childMessages)); messageDao.update(parentMsg); Log.debug("State of the parent message " + parentMsg.toHumanString() + " was changed to " + MsgStateEnum.OK); } } }