@Test
  public void testNegativeLowerBound() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.addOrder(OrderFactoryUtil.asc("classNameId"));
    dynamicQuery.setLimit(-50, _allClassNames.size());

    Assert.assertEquals(
        _allClassNames, ClassNameLocalServiceUtil.<ClassName>dynamicQuery(dynamicQuery));
  }
  @Test
  public void testNoResults() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.setLimit(10, 10);

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

    Assert.assertTrue(dynamicQueryClassNames.isEmpty());
  }
  @Test
  public void testNegativeBoundaries() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.setLimit(-1985, -625);

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

    Assert.assertTrue(dynamicQueryClassNames.isEmpty());
  }
  @Test
  public void testStartHigherThanEnd() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.setLimit(1984, 309);

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

    Assert.assertTrue(dynamicQueryClassNames.isEmpty());
  }
  @Test
  public void testNegativeUpperBound() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.setLimit(QueryUtil.ALL_POS, -50);

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

    Assert.assertTrue(dynamicQueryClassNames.isEmpty());
  }
  @Test
  public void testUpperBound() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.addOrder(OrderFactoryUtil.asc("classNameId"));
    dynamicQuery.setLimit(QueryUtil.ALL_POS, 10);

    Assert.assertEquals(
        _allClassNames.subList(0, 10),
        ClassNameLocalServiceUtil.<ClassName>dynamicQuery(dynamicQuery));
  }
  @Test
  public void testSingleResult() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

    dynamicQuery.addOrder(OrderFactoryUtil.asc("classNameId"));
    dynamicQuery.setLimit(10, 11);

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

    Assert.assertEquals(1, dynamicQueryClassNames.size());
    Assert.assertEquals(_allClassNames.get(10), dynamicQueryClassNames.get(0));
  }
  @Test
  public void testNoLimit() {
    DynamicQuery dynamicQuery = ClassNameLocalServiceUtil.dynamicQuery();

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

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

    for (ClassName className : _allClassNames) {
      if (!classNames.contains(className)) {
        Assert.fail("Class names do not contain " + className);
      }
    }
  }
  @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));
  }
  @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));
  }
 @Before
 public void setUp() {
   _allClassNames = ClassNameLocalServiceUtil.getClassNames(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
 }
  protected void processStartupEvents() throws Exception {

    // Print release information

    Class<?> clazz = getClass();

    ClassLoader classLoader = clazz.getClassLoader();

    try (InputStream inputStream =
        classLoader.getResourceAsStream("com/liferay/portal/events/dependencies/startup.txt")) {

      System.out.println(_toString(inputStream));
    }

    System.out.println("Starting " + ReleaseInfo.getReleaseInfo() + "\n");

    if (_log.isDebugEnabled()) {
      _log.debug("Portal Resiliency - NOT SUPPORTED");
    }

    // Shutdown hook

    if (_log.isDebugEnabled()) {
      _log.debug("Add shutdown hook");
    }

    Runtime runtime = Runtime.getRuntime();

    runtime.addShutdownHook(new Thread(new ShutdownHook()));

    // MySQL version

    DB db = DBManagerUtil.getDB();

    if ((db.getDBType() == DBType.MYSQL) && GetterUtil.getFloat(db.getVersionString()) < 5.6F) {

      throw new ServletException(
          "Please upgrade to at least MySQL 5.6.4. The portal no "
              + "longer supports older versions of MySQL.");
    }

    // Check required build number

    if (_log.isDebugEnabled()) {
      _log.debug("Check required build number");
    }

    DBUpgrader.checkRequiredBuildNumber(ReleaseInfo.getParentBuildNumber());

    Registry registry = RegistryUtil.getRegistry();

    Map<String, Object> properties = new HashMap<>();

    properties.put("module.service.lifecycle", "database.initialized");
    properties.put("service.vendor", ReleaseInfo.getVendor());
    properties.put("service.version", ReleaseInfo.getVersion());

    _dbModuleServiceLifecycleServiceRegistration =
        registry.registerService(
            ModuleServiceLifecycle.class, new ModuleServiceLifecycle() {}, properties);

    // Check class names

    if (_log.isDebugEnabled()) {
      _log.debug("Check class names");
    }

    ClassNameLocalServiceUtil.checkClassNames();
  }