Dynamic URL across different environments using ImpEx - sap-commerce-cloud

as a part of a requirement I have to configure the hyperlink for the description of the products across the site.
The issue is how do I configure the dynamic URL via ImpEx(as the URL points to a dynamic URL,which will be relative to each environment).

You can create a URL with parameters. Something like this-
https://yoursite/{param1}/stuff/{param2}
Then, you can read the parameters in you controller by using the #PathVariable in you method signature.

You can add a propeties on each of local.properties of every environments, example:
LOCAL
target.deployment.env=LOCAL
TEST
target.deployment.env=TEST
And add this code on the header of your impex :
#% impex.info("Target system is : "+Config.getParameter("target.deployment.env"));
#% if: "LOCAL".equals(Config.getParameter("target.deployment.env"));
$Url= LocalUrl;
#% endif:
#% if: "TEST".equals(Config.getParameter("target.deployment.env"));
$Url = TestRL;
#% endif:
And use this variable on your impex :
$Url/homepage
Hope this helps

Related

How to split the variable in Gitlab pipline (.gitlab-ci.yml)

I have a branch name, for example, release-1.1.3, how I can split and extract the version by writing some logic in gitlab-ci file. Is there some method available for it?
before_script
export BRANCH_NAME=$CI_COMMIT_REF_NAME
// here I want to do something to extract the version
export Major=BRANCH_NAME.someoperation
export Minor=BRANCH_NAME.someoperation
export PATCH=BRANCH_NAME.someoperation
any other approaches are also welcome but I required the value in a separate variable which I can pass it to other operations.
I am new to gitlab-ci and working on it, thanks in advance.
Just split your string
You will find some examples here.
How to cut a string after a specific character in unix

Getting values of properties in SoapUI's groovy

I'm pretty new to testing and SoapUI and I've just faced a problem:
I have 2 soap requests from which I transfer data (using PropertyTransfer) to Properties - I can do that and it works fine for me.
But now I would like to take those values in my groovy script (which is next step of my testcase). How to do that? So far, I have found following:
testRunner.testCase.getPropertyValue("SomeProp")
But it doesn't work for me. I guess it's not that Properties. Any tips?
In the Groovy script panel you can right-click and select Get Data, to help you out. You will end up with something like this:
context.expand( '${Properties step#SomeProp}' )
Same thing can also be written as:
testRunner.testCase.testSteps['Properties step'].getPropertyValue("SomeProp")
Few cents:
if we are loading properties file through external file via -Dsoapui.properties=\tmp.properties
Contents of tmp.properties
serialNumber=908664374
ideal way to load the property 'serialNumber' in groovy file would be,
def serialnumber = context.expand('${#serialNumber}')
But if you have a property at any level [test suites, test cases or project] inside your SOAPUI project, say you have it at project level, then it would be
def serialnumber1 = context.expand('${#Project#serialNumber}')
The first expression works with:
context.expand( '${Properties_step#SomeProp}' )
To read property from Project level properties
testRunner.testCase.testSuite.project.getPropertyValue( "PropertyName")
To read property from Test Case level properties
testRunner.testCase.getPropertyValue("PropertyName")
Two answers are possible for this type of scenarios ,
Setting and Getting the Property values,
Message Exchange
Test Runner
Message Exchange :
def testCase=messageExchange.modelItem.testCase.getPropertyValue("Propertyname")
Test Runner:
testRunner.testCase.getPropertyValue("PropertyName")
Note : context also helps to retrieve the same .

JIRA Builtin Script Listener - Create a sub-task. - How to set assignee?

I am using JIRA Builtin Script Listener - Create a sub-task. to create subtasks for Dev and QA for every story and bug in JIRA.
I would like the subtasks to be always assigned to user "Virtual QA". It seems that I have to do this through Additional issue actions field.
I am trying to use:
issue.summary = ('QA: ' + issue.summary)
issue.assignee = 'Virtual QA'
This works only if I use only the first line to set the subtask summary but when I add the second line the script does not run. Can you please help me to solve it?
I was not able to help myself using the official documentation on: https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts
you need to pass user object instead of string, same question here
https://answers.atlassian.com/questions/66562/set-assignee-to-some-specific-user-in-post-function-script
After a lot of investigation and a hundred text tickets this works :)
import com.atlassian.jira.component.ComponentAccessor
issue.summary = ('QA: ' + issue.summary)
issue.setAssignee(ComponentAccessor.getUserUtil().getUser('qa'))

Relative path for JMeter XML Schema?

