Package org.opentides.bean

Examples of org.opentides.bean.SystemCodes


*/
public class CrudUtilTest {
 
  @Test
  public void testBuildCreateMessage() {
    SystemCodes sc = new SystemCodes("category","key","value");
    String expected = "Added System Codes Value:value - Key=key and Category=category";
    Assert.assertEquals(expected,
        CrudUtil.buildCreateMessage(sc));
  }
View Full Code Here


        CrudUtil.buildCreateMessage(sc));
  }
  
  @Test
  public void testBuildUpdateMessage() {
    SystemCodes oldsc = new SystemCodes("categoryold","keyold","value");
    SystemCodes newsc = new SystemCodes("categorynew","keynew","value");
    SystemCodes samesc = new SystemCodes("categoryold","keyold","value");
   
    String expected = "Changed System Codes Value:value - Key from 'keyold' to 'keynew' and Category from 'categoryold' to 'categorynew'";
    Assert.assertEquals(expected,
        CrudUtil.buildUpdateMessage(oldsc, newsc));
    Assert.assertEquals("",
View Full Code Here

        CrudUtil.buildUpdateMessage(oldsc, samesc));
  }

  @Test
  public void testBuildUpdateArrayMessage() {
    SystemCodes oldsc = new SystemCodes("categoryold","keyold","valueold");
    SystemCodes newsc = new SystemCodes("categorynew","keynew","valuenew");
    SystemCodes samesc = new SystemCodes("categoryold","keysame","valuesame");
    List<SystemCodes> oldFaves = new ArrayList<SystemCodes>();
    oldFaves.add(samesc);
    oldFaves.add(oldsc);
    List<SystemCodes> newFaves = new ArrayList<SystemCodes>();
    newFaves.add(newsc);
View Full Code Here

        CrudUtil.buildUpdateMessage(oldUser, newUser));
  }

  @Test
  public void testBuildUpdateSystemCodesMessage() {
    SystemCodes oldsc = new SystemCodes("categoryold","keyold","old");
    SystemCodes newsc = new SystemCodes("categorynew","keynew","new");
    TestCodes oldtc = new TestCodes();
    oldtc.setStatus(oldsc);
    TestCodes newtc = new TestCodes();
    newtc.setStatus(newsc);
    TestCodes sametc = new TestCodes();
View Full Code Here

        CrudUtil.buildUpdateMessage(oldtc, sametc));
  }
 
  @Test
  public void testBuildUpdateToEmptyOrBlankMessage() {
    SystemCodes oldsc = new SystemCodes("categoryold","keyold","old");
    TestCodes oldtc = new TestCodes();
    oldtc.setStatus(oldsc);
    TestCodes newtc = new TestCodes();
    newtc.setStatus(null);
    TestCodes sametc = new TestCodes();
View Full Code Here

        CrudUtil.buildUpdateMessage(oldtc, sametc));
  }
 
  @Test
  public void testBuildUpdateArrayToEmptyMessage() {
    SystemCodes oldsc = new SystemCodes("categoryold","keyold","valueold");
    SystemCodes newsc = new SystemCodes("categorynew","keynew","valuenew");
    SystemCodes samesc = new SystemCodes("categoryold","keysame","valuesame");
    List<SystemCodes> oldFaves = new ArrayList<SystemCodes>();
    oldFaves.add(samesc);
    oldFaves.add(oldsc);
    List<SystemCodes> newFaves = new ArrayList<SystemCodes>();
    newFaves.add(newsc);
View Full Code Here

         Assert.assertNull(CrudUtil.getPropertyName(null));
    }
   
    @Test
    public void testBuildJpaQueryString() {
      SystemCodes sc = new SystemCodes();
      Assert.assertEquals("", CrudUtil.buildJpaQueryString(sc, true));
      sc.setValue("");
      Assert.assertEquals("", CrudUtil.buildJpaQueryString(sc, true));
     
      sc.setKey("PH");
    Assert.assertEquals(" where obj.key = 'PH'", CrudUtil
        .buildJpaQueryString(sc, true));
    Assert.assertEquals(" where obj.key like '%PH%'", CrudUtil
        .buildJpaQueryString(sc, false));
      sc.setValue("Philippines");
    Assert.assertEquals(
        " where obj.key = 'PH' and obj.value = 'Philippines'",
                   CrudUtil.buildJpaQueryString(sc, true));
    Assert.assertEquals(
            " where obj.key like '%PH%' and obj.value like '%Philippines%'",
View Full Code Here

//                   CrudUtil.buildJpaQueryString(sc, false));
    }
   
    @Test
    public void testBuildJpqQueryStringSpecialChars() {
      SystemCodes sc = new SystemCodes();
    // handle (%)
      sc.setValue("Phil%");
      sc.setKey("");
    Assert.assertEquals(
        " where obj.value = 'Phil%'",
                   CrudUtil.buildJpaQueryString(sc, true));
    Assert.assertEquals(
        " where obj.value like '%Phil\\%%'",
                   CrudUtil.buildJpaQueryString(sc, false));

    // handle '
      sc.setValue("Phil's");
      sc.setKey("");
    Assert.assertEquals(
        " where obj.value = 'Phil''s'",
                   CrudUtil.buildJpaQueryString(sc, true));
    Assert.assertEquals(
        " where obj.value like '%Phil''s%'",
                   CrudUtil.buildJpaQueryString(sc, false));

    // handle (\)
      sc.setValue("Phil's\\Jay");
      sc.setKey("");
    Assert.assertEquals(
        " where obj.value = 'Phil''s\\\\Jay'",
                   CrudUtil.buildJpaQueryString(sc, true));
    Assert.assertEquals(
        " where obj.value like '%Phil''s\\\\\\\\Jay%'",
                   CrudUtil.buildJpaQueryString(sc, false));
   
    // handle (_)
      sc.setValue("Phil_Jay");
      sc.setKey("");
    Assert.assertEquals(
        " where obj.value = 'Phil_Jay'",
                   CrudUtil.buildJpaQueryString(sc, true));
    Assert.assertEquals(
        " where obj.value like '%Phil\\_Jay%'",
View Full Code Here

   *
   * @see org.springframework.validation.Validator#validate(java.lang.Object,
   *      org.springframework.validation.Errors)
   */
  public void validate(Object clazz, Errors e) {
    SystemCodes systemCodes = (SystemCodes) clazz;
    if (systemCodes.getCategory().equals("0"))
      e.reject("error.required", new Object[]{"Category"}, "category");

    if(isDuplicateKey(systemCodes)){
      e.reject("error.duplicate-key", new Object[]{"\""+systemCodes.getKey()+"\"","key"}, "\""+systemCodes.getKey() +"\" already exists. Please try a different key.");
    }
   
    ValidationUtils.rejectIfEmpty(e, "category", "error.required",
        new Object[] { "Category" });
    ValidationUtils.rejectIfEmptyOrWhitespace(e, "key", "error.required",
View Full Code Here

   * @param fieldName name of field
   * @param templateId template id
   * @return boolean returns true if duplicate name was found, false otherwise
   */
  public boolean isDuplicateKey(SystemCodes systemCodes){
    SystemCodes key;
    try {
      key = this.systemCodesService.findByKey(systemCodes);
      if (key != null){
        if(!key.getId().equals(systemCodes.getId()))
          return true;
      }
     
    } catch (EntityNotFoundException e) {
      return false;
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.