24 package org.lightjason.agentspeak.action.builtin;
26 import org.junit.Assert;
27 import org.junit.Test;
38 import java.util.ArrayList;
39 import java.util.Collections;
40 import java.util.HashSet;
41 import java.util.List;
43 import java.util.stream.Collectors;
44 import java.util.stream.Stream;
59 final List<ITerm> l_return =
new ArrayList<>();
63 Stream.of( 1, 2 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
67 Assert.assertEquals( l_return.size(), 1 );
68 Assert.assertTrue( l_return.get( 0 ).raw() instanceof Set<?> );
69 Assert.assertArrayEquals( l_return.get( 0 ).<Set<?>>raw().toArray(), Stream.of( 1, 2 ).toArray() );
78 final List<ITerm> l_return =
new ArrayList<>();
82 Stream.of( 10, 20 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
86 Assert.assertEquals( l_return.size(), 1 );
87 Assert.assertEquals( l_return.get( 0 ).raw().getClass(), Collections.synchronizedSet( Collections.emptySet() ).getClass() );
88 Assert.assertArrayEquals( l_return.get( 0 ).<Set<?>>raw().toArray(), Stream.of( 20, 10 ).toArray() );
96 public final void add()
98 final Set<Object> l_set =
new HashSet<>();
102 Stream.of( l_set, 1, 5, 7 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
103 Collections.emptyList()
106 Assert.assertArrayEquals( l_set.toArray(), Stream.of( 1, 5, 7 ).toArray() );
115 final List<ITerm> l_return =
new ArrayList<>();
116 final Set<Object> l_set = Stream.of(
"foo", 1, 2 ).collect( Collectors.toSet() );
120 Stream.of( l_set,
"foo", 1,
"bar" ).map(
CRawTerm::from ).collect( Collectors.toList() ),
124 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of(
true,
true,
false ).toArray() );
131 public final void remove()
133 final List<ITerm> l_return =
new ArrayList<>();
134 final Set<Object> l_set = Stream.of(
"foo", 1, 2 ).collect( Collectors.toSet() );
138 Stream.of( l_set,
"foo", 1, 5 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
142 Assert.assertArrayEquals( l_return.stream().map(
ITerm::raw ).toArray(), Stream.of(
true,
true,
false ).toArray() );
143 Assert.assertArrayEquals( l_set.toArray(), Stream.of( 2 ).toArray() );
152 final List<ITerm> l_return =
new ArrayList<>();
153 final Set<Object> l_set = Stream.of(
"foobar",
"x",
"y" ).collect( Collectors.toSet() );
157 Stream.of( l_set ).map(
CRawTerm::from ).collect( Collectors.toList() ),
161 Assert.assertEquals( l_return.size(), 1 );
162 Assert.assertTrue( l_return.get( 0 ).raw() instanceof List<?> );
163 Assert.assertArrayEquals( l_return.get( 0 ).<List<?>>raw().toArray(), l_set.toArray() );
final void createsynchronized()
test create synchronized
removes any argument from the set and returns it.
base test class with helpers
IContext EMPTYPLAN
empty context with plan
final void contains()
test contains
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
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
converts a set to a list.
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 tolist()
test to-list
adds an element to the set.
< T > T raw()
cast to any raw value type
checks elements are containing in set.
final void create()
test create
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
removes an element of the list by the index.
action to add elements to a list.
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