jInfer

cz.cuni.mff.ksi.jinfer.base.utils
Class TestUtils

java.lang.Object
  extended by cz.cuni.mff.ksi.jinfer.base.utils.TestUtils

public final class TestUtils
extends Object

A few utilities to be used in JUnit tests.


Field Summary
static List<String> EMPTY_CONTEXT
          Empty context, can be used in Element construction.
static Map<String,Object> EMPTY_METADATA
          Empty metadata, can be used in Element construction.
 
Method Summary
static String elementToStr(Element e)
          Returns a simple textual representation of specified element, fit for using in unit tests.
static Attribute getAttribute(String name)
          Returns an attribute with provided name.
static Element getElement(String name)
          Returns an element with provided name.
static Element getElement(String name, Regexp<AbstractStructuralNode> subnodes)
          Returns an element with provided name and subnodes.
static Element getElementWithAttribute(String element, String attribute, String value)
          Returns an element with provided name, containing an attribute with provided name and content.
static SimpleData getSimpleData(String content)
          Returns a simple data with provided string as its only content.
static SimpleData getSimpleDataByName(String name)
          Returns a simple data with provided string as its name.
static Regexp<AbstractStructuralNode> getToken(AbstractStructuralNode n)
          Encapsulates the specified node into a mutable token regexp with interval "once".
static String regexpToStr(Regexp<AbstractStructuralNode> r)
          Returns a simple textual representation of specified regexp, fit for using in unit tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CONTEXT

public static final List<String> EMPTY_CONTEXT
Empty context, can be used in Element construction.


EMPTY_METADATA

public static final Map<String,Object> EMPTY_METADATA
Empty metadata, can be used in Element construction.

Method Detail

elementToStr

public static String elementToStr(Element e)
Returns a simple textual representation of specified element, fit for using in unit tests.


regexpToStr

public static String regexpToStr(Regexp<AbstractStructuralNode> r)
Returns a simple textual representation of specified regexp, fit for using in unit tests.


getElement

public static Element getElement(String name,
                                 Regexp<AbstractStructuralNode> subnodes)
Returns an element with provided name and subnodes. The element is otherwise empty: context and metadata are empty, there are no attributes. The element will be created as immutable.

Parameters:
name - Name for this element.
subnodes - Subnodes of this element.
Returns:
Constructed element.

getElement

public static Element getElement(String name)
Returns an element with provided name. The element is otherwise empty: context and metadata are empty, the subnodes are RegexpType.LAMBDA, there are no attributes. The element will be created as immutable.

Parameters:
name - Name for this element.
Returns:
Constructed element.

getElementWithAttribute

public static Element getElementWithAttribute(String element,
                                              String attribute,
                                              String value)
Returns an element with provided name, containing an attribute with provided name and content. The element is otherwise empty: context and metadata are empty, the subnodes are RegexpType.LAMBDA. The element will be created as immutable.

Parameters:
element - Name for this element.
attribute - Name of its only attribute.
value - The only value of the attribute.
Returns:
Constructed element.

getSimpleData

public static SimpleData getSimpleData(String content)
Returns a simple data with provided string as its only content. Simple data is otherwise quite empty: context and metadata are empty, content type is "string".

Parameters:
content - The only content string this simple data should have.
Returns:
Constructed simple data.

getSimpleDataByName

public static SimpleData getSimpleDataByName(String name)
Returns a simple data with provided string as its name. Simple data is otherwise quite empty: context, metadata and content are empty, content type is "string".

Parameters:
name - The name of simple data.
Returns:
Constructed simple data.

getAttribute

public static Attribute getAttribute(String name)
Returns an attribute with provided name. The attribute is otherwise empty: context, metadata and content are empty, content type is null.

Parameters:
name - Name for this attribute.
Returns:
Constructed attribute.

getToken

public static Regexp<AbstractStructuralNode> getToken(AbstractStructuralNode n)
Encapsulates the specified node into a mutable token regexp with interval "once".


jInfer

Generated on Fri Dec 9 00:01:25 CET 2011