Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,27 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Creating site for ${project.version}</message>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>site</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -230,9 +251,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<version>3.1.1</version>
<configuration>
<use>false</use>
<show>public</show>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private int getVarargsIndex() {
}

private Object getParameterValue(String parameterName, int i, List args, Map<String, Object> kwargs) {
String parameterDefaultValue = parameterName.contains("=") && parameterName.split("=").length > 1 ? parameterName.split("=")[1] : null;
String parameterDefaultValue = this.parameterNames.get(i).contains("=") && this.parameterNames.get(i).split("=").length > 1 ? this.parameterNames.get(i).split("=")[1] : null;
Object value = args != null && args.size() > i ? args.get(i) : parameterDefaultValue;
if (kwargs != null && kwargs.containsKey(parameterName)) {
value = kwargs.get(parameterName);
Expand All @@ -101,7 +101,7 @@ private Object ensureCorrectVarargsType(List varargs) {
private boolean keywordHasVarargs() {
int varargIndex = this.getVarargsIndex();
return varargIndex > -1 && parameterTypes != null && parameterTypes.length > 0 &&
(parameterTypes[parameterTypes.length-1] == List.class || parameterTypes[parameterTypes.length-varargIndex].isArray() ||
(parameterTypes[parameterTypes.length-1] == List.class || parameterTypes[parameterTypes.length-1].isArray() ||
(parameterTypes.length > 1 && (parameterTypes[parameterTypes.length-2] == List.class || parameterTypes[parameterTypes.length-2].isArray())));
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/some/own/keyword/AnnotatedKeywords.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.some.own.keyword;

import org.junit.jupiter.api.Assertions;
import org.opentest4j.AssertionFailedError;

import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywords;

Expand All @@ -22,5 +24,4 @@ public void myFailingKeyword() {
public String myKeywordThatReturnsItsArguments(String arg) {
return arg;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Assertions;
import org.opentest4j.AssertionFailedError;
import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.javalib.annotation.RobotKeyword;
Expand Down Expand Up @@ -102,4 +103,27 @@ public class SomeObject implements SomeInterface {
public String value;
}

@RobotKeyword
@ArgumentNames({"*Technical arguments"})
public String[] onlyVarargs(String[] arguments) {
return arguments;
}

@RobotKeyword
@ArgumentNames({"Image or text to wait", "Similarity of images=0.7", "*Technical arguments"})
public void defaultAndVarargs(String imageNameOrText, double similarity, String[] arguments) {
Assertions.assertEquals(0.7, similarity);
}

@RobotKeyword
@ArgumentNames({"port=0"})
public int useInt(int port) {
return port;
}

@RobotKeyword
@ArgumentNames({"port=0"})
public Integer useInteger(Integer port) {
return port;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public void findsAnnotatedKeywordsFromClassPath() throws Exception {
List keywordNames = annotationLibrary.getKeywordNames();
List expectedKeywordNames = Arrays.asList("failingKeyword", "someKeyword", "overloaded",
keywordThatReturnsItsArguments, "keywordWithVariableArgumentCount", "variousArgs", "defaultValues",
"keywordWithObjectArgument", "getSomeObject", "keywordWithNumericArguments", byteArrayTest );
"keywordWithObjectArgument", "getSomeObject", "keywordWithNumericArguments", byteArrayTest, "defaultAndVarargs", "onlyVarargs",
"useInt", "useInteger");
keywordNames.sort(Comparator.naturalOrder());
expectedKeywordNames.sort(Comparator.naturalOrder());
assertIterableEquals(keywordNames, expectedKeywordNames);
Expand Down Expand Up @@ -92,4 +93,26 @@ public void testByteArrayHandlingResponse() {
Object response = annotationLibrary.runKeyword(byteArrayTest, Arrays.asList(testString, testString.getBytes()));
assertEquals(testString, new String((byte[]) response));
}

@Test
public void onlyVarargs() {
annotationLibrary.runKeyword("onlyVarargs", Arrays.asList("one given argument"));
}

@Test
public void defaultAndVarargs() {
annotationLibrary.runKeyword("defaultAndVarargs", Arrays.asList("one given argument"));
}

@Test
public void useInt() {
Object response = annotationLibrary.runKeyword("useInt", Arrays.asList());
assertEquals(0, response);
}

@Test
public void useInteger() {
Object response = annotationLibrary.runKeyword("useInteger", Arrays.asList());
assertEquals(0, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public void testFindsAnnotatedKeywordsFromClassPath() {
List expectedKeywordNames = Arrays.asList("failingKeyword", "someKeyword", "overloaded",
keywordThatReturnsItsArguments, "keywordWithVariableArgumentCount", "variousArgs", "defaultValues",
"keywordWithObjectArgument", "getSomeObject", "keywordWithNumericArguments",
"myFailingKeyword", "myKeywordThatReturnsItsArguments", "byteArrayTest");
"myFailingKeyword", "myKeywordThatReturnsItsArguments", "byteArrayTest", "defaultAndVarargs", "onlyVarargs",
"useInt", "useInteger");
keywordNames.sort(Comparator.naturalOrder());
expectedKeywordNames.sort(Comparator.naturalOrder());
assertIterableEquals(keywordNames, expectedKeywordNames);
Expand Down
6 changes: 6 additions & 0 deletions src/test/robotframework/acceptance/annotationlibrary.robot
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ Positional and kwargs
Named and kwargs
Various Args arg=value hello=world # Logs 'arg: value' and 'kwarg: hello world'.
Various Args hello=world arg=value # Same as above. Order does not matter.

Only varargs
Only varargs testThing

Default and varargs
Default and varargs Non-default