Example usage for org.springframework.util Assert notEmpty

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

Introduction

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

Prototype

@Deprecated
public static void notEmpty(@Nullable Map<?, ?> map) 

Source Link

Document

Assert that a Map contains entries; that is, it must not be null and must contain at least one entry.

Usage

From source file:org.oncoblocks.centromere.jpa.test.JpaRepositoryTests.java

@Test
public void findByOutsideTest() throws Exception {
    List<QueryCriteria> criterias = new ArrayList<>();
    criterias/*from  w  w  w  .  jav a 2s  .  c  o  m*/
            .add(new QueryCriteria("entrezGeneId", new ArrayList<>(Arrays.asList(2L, 4L)), Evaluation.OUTSIDE));
    List<EntrezGene> genes = (List<EntrezGene>) geneRepository.find(criterias);
    Assert.notNull(genes);
    Assert.notEmpty(genes);
    Assert.isTrue(genes.size() == 2);
    Assert.isTrue(genes.get(1).getEntrezGeneId().equals(5L));
}

From source file:org.oncoblocks.centromere.jpa.test.JpaRepositoryTests.java

@Test
public void findByTypeAndOutsideTest() throws Exception {

    List<QueryCriteria> criterias = new ArrayList<>();
    criterias.add(new QueryCriteria("geneType", "protein-coding"));
    criterias/*from   www  . j av  a 2  s .c  o m*/
            .add(new QueryCriteria("entrezGeneId", new ArrayList<>(Arrays.asList(2L, 3L)), Evaluation.OUTSIDE));
    List<EntrezGene> genes = (List<EntrezGene>) geneRepository.find(criterias);

    Assert.notNull(genes);
    Assert.notEmpty(genes);
    Assert.isTrue(genes.size() == 2);
    Assert.isTrue(genes.get(1).getEntrezGeneId().equals(4L));
}

From source file:org.oncoblocks.centromere.jpa.test.JpaRepositoryTests.java

@Test
public void findByLikeTest() throws Exception {
    List<QueryCriteria> criterias = new ArrayList<>();
    criterias.add(new QueryCriteria("primaryGeneSymbol", "eC", Evaluation.LIKE));
    List<EntrezGene> genes = (List<EntrezGene>) geneRepository.find(criterias);
    Assert.notNull(genes);//ww  w .  jav  a  2 s  . c o  m
    Assert.notEmpty(genes);
    Assert.isTrue(genes.size() == 1);
    EntrezGene gene = genes.get(0);
    Assert.isTrue("GeneC".equals(gene.getPrimaryGeneSymbol()));
}

From source file:org.oncoblocks.centromere.jpa.test.JpaRepositoryTests.java

@Test
public void findByStartsWithTest() throws Exception {
    List<QueryCriteria> criterias = new ArrayList<>();
    criterias.add(new QueryCriteria("geneType", "protein", Evaluation.STARTS_WITH));
    List<EntrezGene> genes = (List<EntrezGene>) geneRepository.find(criterias);
    Assert.notNull(genes);/*from   ww  w.j a  v  a  2  s  .c  o  m*/
    Assert.notEmpty(genes);
    Assert.isTrue(genes.size() == 3);
    EntrezGene gene = genes.get(0);
    Assert.isTrue("GeneA".equals(gene.getPrimaryGeneSymbol()));
}

From source file:org.oncoblocks.centromere.jpa.test.JpaRepositoryTests.java

@Test
public void findByEndsWithTest() throws Exception {
    List<QueryCriteria> criterias = new ArrayList<>();
    criterias.add(new QueryCriteria("primaryGeneSymbol", "neD", Evaluation.ENDS_WITH));
    List<EntrezGene> genes = (List<EntrezGene>) geneRepository.find(criterias);
    Assert.notNull(genes);/*from   w  ww  .  j  av  a  2s  . c o  m*/
    Assert.notEmpty(genes);
    Assert.isTrue(genes.size() == 1);
    EntrezGene gene = genes.get(0);
    Assert.isTrue("GeneD".equals(gene.getPrimaryGeneSymbol()));
}

From source file:net.groupbuy.service.impl.OrderServiceImpl.java

