Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 65 #67

Merged
merged 2 commits into from
Oct 2, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.github.wasiqb.coteafs.appium.config;

import static org.apache.commons.text.StringSubstitutor.replaceSystemProperties;
import static com.github.wasiqb.coteafs.appium.utils.StringUtil.replaceSystemProperty;

import com.github.wasiqb.coteafs.appium.config.enums.ApplicationType;
import com.github.wasiqb.coteafs.appium.config.enums.AutomationName;
Expand Down Expand Up @@ -81,9 +81,7 @@ public AndroidDeviceSetting getAndroid () {
* @return the appLocation
*/
public String getAppLocation () {
return this.appLocation.startsWith ("${")
? replaceSystemProperties (this.appLocation)
: this.appLocation;
return replaceSystemProperty (this.appLocation);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.github.wasiqb.coteafs.appium.config;

import static org.apache.commons.text.StringSubstitutor.replaceSystemProperties;
import static com.github.wasiqb.coteafs.appium.utils.StringUtil.replaceSystemProperty;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -128,9 +128,7 @@ public String getNodePath () {
* @return the password
*/
public String getPassword () {
return this.password.startsWith ("${")
? replaceSystemProperties (this.password)
: this.password;
return replaceSystemProperty (this.password);
}

/**
Expand Down Expand Up @@ -175,9 +173,7 @@ public long getStartUpTimeOutSeconds () {
* @return the userName
*/
public String getUserName () {
return this.userName.startsWith ("${")
? replaceSystemProperties (this.userName)
: this.userName;
return replaceSystemProperty (this.userName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2017-2020, Wasiq Bhamla.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.wasiqb.coteafs.appium.utils;

import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.apache.commons.text.StringSubstitutor.replaceSystemProperties;

/**
* @author wasiqb
* @since Oct 2, 2018
*/
public final class StringUtil {
/**
* @author wasiqb
* @since Oct 2, 2018
* @param value
* @return extracted string.
*/
public static String replaceSystemProperty (final String value) {
if (isEmpty (value))
return null;
return value.startsWith ("${") ? replaceSystemProperties (value) : value;
}

private StringUtil () {
// Util class.
}
}
1 change: 0 additions & 1 deletion src/test/resources/appium-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ devices:
app_type: HYBRID
device_type: REAL
automation_name: APPIUM
app_location: apps/android/VodQA.apk
app_location: ${env.app}
cloud_app: true
session_timeout: 120000
Expand Down