Codota Logo
Assert
Code IndexAdd Codota to your IDE (free)

How to use
Assert
in
com.hbasesoft.framework.common.utils

Best Java code snippets using com.hbasesoft.framework.common.utils.Assert (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: ww20081120/framework

/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param entityClass
 * @param propertyName
 * @param value
 * @return
 * @throws DaoException <br>
 */
@SuppressWarnings("unchecked")
@Override
public <T> List<T> findByProperty(Class<T> entityClass, String propertyName, Object value) throws DaoException {
  Assert.notEmpty(propertyName, ErrorCodeDef.DAO_PROPERTY_IS_EMPTY);
  return (List<T>) createCriteria(entityClass, Restrictions.eq(propertyName, value)).list();
}
origin: ww20081120/framework

  public static void checkSql(String sql) {
    Assert.isTrue(sql.indexOf(GlobalConstants.ASTERISK) == -1, ErrorCodeDef.UNSUUPORT_ASTERISK);
  }
}
origin: ww20081120/framework

/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param class1
 * @param id
 * @return
 * @throws DaoException <br>
 */
@Override
public <T> T get(Class<T> entityClass, Serializable id) throws DaoException {
  Assert.notNull(id, ErrorCodeDef.ID_IS_NULL);
  return (T) getSession().get(entityClass, id);
}
origin: ww20081120/framework

