Пример #1
0
  @Test
  public void testCriterion() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");

    ClassName className = _allClassNames.get(10);

    dynamicQuery.add(classNameIdProperty.eq(className.getClassNameId()));

    List<ClassName> classNames = ClassNameLocalServiceUtil.dynamicQuery(dynamicQuery);

    Assert.assertEquals(1, classNames.size());
    Assert.assertEquals(className, classNames.get(0));
  }
Пример #2
0
  @Test
  public void testOrderBy() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");

    ClassName lastClassName = _allClassNames.get(_allClassNames.size() - 1);

    dynamicQuery.add(classNameIdProperty.le(lastClassName.getClassNameId()));

    dynamicQuery.addOrder(OrderFactoryUtil.desc("classNameId"));

    _allClassNames = new ArrayList<>(_allClassNames);

    Collections.reverse(_allClassNames);

    Assert.assertEquals(
        _allClassNames, ClassNameLocalServiceUtil.<ClassName>dynamicQuery(dynamicQuery));
  }