Skip to content

Commit

Permalink
Merge pull request #67 from WasiqB/issue-65
Browse files Browse the repository at this point in the history
Issue 65
  • Loading branch information
mfaisalkhatri authored Oct 2, 2018
2 parents f9f54cd + 23fc5e4 commit 0028a79
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
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

0 comments on commit 0028a79

Please sign in to comment.