24 package org.lightjason.agentspeak.beliefbase;
26 import com.codepoetics.protonpack.StreamUtils;
27 import com.fasterxml.jackson.databind.ObjectMapper;
28 import org.apache.commons.io.IOUtils;
29 import org.apache.commons.lang3.tuple.ImmutablePair;
30 import org.apache.commons.lang3.tuple.Pair;
31 import org.junit.Assert;
32 import org.junit.Assume;
33 import org.junit.Before;
34 import org.junit.Test;
54 import javax.annotation.Nonnegative;
55 import javax.annotation.Nonnull;
56 import java.io.IOException;
57 import java.text.MessageFormat;
58 import java.util.ArrayList;
59 import java.util.Collections;
60 import java.util.List;
63 import java.util.logging.LogManager;
64 import java.util.stream.Collectors;
65 import java.util.stream.Stream;
76 private final Set<IAction>
m_actions = Stream.concat(
81 ).collect( Collectors.toSet() );
94 LogManager.getLogManager().reset();
103 @SuppressWarnings(
"unchecked" )
106 m_testlog = Collections.synchronizedList(
new ArrayList<>() );
107 m_data =
new ObjectMapper().readValue(
108 "{ \"val\" : 123, \"str\" : \"text value\", \"logic\" : true, \"obj\" : { \"name\" : \"abcdef\", \"val\" : 357 }, \"ar\" : [1, 3, 5] }",
119 Assume.assumeNotNull(
m_data );
142 Assume.assumeNotNull(
m_data );
156 Assume.assumeNotNull(
m_data );
171 Assume.assumeNotNull(
m_data );
176 +
"generic/print('string-value:', X); " 177 +
"test/result( bool/equal(X, 'text value'), 'unified value incorrect' ). " 178 +
"-!main <- test/result( fail, 'unification wrong').",
183 MessageFormat.format(
"{0}",
m_testlog.stream().filter( i -> !i.getLeft() ).map( Pair::getRight ).collect( Collectors.toList() ) ),
184 m_testlog.stream().anyMatch( Pair::getLeft )
217 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return
251 @Nonnull
final List<ITerm> p_argument, @Nonnull
final List<ITerm> p_return
256 p_argument.get( 0 ).<Boolean>raw(),
257 p_argument.size() > 1
258 ? p_argument.get( 1 ).<String>raw()
286 super( p_configuration );
287 m_beliefbase.add(
new CViewMap(
"map", p_map, m_beliefbase ) );
298 private final Map<String, Object>
m_map;
308 CAgentGenerator(
final String p_asl,
final Map<String, Object> p_map,
final Set<IAction> p_actions )
throws Exception
310 super( IOUtils.toInputStream( p_asl,
"UTF-8" ), p_actions );
317 return new CAgent( m_configuration, m_map );
final void inagent()
test in-agent definition
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
default implementation of an action
boolean containsView( @Nonnull final IPath p_path)
view existing check
base test class with helpers
Map< String, Object > m_data
map reference
static< N > IFuzzyValue< N > from( @Nonnull final N p_value)
factory
static IPath from( @Nonnull final String p_string)
factor method to build path
final int minimalArgumentNumber()
minimum number of arguments
class to create a path structure
final IPath name()
returns the name with path of the action
final void stream()
test stream
view for a beliefbase that creates any access to the underlying data structures
CAgent(final IAgentConfiguration< IAgent<?>> p_configuration, final Map< String, Object > p_map)
ctor
CAgentGenerator(final String p_asl, final Map< String, Object > p_map, final Set< IAction > p_actions)
ctor
final Set< IAction > m_actions
actions
execution context with local data
external action interface
static final boolean PRINTENABLE
enable printing of test-data
static Stream< IAction > actionsFromPackage( @Nullable final String... p_package)
get all classes within an Java package as action
IAgent<?> generatesingle(final Object... p_data)
final int minimalArgumentNumber()
minimum number of arguments
final Map< String, Object > m_map
belief map
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
result for an immutable fuzzy value
final void containsliteral()
test contains literal
final void initialize()
initialize
default generic literal class for agent beliefs a literal consists of a functor, an optional list of ...
final IPath name()
returns the name with path of the action
interface to define the agent configuration
static final long serialVersionUID
serial id
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
class for any helper calls
List< Pair< Boolean, String > > m_testlog
list with successful plans
static ILiteral from( @Nonnull final String p_functor, @Nullable final ITerm... p_values)
factory
view which can use a map of maps to represent the hierarchical beliefbase structure ...
boolean containsLiteral( @Nonnull final IPath p_path)
checks if a literal exists
final void containsview()
test contains view
term structure for simple datatypes