LightJason - AgentSpeak(L++)
TestCActionBinding.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.action.builtin;
25 
26 import org.junit.Assert;
27 import org.junit.Test;
34 
35 import java.util.stream.Stream;
36 
37 
41 public final class TestCActionBinding extends IBaseTest
42 {
43 
47  @Test
48  public final void classbinding()
49  {
50  Assert.assertArrayEquals(
51 
56  ).map( i -> i.name().path() ).toArray(),
57 
58  Stream.of( "methodwhitelist" ).toArray()
59  );
60  }
61 
62 
66  @Test
67  public final void methoddefault()
68  {
69  Assert.assertArrayEquals(
70  CCommon.actionsFromAgentClass( CMethodBindingDefault.class ).map( i -> i.name().path() ).toArray(),
71  Stream.of( "methodannotate" ).toArray()
72  );
73  }
74 
75 
79  @Test
80  public final void methodblacklist()
81  {
82  Assert.assertArrayEquals(
83  CCommon.actionsFromAgentClass( CMethodBindingBlacklist.class ).map( i -> i.name().path() ).toArray(),
84  Stream.of( "methodannotate" ).toArray()
85  );
86  }
87 
88 
92  @Test
93  public final void methodwhitelist()
94  {
95  Assert.assertArrayEquals(
96  CCommon.actionsFromAgentClass( CMethodBindingWhitelist.class ).map( i -> i.name().path() ).toArray(),
97  Stream.of( "methodnotannotate" ).toArray()
98  );
99  }
100 
101  // ---------------------------------------------------------------------------------------------------------------------------------------------------------
102 
103 
107  @IAgentAction
108  private static final class CClassBindingDefault extends IBaseAgent<CClassBindingDefault>
109  {
113  private static final long serialVersionUID = 3345768520232804575L;
114 
121  {
122  super( p_configuration );
123  }
124 
128  private void methoddefault()
129  {}
130  }
131 
136  private static final class CClassBindingBlacklist extends IBaseAgent<CClassBindingBlacklist>
137  {
141  private static final long serialVersionUID = 7111629511993393960L;
142 
149  {
150  super( p_configuration );
151  }
152 
156  private void methodblacklist()
157  {}
158  }
159 
164  private static final class CClassBindingWhitelist extends IBaseAgent<CClassBindingWhitelist>
165  {
169  private static final long serialVersionUID = -7816405802996290926L;
170 
177  {
178  super( p_configuration );
179  }
180 
184  private void methodwhitelist()
185  {}
186  }
187 
188 
192  @IAgentAction
193  private static final class CMethodBindingDefault extends IBaseAgent<CMethodBindingDefault>
194  {
198  private static final long serialVersionUID = -2286148952945672902L;
199 
206  {
207  super( p_configuration );
208  }
209 
214  private void methodannotate()
215  {}
216 
220  private void methodnotannotate()
221  {}
222  }
223 
228  private static final class CMethodBindingBlacklist extends IBaseAgent<CMethodBindingBlacklist>
229  {
233  private static final long serialVersionUID = 2803896156449016208L;
234 
241  {
242  super( p_configuration );
243  }
244 
249  private void methodannotate()
250  {}
251 
255  private void methodnotannotate()
256  {}
257  }
258 
259 
264  private static final class CMethodBindingWhitelist extends IBaseAgent<CMethodBindingWhitelist>
265  {
269  private static final long serialVersionUID = -9187345129201192928L;
270 
277  {
278  super( p_configuration );
279  }
280 
285  private void methodannotate()
286  {}
287 
291  private void methodnotannotate()
292  {}
293  }
294 
295 
296 }
CMethodBindingDefault(final IAgentConfiguration< CMethodBindingDefault > p_configuration)
ctor
class annotation to set default behaviour of method-action-binding to a blacklist ...
base test class with helpers
Definition: IBaseTest.java:33
final void methodwhitelist()
test method whitelist binding
CClassBindingWhitelist(final IAgentConfiguration< CClassBindingWhitelist > p_configuration)
ctor
static Stream< IAction > actionsFromAgentClass( @Nonnull final Class<?>... p_class)
returns actions by a class
final void methoddefault()
test method default binding
final void methodblacklist()
test method blacklist binding
CMethodBindingWhitelist(final IAgentConfiguration< CMethodBindingWhitelist > p_configuration)
ctor
CClassBindingBlacklist(final IAgentConfiguration< CClassBindingBlacklist > p_configuration)
ctor
CMethodBindingBlacklist(final IAgentConfiguration< CMethodBindingBlacklist > p_configuration)
ctor
CClassBindingDefault(final IAgentConfiguration< CClassBindingDefault > p_configuration)
ctor
method annotation to allow the binding of a method for an action