Skip to content

Commit

Permalink
#274 fix sahi message doubled and sahi documentation URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Schneck committed Feb 1, 2018
1 parent c505c08 commit 1cb0a42
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ sakuli.screenshot.dir=${sakuli.log.folder}/_screenshots
# screenshot file format (Possible values: jpg, png)
sakuli.screenshot.format=png
### URLs for documentation links
sahi.doc.url=http://sahipro.com/docs/sahi-apis/action-apis.html
sahi.doc.base.url=http://sahipro.com/docs/all-topics.html?q=
sakuli.doc.base.url=http://consol.github.io/sakuli/latest/index.html#

#######################################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/main/java/org/sakuli/aop/RhinoAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void doHandleRhinoException(JoinPoint joinPoint) {
else if (logResult.getDebugInfo() == null
|| !logResult.getDebugInfo().startsWith("org.sakuli.actions.")) {
logger.info(logResult.getMessage());
addActionsToCurrentTestCase(TestAction.createSahiTestAction(logResult.getMessage(), BeanLoader.loadBaseActionLoader().getSakuliProperties().getSahiDocUrl()));
addActionsToCurrentTestCase(TestAction.createSahiTestAction(logResult.getMessage(), BeanLoader.loadBaseActionLoader().getSakuliProperties().getSahiDocBaseUrl()));
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/core/src/main/java/org/sakuli/datamodel/TestAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@

package org.sakuli.datamodel;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.apache.commons.lang3.StringUtils.removeEnd;
import static org.apache.commons.lang3.StringUtils.substringBetween;

/**
* Created by georgi on 21/09/17.
*/
Expand All @@ -37,7 +41,7 @@ public class TestAction {
private TestAction(String object, String method, List<String> args, String message, String documentationURL) {
this.object = object;
this.method = method;
this.args = args;
this.args = args == null ? Collections.EMPTY_LIST : args;
this.message = message;
this.documentationURL = documentationURL;
}
Expand All @@ -55,7 +59,7 @@ public static TestAction createSakuliTestAction(String object, String method, Ob
}

public static TestAction createSahiTestAction(String method, String documentationURL) {
return new TestAction(method, method, null, null, documentationURL);
return new TestAction(null, removeEnd(method, ";"), null, "Sahi Action", documentationURL + "_" + substringBetween(method, "_", "("));
}

private static String createDocumentationURL(String baseUrl, String clazz, String method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class SakuliProperties extends AbstractProperties {
public static final String LOG_LEVEL_SPRING = "log.level.spring";
public static final String LOG_LEVEL_ROOT = "log.level.root";
public static final String FORWARDER_TEMPLATE_FOLDER = "sakuli.forwarder.template.folder";
public static final String SAHI_DOC_URL = "sahi.doc.url";
public static final String SAHI_DOC_BASE_URL = "sahi.doc.base.url";
public static final String SAKULI_DOC_BASE_URL = "sakuli.doc.base.url";
public static final String CONFIG_FOLDER_APPEDER = File.separator + "config";
public static final String LIBS_FOLDER_APPEDER = File.separator + "libs";
Expand Down Expand Up @@ -86,8 +86,8 @@ public class SakuliProperties extends AbstractProperties {
private String logLevelRoot;
@Value("${" + FORWARDER_TEMPLATE_FOLDER + ":}")
private String forwarderTemplateFolder;
@Value("${" + SAHI_DOC_URL + "}")
private String sahiDocumentationUrl;
@Value("${" + SAHI_DOC_BASE_URL + "}")
private String sahiDocumentationBaseUrl;
@Value("${" + SAKULI_DOC_BASE_URL + "}")
private String sakuliDocumentationBaseUrl;

Expand Down Expand Up @@ -248,8 +248,8 @@ public String getForwarderTemplateFolder() {
return forwarderTemplateFolder;
}

public String getSahiDocUrl() {
return sahiDocumentationUrl;
public String getSahiDocBaseUrl() {
return sahiDocumentationBaseUrl;
}

public String getSakuliDocBaseUrl() {
Expand Down
12 changes: 11 additions & 1 deletion src/core/src/test/java/org/sakuli/datamodel/TestCaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

/**
* @author tschneck
* Date: 19.07.13
* Date: 19.07.13
*/
public class TestCaseTest {
private TestCase testling;
Expand Down Expand Up @@ -127,4 +127,14 @@ public void testGetAndResetTestActions() throws Exception {
assertEquals(testling.getTestActions().size(), 0);
}

@Test
public void testCreateSahiTestAction() throws Exception {
String url = "http://sahipro.com/docs/all-topics.html?q=";
final TestAction ta = TestAction.createSahiTestAction("_highlight(_link(\"Sample Application\"));", url);
assertEquals(ta.getArgs().size(), 0);
assertEquals(ta.getMessage(), "Sahi Action");
assertEquals(ta.getMethod(), "_highlight(_link(\"Sample Application\"))");
assertEquals(ta.getObject(), null);
assertEquals(ta.getDocumentationURL(), url + "_highlight");
}
}

0 comments on commit 1cb0a42

Please sign in to comment.