I'm using JMeter 2.6, and have the following setup for my test:
-
|-test.jmx
|-myschema.xsd
I've set up an XML Schema Assertion, and typed "myschema.xsd" in the File Name field. Unfortunately, this doesn't work:
HTTP Request
Output schema : error: line=1 col=114 schema_reference.4:
Failed to read schema document 'myschema.xsd', because
1) could not find the document;
2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
I've tried adding several things to the path, including ${__P(user.dir)} (points to the home dir of the user) and ${__BeanShell(pwd())} (doesn't return anything). I got it working by giving the absolute path, but the script is supposed to be used by others, so that's no good.
I could make it use a property value defined in the command line, but I'd like to avoid it as well, for the same reason.
How can I correctly point the Assertion to the schema under these circumstances?
Looks like you have to in this situation
validate your xml against xsd manually: simply use corresponding java code from e.g. BeanShell Assertion or BeanShell PostProcessor;
here is a pretty nice solution: https://stackoverflow.com/a/16054/993246 (as well you can use any other you want for this);
dig into jmeter's sources, amend XML Schema file obtaining to support variables in path (File Name field) - like CSV Data Set Config does;
but the previous way seems to be much easier;
run your jmeter test-scenario from shell-script or ant-task which will first copy your xsd to jmeter's /bin dir before script execution - at least XML Schema Assertion can be used "as is".
Perhaps if you will find any other/better - please share it.
Hope this helps.
Summary: in the end I've used http://path.to.schema/myschema.xsd as the File Name parameter in the Assertion.
Explanation: following Alies Belik's advice, I've found that the code for setting up the schema looks something like this:
DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
...
parserFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdFileName);
where xsdFileName is a string (the attribute string is actually a constant, I inlined it for readability).
According to e.g. this page, the attribute, when in the form a String, is interpreted as an URI - which includes HTTP URLs. Since I already have the schema accessible through HTTP, I've opted for this solution.
Add the 'myschema.xsd' to the \bin directory of your apache-jmeter next to the 'ApacheJMeter.jar' or set the 'File Name' from the 'XML Schema Assertion' to your 'myschema.xsd' from this starting point.
E.g.
JMeter: C:\Users\username\programs\apache-jmeter-2.13\bin\ApacheJMeter.jar
Schema: C:\Users\username\workspace\yourTest\schema\myschema.xsd
File Name: ..\\..\\..\workspace\yourTest\schema\myschema.xsd

Using getResources and a custom date TV, how can I limit my results by the year entered in my TV?

In MODx Revolution, while using getResources and a custom date TV (called: press-release-date), how can I limit my results by year (using a URL param to set the year, so I could enter any year)?
For example, my URL has page.html?year=2012
I want my results from getResources to only include ones associated with that year. I believe I want to use the &where property (if so, I am certainly botching the formatting):
&where=`{"press-release-date":[[*press-release-date:strtotime:date=`%Y`]:isequalto:`2012`]}`
I've also tried
&where=`{[[*press-release-date]]:[[*press-release-date:strtotime:date=`%Y`]:isequalto:`2012`]}`
Thanks!
UPDATE:
This is the full code I am using currently:
[[!getResources?
&parents=`780,781,782,783,784`
&tpl=`list-press-tpl`
&limit=`1000`
&sortdir=`DESC`
&includeTVs=`1`
&includeContent=`1`
&depth=`0`
&showHidden=`1`
&sortbyTV=`press-release-date`
&where=`{[[*press-release-date]]:[[*press-release-date:strtotime:date=`%Y`]:isequalto:`2012`]}`
]]
You are going to want to use the &tvFilters attribute: http://rtfm.modx.com/display/ADDON/getResources you will probably have to also &includeTVs, &includeTvsList and ~possibly~ also &processTVList. As to how to strip the post value from the url, you may have to write a quick little snippet that grabs all your url variables & sets them as placeholders. something along the lines of:
foreach($_POST as $key => $value){
$modx->setPlaceholder($key,$value);
}
Then you should be able to access them:
&where=`{[[*press-release-date]]:[[*press-release-date:strtotime:date=`%Y`]:isequalto:`[[+year]]`]}`
at a guess... not tested.:)
You can try tvFilters instead. But you will have to translate your [[+year]] into your press-release-date date format and limit search inside intertleave:
&tvFilters=`press-release-date>=[[+year:dec:strtotime]]||press-release-date<=[[+year:strtotime]]`
http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29
http://rtfm.modx.com/display/revolution20/Date+Formats
http://ru2.php.net/strtotime

Resources