24 package org.lightjason.agentspeak.action.builtin;
26 import org.junit.Assert;
27 import org.junit.Test;
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;
59 Stream.of(
"jsonlist",
"testjsonlist" )
61 .collect( Collectors.toList() ),
62 Collections.emptyList()
73 final List<ITerm> l_return =
new ArrayList<>();
77 Stream.of(
"https://api.github.com/repos/LightJason/Examples/commits",
"testjsonlist" )
79 .collect( Collectors.toList() ),
83 Assert.assertFalse( l_return.isEmpty() );
84 Assert.assertTrue( l_return.stream().map(
ITerm::raw ).allMatch( i -> i instanceof
ILiteral ) );
85 Assert.assertTrue( l_return.stream().map(
ITerm::<ILiteral>raw ).map(
ITerm::functor ).allMatch( i -> i.equals(
"testjsonlist" ) ) );
95 final List<ITerm> l_return =
new ArrayList<>();
99 Stream.of(
"https://api.github.com/repos/LightJason/Examples/commits",
"testjsonlist",
"item" )
101 .collect( Collectors.toList() ),
105 Assert.assertEquals( l_return.size(), 1 );
106 Assert.assertTrue( l_return.get( 0 ).raw() instanceof
ILiteral );
107 Assert.assertEquals( l_return.get( 0 ).<
ILiteral>raw().
functor(),
"testjsonlist" );
121 Stream.of(
"jsonobject",
"testjsonobject" )
123 .collect( Collectors.toList() ),
124 Collections.emptyList()
136 final List<ITerm> l_return =
new ArrayList<>();
140 Stream.of(
"https://maps.googleapis.com/maps/api/geocode/json?address=Frankfurt",
"testjsonobject" )
142 .collect( Collectors.toList() ),
146 Assert.assertEquals( l_return.size(), 1 );
147 Assert.assertTrue( l_return.get( 0 ).raw() instanceof
ILiteral );
148 Assert.assertEquals( l_return.get( 0 ).<
ILiteral>raw().
functor(),
"testjsonobject" );
158 final List<ITerm> l_return =
new ArrayList<>();
162 Stream.of(
"https://maps.googleapis.com/maps/api/geocode/json?address=Frankfurt",
"testjsonobject",
"loc" )
164 .collect( Collectors.toList() ),
168 Assert.assertEquals( l_return.size(), 1 );
169 Assert.assertTrue( l_return.get( 0 ).raw() instanceof
ILiteral );
170 Assert.assertEquals( l_return.get( 0 ).<
ILiteral>raw().
functor(),
"testjsonobject" );
171 Assert.assertTrue( l_return.get( 0 ).<
ILiteral>raw().
values().findFirst().isPresent() );
188 Stream.of(
"xmlobject",
"testxml" )
190 .collect( Collectors.toList() ),
191 Collections.emptyList()
203 final List<ITerm> l_return =
new ArrayList<>();
207 Stream.of(
"https://en.wikipedia.org/wiki/Special:Export/Normalized_compression_distance",
"testxml" )
209 .collect( Collectors.toList() ),
213 Assert.assertEquals( l_return.size(), 1 );
214 Assert.assertTrue( l_return.get( 0 ).raw() instanceof
ILiteral );
215 Assert.assertEquals( l_return.get( 0 ).<
ILiteral>raw().
functor(),
"testxml" );
225 final List<ITerm> l_return =
new ArrayList<>();
229 Stream.of(
"https://en.wikipedia.org/wiki/Special:Export/Normalized_compression_distance",
"testxml",
"ncd" )
231 .collect( Collectors.toList() ),
235 Assert.assertEquals( l_return.size(), 1 );
236 Assert.assertTrue( l_return.get( 0 ).raw() instanceof
ILiteral );
237 Assert.assertEquals( l_return.get( 0 ).<
ILiteral>raw().
functor(),
"testxml" );
238 Assert.assertTrue( l_return.get( 0 ).<
ILiteral>raw().
values().findFirst().isPresent() );
final void jsonobjectsingle()
test json object with single argument
final void jsonlistmultiple()
test json list with multiple argument
base test class with helpers
final void jsonobjecterror()
test json object error
action for calling a restful webservice with a JSON object list.
IContext EMPTYPLAN
empty context with plan
final void jsonlistsingle()
test json list with single argument
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 xmlobjecterror()
test xml object error
Stream< ITerm > values(final IPath... p_path)
returns a stream over value items
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 call a restful webservice with XML data.
execution context with local data
final void xmlobjectsingle()
test xml object with single argument
String functor()
returns the functor without path
< T > T raw()
cast to any raw value type
final void jsonlisterror()
test json list error
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
final void xmlobjectmultiple()
test xml object with single argument
final void jsonobjectmultiple()
test json object with multiple arguments
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
action for calling a restful webservice with a JSON object.