24 package org.lightjason.agentspeak.action.builtin;
    26 import org.junit.Assert;
    27 import org.junit.Test;
    45 import java.util.ArrayList;
    46 import java.util.Collections;
    47 import java.util.HashSet;
    48 import java.util.List;
    49 import java.util.stream.Collectors;
    50 import java.util.stream.Stream;
    65         final List<ITerm> l_return = 
new ArrayList<>();
    69             Stream.of( 
"functor", 
"stringvalue", 1234, 
true ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
    73         Assert.assertEquals( l_return.size(), 1 );
    92         final List<ITerm> l_return = 
new ArrayList<>();
    96             Stream.of( 
"main/parsefunctor( \"hello\", 666, false )" ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   100         Assert.assertEquals( l_return.size(), 1 );
   119         final List<ITerm> l_return = 
new ArrayList<>();
   124                 Stream.of( 
"Main/parsefunctor( hello, XXXXX, false )" ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   137         final List<ITerm> l_return = 
new ArrayList<>();
   141             Stream.of( 
"732.489", 
"64.091248", 
"-78129.01", 
"foo" ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   145         Assert.assertEquals( l_return.size(), 4 );
   146         Assert.assertEquals( l_return.get( 0 ).<Number>raw().doubleValue(), 732.489, 0 );
   147         Assert.assertEquals( l_return.get( 1 ).<Number>raw().doubleValue(), 64.091248, 0 );
   148         Assert.assertEquals( l_return.get( 2 ).<Number>raw().doubleValue(), -78129.01, 0 );
   149         Assert.assertNull( l_return.get( 3 ).raw() );
   159         final List<ITerm> l_return = 
new ArrayList<>();
   163             Stream.of( 
new ArrayList<>(), 123L, 
"test value", 
new HashSet<>() ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   167         Assert.assertEquals( l_return.size(), 4 );
   168         Assert.assertEquals( l_return.get( 0 ).<String>raw(), 
"java.util.ArrayList" );
   169         Assert.assertEquals( l_return.get( 1 ).<String>raw(), 
"java.lang.Long" );
   170         Assert.assertEquals( l_return.get( 2 ).<String>raw(), 
"java.lang.String" );
   171         Assert.assertEquals( l_return.get( 3 ).<String>raw(), 
"java.util.HashSet" );
   179     public final void is()
   184                 Stream.of( 
"java.lang.String", 
"text foo", 123, 88.98 ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   185                 Collections.emptyList()
   192                 Stream.of( 
"java.lang.Number", 123, 44.5 ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   193                 Collections.emptyList()
   208                 Stream.of( 
"test type string", null ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   209                 Collections.emptyList()
   216                 Stream.of( 
CRawTerm.
from( null ) ).collect( Collectors.toList() ),
   217                 Collections.emptyList()
   232                 Stream.of( 
"test type string", 123, 77L, 112.123, 44.5f ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   233                 Collections.emptyList()
   240                 Stream.of( 123, 77L, 112.123, 44.5f ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   241                 Collections.emptyList()
   256                 Stream.of( 
"test foobar", 123, 
"string again", 
true, 
new Object(), 77.8, 
'a' ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   257                 Collections.emptyList()
   265                 Stream.of( 
"okay 1", 
'c', 
"ok 2" ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   266                 Collections.emptyList()
   278         final List<ITerm> l_return = 
new ArrayList<>();
   282             Stream.of( 
"", 123, 5.5, 
new Object() ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   286         Assert.assertEquals( l_return.size(), 4 );
   287         Assert.assertTrue( l_return.get( 0 ).<String>raw().isEmpty() );
   288         Assert.assertEquals( l_return.get( 1 ).raw(), 
"123" );
   289         Assert.assertEquals( l_return.get( 2 ).raw(), 
"5.5" );
   290         Assert.assertTrue( l_return.get( 3 ).raw() instanceof String );
   300         final List<ITerm> l_return = 
new ArrayList<>();
   304             Stream.of( 1, 2, 3.2 ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   308         Assert.assertEquals( l_return.size(), 3 );
   309         Assert.assertTrue( l_return.get( 0 ).raw() instanceof Double );
   310         Assert.assertTrue( l_return.get( 1 ).raw() instanceof Double );
   311         Assert.assertTrue( l_return.get( 2 ).raw() instanceof Double );
   324                 Stream.of( 
"" ).map( 
CRawTerm::from ).collect( Collectors.toList() ),
   325                 Collections.emptyList()
 final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation 
 
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation 
 
final void tostring()
test "tostring" 
 
action for parsing a integer from string. 
 
final void parsefloat()
test parse-float action 
 
creates a literal by the input data. 
 
base test class with helpers 
 
final void type()
test type action 
 
test generic-type actions 
 
IContext EMPTYPLAN
empty context with plan 
 
final void tofloat()
test "tofloat" 
 
final void parseliteral()
test parse literal action 
 
final void tofloaterror()
test "tofloat" error 
 
action for parsing a number from string. 
 
converts a value into the string represenation. 
 
final void parseliteralerror()
test parse literal action with error 
 
execution context with local data 
 
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation 
 
action to cast a value to a number value. 
 
final void isstring()
test "isstring" action 
 
final void isnumeric()
test "isnumeric" action 
 
action to check if a type is a string. 
 
default generic literal class for agent beliefs a literal consists of a functor, an optional list of ...
 
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term 
 
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation 
 
final void is()
test "is" action 
 
action to check if a type is a number. 
 
static ILiteral from( @Nonnull final String p_functor, @Nullable final ITerm... p_values)
factory 
 
returns for each argument the underlying type. 
 
final void isnull()
test "isnull"action 
 
action to check if a value is a null value. 
 
action to check if a type is a class. 
 
final void createliteral()
test create literal action 
 
term structure for simple datatypes