public void shipping(Order order, Shipping shipping, Admin operator) {
    Assert.notNull(order);/*from  w ww  .j av a 2s  .c  om*/
    Assert.notNull(shipping);
    Assert.notEmpty(shipping.getShippingItems());

    orderDao.lock(order, LockModeType.PESSIMISTIC_WRITE);

    Setting setting = SettingUtils.get();
    if (!order.getIsAllocatedStock() && setting.getStockAllocationTime() == StockAllocationTime.ship) {
        for (OrderItem orderItem : order.getOrderItems()) {
            if (orderItem != null) {
                Product product = orderItem.getProduct();
                productDao.lock(product, LockModeType.PESSIMISTIC_WRITE);
                if (product != null && product.getStock() != null) {
                    product.setAllocatedStock(product.getAllocatedStock()
                            + (orderItem.getQuantity() - orderItem.getShippedQuantity()));
                    productDao.merge(product);
                    orderDao.flush();
                    staticService.build(product);
                }
            }
        }
        order.setIsAllocatedStock(true);
    }

    shipping.setOrder(order);
    shippingDao.persist(shipping);
    for (ShippingItem shippingItem : shipping.getShippingItems()) {
        OrderItem orderItem = order.getOrderItem(shippingItem.getSn());
        if (orderItem != null) {
            Product product = orderItem.getProduct();
            productDao.lock(product, LockModeType.PESSIMISTIC_WRITE);
            if (product != null) {
                if (product.getStock() != null) {
                    product.setStock(product.getStock() - shippingItem.getQuantity());
                    if (order.getIsAllocatedStock()) {
                        product.setAllocatedStock(product.getAllocatedStock() - shippingItem.getQuantity());
                    }
                }
                productDao.merge(product);
                orderDao.flush();
                staticService.build(product);
            }
            orderItemDao.lock(orderItem, LockModeType.PESSIMISTIC_WRITE);
            orderItem.setShippedQuantity(orderItem.getShippedQuantity() + shippingItem.getQuantity());
        }
    }
    if (order.getShippedQuantity() >= order.getQuantity()) {
        order.setShippingStatus(ShippingStatus.shipped);
        order.setIsAllocatedStock(false);
    } else if (order.getShippedQuantity() > 0) {
        order.setShippingStatus(ShippingStatus.partialShipment);
    }
    order.setExpire(null);
    orderDao.merge(order);

    OrderLog orderLog = new OrderLog();
    orderLog.setType(Type.shipping);
    orderLog.setOperator(operator != null ? operator.getUsername() : null);
    orderLog.setOrder(order);
    orderLogDao.persist(orderLog);
}

From source file:net.groupbuy.service.impl.OrderServiceImpl.java

public void returns(Order order, Returns returns, Admin operator) {
    Assert.notNull(order);//  w  w w  . j av  a 2  s . co  m
    Assert.notNull(returns);
    Assert.notEmpty(returns.getReturnsItems());

    orderDao.lock(order, LockModeType.PESSIMISTIC_WRITE);

    returns.setOrder(order);
    returnsDao.persist(returns);
    for (ReturnsItem returnsItem : returns.getReturnsItems()) {
        OrderItem orderItem = order.getOrderItem(returnsItem.getSn());
        if (orderItem != null) {
            orderItemDao.lock(orderItem, LockModeType.PESSIMISTIC_WRITE);
            orderItem.setReturnQuantity(orderItem.getReturnQuantity() + returnsItem.getQuantity());
        }
    }
    if (order.getReturnQuantity() >= order.getShippedQuantity()) {
        order.setShippingStatus(ShippingStatus.returned);
    } else if (order.getReturnQuantity() > 0) {
        order.setShippingStatus(ShippingStatus.partialReturns);
    }
    order.setExpire(null);
    orderDao.merge(order);

    OrderLog orderLog = new OrderLog();
    orderLog.setType(Type.returns);
    orderLog.setOperator(operator != null ? operator.getUsername() : null);
    orderLog.setOrder(order);
    orderLogDao.persist(orderLog);
}

From source file:com.ewcms.content.document.service.ArticleMainService.java

@Override
public void referArticleMain(Integer channelId, Long[] articleMainIds) {
    Assert.notNull(channelId);/*from   www.j a  v  a2 s  .  c  om*/
    Assert.notEmpty(articleMainIds);

    Channel channel = channelDAO.get(channelId);
    Channel parentChannel = channel.getParent();
    if (parentChannel.getType() == Channel.Type.LEADER) {
        for (Long articleMainId : articleMainIds) {
            ArticleMain articleMain = articleMainDAO.get(articleMainId);
            if (articleMain == null)
                continue;
            ArticleMain refArticleMain = new ArticleMain();
            refArticleMain.setArticle(articleMain.getArticle());
            refArticleMain.setChannelId(channelId);
            refArticleMain.setReference(true);
            refArticleMain.setSort(articleMain.getSort());
            refArticleMain.setTop(articleMain.getTop());

            articleMainDAO.persist(refArticleMain);
        }
    }
}

From source file:com.ewcms.content.document.service.ArticleMainService.java

@Override
public void removeArticleMain(Long[] articleMainIds) {
    Assert.notNull(articleMainIds);/*from w w w.  java2s  .  c  o  m*/
    Assert.notEmpty(articleMainIds);
    for (Long articleMainId : articleMainIds) {
        ArticleMain articleMain = articleMainDAO.get(articleMainId);
        Assert.notNull(articleMain);
        if (articleMain.getReference()) {
            articleMain.setArticle(null);
            articleMainDAO.merge(articleMain);
            articleMainDAO.remove(articleMain);
        }
    }
}

From source file:com.kingen.service.org.OrgService.java

@ServiceLogAnnotation(action = "?")
public void saveOrgUsers(String orgId, List<String> userIds, Boolean synToActiviti) throws Exception {
    if (orgId != null) {
        Assert.notEmpty(userIds);
        for (String userId : userIds) {
            SysUserOrgId userOrgId = new SysUserOrgId(userId, orgId);
            SysUserOrg u = new SysUserOrg(userOrgId);
            dao.saveme(u);/*from  ww  w . j  a v a2s . c  o  m*/

            if (synToActiviti) {
                identityService.createMembership(userId, orgId);
            }
        }
    }
}