24 package org.lightjason.agentspeak.agent;
26 import org.junit.Assert;
27 import org.junit.Test;
34 import java.text.MessageFormat;
35 import java.util.Arrays;
36 import java.util.List;
38 import java.util.stream.Collectors;
39 import java.util.stream.Stream;
41 import static org.junit.Assert.assertEquals;
42 import static org.junit.Assert.assertNotEquals;
59 final Set<ILiteral> l_test = Stream.of(
62 ).collect( Collectors.toSet() );
68 ) ).collect( Collectors.toSet() ) );
70 final List<ITerm> l_result = l_literal.
values(
CPath.
from(
"first" ) ).collect( Collectors.toList() );
71 assertEquals( MessageFormat.format(
"literal traversing in {0} is wrong", l_literal ), l_result.size(), l_test.size() );
89 Arrays.stream( l_test ),
95 ).collect( Collectors.toList() ) );
97 Assert.assertArrayEquals(
98 MessageFormat.format(
"literal sequential traversing in {0} is wrong for", l_literal ),
112 final ILiteral l_first =
CLiteral.
parse(
"foo(sub(3),sub(X),test(1235),data(value('data string')))[ann(1),value('test')]" );
113 final ILiteral l_second =
CLiteral.
parse(
"foo(sub(3),sub(X),test(123),data(value('data string another value')))[ann(13),value('test2')]" );
116 MessageFormat.format(
"literal value hash of [{0}] and [{1}] is [{2} / {3}] inequal", l_first, l_second, l_first.
structurehash(),
126 MessageFormat.format(
"literal value hash of [{0}] and [{1}] are equal [{2}]", l_third, l_fourth, l_third.
structurehash() ),
127 l_third.structurehash(),
final void structurehash()
literal value hashing
base test class with helpers
Stream< ITerm > orderedvalues( @Nullable final IPath... p_path)
returns a stream over the ordered values in sequential ordering
static IPath from( @Nonnull final String p_string)
factor method to build path
class to create a path structure
final void literalvaluesequentialtraversing()
traversion of literal value content
Stream< ITerm > values(final IPath... p_path)
returns a stream over value items
final void literalvaluetraversing()
traversion of literal value content
int structurehash()
returns a hash value which defines a hash ove rthe structure
default generic literal class for agent beliefs a literal consists of a functor, an optional list of ...
static ILiteral parse( @Nonnull final String p_literal)
factory
static ILiteral from( @Nonnull final String p_functor, @Nullable final ITerm... p_values)
factory