24 package org.lightjason.agentspeak.action.builtin;
26 import org.junit.Assert;
27 import org.junit.Test;
36 import java.util.AbstractMap;
37 import java.util.ArrayList;
38 import java.util.Collections;
39 import java.util.List;
40 import java.util.stream.Collectors;
41 import java.util.stream.Stream;
56 final List<ITerm> l_return =
new ArrayList<>();
60 Stream.of(
"abcd", 123,
"foobar",
true ).map(
CRawTerm::from ).collect( Collectors.toList() ),
64 Assert.assertEquals( l_return.size(), 2 );
66 Assert.assertEquals( l_return.get( 0 ).<AbstractMap.Entry<String, ?>>raw().getKey(),
"abcd" );
67 Assert.assertEquals( l_return.get( 0 ).<AbstractMap.Entry<?, Number>>raw().getValue(), 123 );
69 Assert.assertEquals( l_return.get( 1 ).<AbstractMap.Entry<String, ?>>raw().getKey(),
"foobar" );
70 Assert.assertTrue( l_return.get( 1 ).<AbstractMap.Entry<?, Boolean>>raw().getValue() );
82 Collections.emptyList(),
83 Collections.emptyList()
93 public final void set()
95 final AbstractMap.Entry<String, String> l_data =
new AbstractMap.SimpleEntry<>(
"foo",
"bar" );
99 Stream.of(
"blubblub", l_data ).map(
CRawTerm::from ).collect( Collectors.toList() ),
100 Collections.emptyList()
103 Assert.assertEquals( l_data.getValue(),
"blubblub" );
113 final List<ITerm> l_return =
new ArrayList<>();
117 Stream.of(
new AbstractMap.SimpleEntry<>(
"foo",
"bar" ),
new AbstractMap.SimpleEntry<>( 1, 2 ) ).map(
CRawTerm::from ).collect( Collectors.toList() ),
121 Assert.assertEquals( l_return.size(), 4 );
123 Assert.assertEquals( l_return.get( 0 ).raw(),
"foo" );
124 Assert.assertEquals( l_return.get( 1 ).raw(),
"bar" );
126 Assert.assertEquals( l_return.get( 2 ).<Number>raw(), 1 );
127 Assert.assertEquals( l_return.get( 3 ).<Number>raw(), 2 );
base test class with helpers
IContext EMPTYPLAN
empty context with plan
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
unflats any list structure.
final void flat()
test tuple flat
final void createerror()
test tuple creating error
execution context with local data
adds an element to the list.
creates a tuple of two elements.
sets a value within a tuple.
final void create()
test tuple creating
unflats the tuples into variables.
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
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
term structure for simple datatypes