@Test
public void updateBySqlString() {
  StudentEntity entity = studentDao.get(StudentEntity.class, "1");
  Assert.notEquals(entity.getName(), "李四", ErrorCodeDef.SYSTEM_ERROR_10001);
  studentDao.updateBySqlString("update t_student set name = '李四' where id = '1'");
  // 因为上面已经查询过一次,hibernate做了缓存,在事务未提交前,操作的都是缓存,所以得清理掉, 才能从数据库中重新查询。
  studentDao.clear();
  StudentEntity e2 = studentDao.get(StudentEntity.class, "1");
  Assert.equals(e2.getName(), "李四", ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

@Test
public void findUniqueByProperty() {
  CourseEntity entity = courseDao.findUniqueByProperty(CourseEntity.class, CourseEntity.COURSE_NAME, "语文");
  Assert.equals(entity.getId(), "1", ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

@Test
public void deleteEntityById() {
  StudentEntity entity = new StudentEntity();
  entity.setAge(16);
  entity.setName("张三丰");
  studentDao.save(entity);
  String id = entity.getId();
  studentDao.deleteEntityById(StudentEntity.class, id);
  entity = studentDao.get(StudentEntity.class, id);
  Assert.isNull(entity, ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

@Test
public void updateEntity() {
  StudentEntity entity = studentDao.get(StudentEntity.class, "1");
  Assert.notEquals(entity.getName(), "李四", ErrorCodeDef.SYSTEM_ERROR_10001);
  entity.setName("李四");
  studentDao.updateEntity(entity);
  StudentEntity e2 = studentDao.get(StudentEntity.class, "1");
  Assert.equals(e2.getName(), "李四", ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

@Test
public void singleResult() {
  StudentEntity entity = studentDao
    .singleResult("from com.hbasesoft.framework.db.demo.entity.StudentEntity where id = '1'");
  Assert.equals(entity.getName(), "张三", ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

@Test
public void delete() {
  StudentEntity entity = new StudentEntity();
  entity.setAge(16);
  entity.setName("张三丰");
  studentDao.save(entity);
  String id = entity.getId();
  studentDao.delete(entity);
  entity = studentDao.get(StudentEntity.class, id);
  Assert.isNull(entity, ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

private static Address[] getAddresses() {
  String address = PropertyHolder.getProperty(REDIS_ADDRESS);
  Assert.notEmpty(address, ErrorCodeDef.REDIS_ADDRESS_NOT_SET, REDIS_ADDRESS);
  return ProtocolUtil.parseAddress(address);
}
origin: ww20081120/framework

@Test
public void countCoursePass() {
  int count = studentDao.countCoursePass("语文");
  Assert.isTrue(count == 2, ErrorCodeDef.SYSTEM_ERROR_10001);
  System.out.println("语文考及格的有两人");
}
origin: ww20081120/framework

/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param entityName
 * @param id
 * @throws DaoException <br>
 */
@Override
public <T> void deleteEntityById(Class<T> entityName, Serializable id) throws DaoException {
  Assert.notNull(id, ErrorCodeDef.ID_IS_NULL);
  delete(get(entityName, id));
}
origin: ww20081120/framework

@Test
public void get() {
  StudentEntity entity = studentDao.get(StudentEntity.class, "1");
  Assert.equals(entity.getName(), "张三", ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

protected Address[] getAddresses() {
  String address = PropertyHolder.getProperty(REDIS_ADDRESS);
  Assert.notEmpty(address, ErrorCodeDef.REDIS_ADDRESS_NOT_SET, REDIS_ADDRESS);
  return ProtocolUtil.parseAddress(address);
}
origin: ww20081120/framework

@Test
public void findByQueryString() {
  List<StudentEntity> entities = studentDao
    .findByQueryString("from com.hbasesoft.framework.db.demo.entity.StudentEntity where id = '1'");
  Assert.isTrue(entities.size() == 1, ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

public static <T> T proxy(Class<T> clazz, CacheProxy cacheProxy) {
  if (Modifier.isAbstract(clazz.getModifiers())) {
    T target = null;
    if (StringUtils.isNotEmpty(cacheProxy.name())) {
      target = ContextHolder.getContext().getBean(cacheProxy.name(), clazz);
    }
    else {
      target = ContextHolder.getContext().getBean(clazz);
    }
    Assert.notNull(target, ErrorCodeDef.PROXY_TARGET_NOT_FOUND, clazz);
    CachePorxyInvocationHandler invocationHandler = new CachePorxyInvocationHandler(target, cacheProxy, clazz);
    @SuppressWarnings("unchecked")
    T proxyObj = (T) Proxy.newProxyInstance(clazz.getClassLoader(), clazz.isInterface() ? new Class[] {
      clazz
    } : clazz.getInterfaces(), invocationHandler);
    LoggerUtil.info("Success cache proxy clazz[{0}].", clazz);
    return proxyObj;
  }
  return null;
}
origin: ww20081120/framework

  @Test
  public void getCriteriaQuery() {
    DetachedCriteria criteria = DetachedCriteria.forClass(CourseEntity.class);
    criteria.add(Restrictions.eq(CourseEntity.COURSE_NAME, "语文"));
    CourseEntity e1 = courseDao.getCriteriaQuery(criteria);

    CourseEntity e2 = courseDao.findUniqueByProperty(CourseEntity.class, CourseEntity.COURSE_NAME, "语文");

    Assert.equals(e1.getId(), e2.getId(), ErrorCodeDef.SYSTEM_ERROR_10001);
  }
}
origin: ww20081120/framework

/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param entityClass
 * @param propertyName
 * @param value
 * @return
 * @throws DaoException <br>
 */
@SuppressWarnings("unchecked")
@Override
public <T> T findUniqueByProperty(Class<T> entityClass, String propertyName, Object value) throws DaoException {
  Assert.notEmpty(propertyName, ErrorCodeDef.DAO_PROPERTY_IS_EMPTY);
  return (T) createCriteria(entityClass, Restrictions.eq(propertyName, value)).uniqueResult();
}
origin: ww20081120/framework

@Test
public void findByProperty() {
  List<StudentEntity> entities = studentDao.findByProperty(StudentEntity.class, StudentEntity.AGE, 18);
  Assert.isTrue(entities.size() == 2, ErrorCodeDef.SYSTEM_ERROR_10001);
}
origin: ww20081120/framework

public static <T extends Serializable> int flowStart(T bean, String flowName, boolean throwable) {
  Assert.notNull(bean, ErrorCodeDef.NOT_NULL, "FlowBean");
  int result = ErrorCodeDef.SUCCESS;
  // match flow config
  FlowConfig config = match(flowName);
  Assert.notNull(config, ErrorCodeDef.FLOW_NOT_MATCH, bean);
  try {
    execute(bean, new FlowContext(config));
  }
  catch (Exception e) {
    LoggerUtil.error("flow process error.", e);
    FrameworkException fe = e instanceof FrameworkException ? (FrameworkException) e
      : new FrameworkException(e);
    if (throwable) {
      throw fe;
    }
    result = fe.getCode();
  }
  return result;
}
com.hbasesoft.framework.common.utilsAssert

Javadoc


Most used methods

  • notEmpty
    Description:
  • isTrue
  • notNull
    Description:
  • equals
  • isNull
    Description:
  • notEquals

Popular in Java

  • Running tasks concurrently on multiple threads
  • compareTo (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • addToBackStack (FragmentTransaction)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • String (java.lang)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now