Package org.opentides.bean

Examples of org.opentides.bean.SystemCodes


  public void testSaveEntityModelUpdateObject() {
    int count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='TK' and CATEGORY_='COUNTRY'");
    assertEquals(0, count);
    count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='PH' and CATEGORY_='COUNTRY'");
    assertEquals(1, count);
    SystemCodes sc1 = dao.loadEntityModel(9001l);
    sc1.setKey("TK");
    sc1.setCategory("COUNTRY");
    sc1.setValue("Thailand");
    dao.saveEntityModel(sc1);
    count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='TK' and CATEGORY_='COUNTRY'");
    assertEquals(1, count);
    count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='PH' and CATEGORY_='COUNTRY'");
    assertEquals(0, count);
    SystemCodes sc2 = dao.loadEntityModel(9001l);
    assertEquals(sc1, sc2);
  }
View Full Code Here


    count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='US'");
    assertEquals(0, count);   

    count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='PH'");
    assertEquals(1, count)
    SystemCodes sc1 = dao.loadEntityModel(9001l);
    dao.deleteEntityModel(sc1);
    count = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where KEY_='PH'");
    assertEquals(0, count)
  }
View Full Code Here

  }
 
  // TODO: Test ByExample with various datatypes (e.g. String, Long, Boolean, etc.)
  public void testCountByExampleString() {
    SystemCodes example = new SystemCodes();
    example.setDisableProtection(true);
    example.setCategory("OFFICE");
    long count = dao.countByExample(example);
    long target = jdbcTemplate.queryForInt("select count(*) from SYSTEM_CODES where CATEGORY_='OFFICE'");
    assertEquals(target, count);   
  }
View Full Code Here

  }
 
  // TODO: Test ByExample with various parameters (e.g. exact match or not)
  @SuppressWarnings("unchecked")
  public void testFindByExample() {
    SystemCodes example = new SystemCodes();
    example.setDisableProtection(true);
    example.setCategory("OFFICE");
    List<SystemCodes> codes = dao.findByExample(example);
    List<SystemCodes> targets = jdbcTemplate.query(
        "select * from SYSTEM_CODES where CATEGORY_='OFFICE'"
        new SystemCodesMapper());
    Assert.assertArrayEquals(targets.toArray(), codes.toArray());
View Full Code Here

    Assert.assertArrayEquals(targets.toArray(), codes.toArray());
  }
 
  @SuppressWarnings("unchecked")
  public void testFindByExampleSorting() {
    SystemCodes example = new SystemCodes();
    example.setDisableProtection(true);
    example.setOrderOption("key");
    example.setOrderFlow("desc");
    example.setCategory("COUNTRY");
    List<SystemCodes> codes = dao.findByExample(example);
    List<SystemCodes> targets = jdbcTemplate.query(
        "select * from SYSTEM_CODES where CATEGORY_='COUNTRY' order by KEY_ desc"
        new SystemCodesMapper());
    Assert.assertArrayEquals(targets.toArray(), codes.toArray());
View Full Code Here

    Assert.assertArrayEquals(targets.toArray(), codes.toArray());
  }
 
  @SuppressWarnings("unchecked")
  public void testFindByExamplePaging() {
    SystemCodes example = new SystemCodes();
    example.setDisableProtection(true);
    example.setCategory("COUNTRY");
    List<SystemCodes> codes = dao.findByExample(example,0,2);
    List<SystemCodes> targets = this.jdbcTemplate.query(
          "select * from SYSTEM_CODES where CATEGORY_='COUNTRY' limit 0,2",
          new SystemCodesMapper());
    Assert.assertArrayEquals(targets.toArray(), codes.toArray());
View Full Code Here

  }
 
  public void testfindSingleResultByNamedQuery() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("keyName", "CN");
    SystemCodes object = dao.findSingleResultByNamedQuery("jpql.systemcodes.findByKey", params);
    List<SystemCodes> target = this.jdbcTemplate.query("select * from SYSTEM_CODES where key_='CN'", new SystemCodesMapper());
    assertEquals(target.get(0), object);   
  }
View Full Code Here

    datasetName = "test/xml/SystemCodesDAOTest.xml";
  }

  private static final class SystemCodesMapper implements RowMapper {
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
          SystemCodes sc = new SystemCodes();
          sc.setCategory(rs.getString("category_"));
          sc.setKey(rs.getString("key_"));
          sc.setValue(rs.getString("value_"));
          return sc;
      }
View Full Code Here

  }
 
  @Override
  public String getAsText() {
    if (getValue() != null) {
      SystemCodes editor = (SystemCodes) getValue();
      return editor.getId().toString();
    }
    return "";
  }
View Full Code Here

  }

  @Override
  public void setAsText(String text) throws IllegalArgumentException {
    if (!StringUtil.isEmpty(text)) {
      SystemCodes systemCode = systemCodesService.load(text);
      setValue(systemCode);
    } else
      setValue(null);
  }
View Full Code Here

TOP

Related Classes of org.opentides.bean.SystemCodes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.