Tabnine Logo
Assert
Code IndexAdd Tabnine 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)

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 get() {
  StudentEntity entity = studentDao.get(StudentEntity.class, "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 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

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 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> 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 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 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

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • BoxLayout (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now