Package org.yaac.shared.property

Source Code of org.yaac.shared.property.KeyInfoTest

package org.yaac.shared.property;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.yaac.server.util.AutoBeanUtil;
import org.yaac.shared.egql.ResultCell;
import org.yaac.shared.property.KeyInfo;

/**
* @author Max Zhu (thebbsky@gmail.com)
*
*/
public class KeyInfoTest {

  /**
   *
   */
  @Test
  public void testAsSingleNodeDescName() {
    KeyInfo key = new KeyInfo(null, "kkk", "name", null, "keyString");
    assertEquals("kkk(\"name\")", key.asSingleNodeDesc());
  }
 
  /**
   *
   */
  @Test
  public void testAsSingleNodeDescId() {
    KeyInfo key = new KeyInfo(null, "kkk", null, 20L, "keyString");
    assertEquals("kkk(20)", key.asSingleNodeDesc());
  }
 
  @Test
  public void testAsFullNodeDesc() {
    KeyInfo key1 = new KeyInfo(null, "kkk", null, 20L, "keyString");
    KeyInfo key2 = new KeyInfo(key1, "fff", null, 201L, "keyString");
   
    assertEquals("kkk(20)/fff(201)", key2.asFullPathDesc());
  }
 
  @Test
  public void testAsHtml() {
    KeyInfo key = new KeyInfo(null, "kkk", "name", null, "keyString");
   
    assertEquals("<a href='#editor:keyString'>kkk(\"name\")</a>", key.asHtml());
  }
 
  @Test
  public void testEncodeDecode() {
    KeyInfo key1 = new KeyInfo(null, "kkk", null, 20L, "keyString");
    KeyInfo key2 = new KeyInfo(key1, "fff", null, 201L, "keyString");
   
    ResultCell cell = key2.populateResultCell(AutoBeanUtil.getResultCellFactory());
   
    assertEquals(key2, PropertyInfo.Builder.fromResultCell(cell));
  }
 
  @Test
  public void testAsExp() {
    KeyInfo key1 = new KeyInfo(null, "kkk", "name", null, "keyString");
    KeyInfo key2 = new KeyInfo(key1, "fff", null, 201L, "keyString");
   
    assertEquals("key('kkk','name','fff',201)", key2.asExpression(null));
  }
}
TOP

Related Classes of org.yaac.shared.property.KeyInfoTest

TOP
Copyright © 2018 www.massapi.com. 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.