Skip to content

Commit

Permalink
fix action generator
Browse files Browse the repository at this point in the history
  • Loading branch information
querdenker2k committed Dec 20, 2023
1 parent a07c951 commit cba9890
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.openhab.automation.jrule.internal.JRuleConfig;
Expand Down Expand Up @@ -180,8 +179,8 @@ private Map<String, Object> createActionModel(Thing thing) {
Map<Object, Object> arg = new HashMap<>();
Class<?> parameterType = replaceTypeIfNecessary(parameter.getType());
arg.put("type", parameterType.getTypeName());
arg.put("reflectionType", ClassUtils.primitiveToWrapper(parameter.getType())
.getTypeName().replaceFirst("java.lang.", ""));
arg.put("reflectionType",
parameter.getType().getTypeName().replaceFirst("java.lang.", ""));
arg.put("name", parameter.getAnnotation(ActionInput.class).name());
args.add(arg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public Collection<Class<? extends ThingHandlerService>> getServices() {
Object res = doSomethingAbstract.invoke(action, new StringType("blub"));
assertEquals(10, res);

Method doSomething = action.getClass().getDeclaredMethod("doSomething", String.class, int.class, Float.class);
doSomething.invoke(action, "hi", (int) 5, 3.7f);
assertEquals(10, res);

// Verify method with unsupported types are mapped to Object
Method returnObjectOnUnsupportedClass = action.getClass().getDeclaredMethod("returnObjectOnUnsupportedClass",
Object.class);
Expand Down

0 comments on commit cba9890

Please sign in to comment.