src/main/resources/com/microfocus/application/automation/tools/octane/testrunner/TestsToRunConverterBuilder/config.jelly
<!--
~ Certain versions of software accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company.
~ This software was acquired by Micro Focus on September 1, 2017, and is now offered by OpenText.
~ Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.
~ __________________________________________________________________
~ MIT License
~
~ Copyright 2012-2024 Open Text
~
~ The only warranties for products and services of Open Text and
~ its affiliates and licensors ("Open Text") are as may be set forth
~ in the express warranty statements accompanying such products and services.
~ Nothing herein should be construed as constituting an additional warranty.
~ Open Text shall not be liable for technical or editorial errors or
~ omissions contained herein. The information contained herein is subject
~ to change without notice.
~
~ Except as specifically indicated otherwise, this document contains
~ confidential information and a valid license is required for possession,
~ use or copying. If this work is provided to the U.S. Government,
~ consistent with FAR 12.211 and 12.212, Commercial Computer Software,
~ Computer Software Documentation, and Technical Data for Commercial Items are
~ licensed to the U.S. Government under vendor's standard commercial license.
~
~ 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.
~ ___________________________________________________________________
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="Testing framework" field="framework">
<select name="teststorunconverter.framework" onchange="frameworkChanged(this)">
<j:forEach var="myFramework" items="${descriptor.Frameworks}">
<f:option selected="${myFramework.name == instance.testsToRunConverterModel.framework.name}" value="${myFramework.name}">
${myFramework.description}
</f:option>
</j:forEach>
</select>
</f:entry>
<f:entry title="Custom conversion format" field="format">
<div class="custom-conf-parent">
<j:if test="${instance.isCustom}">
<textarea name="teststorunconverter.format" type="text" class="custom-configuration-text jenkins-input setting-input">
${instance.testsToRunConverterModel.framework.format}
</textarea>
<select class="custom-configuration-fill" onchange="insertFormat(this)">
<f:option value="title">Fill sample configuration ...</f:option>
<f:option value="basic">Minimal configuration</f:option>
<f:option value="extended">Extended configuration</f:option>
</select>
</j:if>
<j:if test="${!instance.isCustom}">
<textarea name="teststorunconverter.format" type="text" disabled="true" class="custom-configuration-text jenkins-input setting-input">
${instance.testsToRunConverterModel.framework.format}
</textarea>
<select class="custom-configuration-fill hidden" onchange="insertFormat(this)">
<f:option value="title">Fill sample configuration ...</f:option>
<f:option value="basic">Minimal configuration</f:option>
<f:option value="extended">Extended configuration</f:option>
</select>
</j:if>
</div>
</f:entry>
<f:advanced title ="Validate">
<f:section title="Validate conversion"/>
<f:entry title="Tests to run" description="Enter tests to run in raw format, for example : v1:package1|className1|testName1;package2|className2|testName2">
<f:textbox field="testsToRun" />
</f:entry>
<f:validateButton title="Convert" progress="Evaluating..."
method="testConvert" with="teststorunconverter.framework,teststorunconverter.format,testsToRun"/>
</f:advanced>
<style>
.custom-conf-parent{
position:relative;
}
.custom-configuration-fill1{
position: absolute;
font-size: smaller;
right: 20px;
}
.custom-configuration-fill{
top:-1px;
position: relative;
font-size: smaller;
float:right;
}
.custom-configuration-text{
resize: vertical;
min-height:90px;
height:120px;
}
.hidden{
visibility: hidden
}
</style>
<script>
function insertFormat(sender){
var index = sender.selectedIndex;
var options = sender.options;
var parent = getTableParent(sender);
var txtFormat = parent.querySelector(".custom-configuration-text");
if(options[index].value === 'basic'){
txtFormat.value = "{\n\t\"testPattern\": \"$package.$class#$testName\",\n\t\"testDelimiter\": \",\"\n}";
}
else if(options[index].value === 'extended'){
txtFormat.value = "{"+
"\n\t\"testPattern\": \"$package.$class#$testName\","+
"\n\t\"testDelimiter\": \",\","+
"\n\t\"prefix\": \"\","+
"\n\t\"suffix\": \"\","+
"\n\t\"replacements\": ["+
"\n\t\{"+
"\n\t\t\"type\": \"replaceString\","+
"\n\t\t\"target\": \"$package|$class|$testName\","+
"\n\t\t\"string\": \"aaa\","+
"\n\t\t\"replacement\": \"bbb\""+
"\n\t\}"+
"\n\t\{"+
"\n\t\t\"type\": \"replaceRegexFirst\","+
"\n\t\t\"target\": \"$package|$class|$testName\","+
"\n\t\t\"regex\": \"aaa\","+
"\n\t\t\"replacement\": \"bbb\""+
"\n\t\}"+
"\n\t\{"+
"\n\t\t\"type\": \"joinString\","+
"\n\t\t\"target\": \"$package|$class|$testName\","+
"\n\t\t\"prefix\": \"\","+
"\n\t\t\"suffix\": \"\""+
"\n\t\}"+
"\n\t]"+
"\n}";
}
sender.selectedIndex = 0;
}
function frameworkChanged(sender) {
var parent = getTableParent(sender);
var bCustom = sender.options[sender.selectedIndex].value === 'custom' ? true : false;
var parent = getTableParent(sender)
enableElements(bCustom,parent);
}
function enableElements(isCustom, parent){
var txtFormat = parent.querySelector(".custom-configuration-text");
if(txtFormat){
txtFormat.disabled = !isCustom;
}
var fillFormat = parent.querySelector(".custom-configuration-fill");
if(fillFormat){
if(isCustom){
fillFormat.classList.remove("hidden");
} else {
fillFormat.classList.add("hidden");
}
}
}
function getTableParent(element){
var myElement = element;
var counter = 0;
while(myElement.nodeName.toLowerCase()!=="table"){
myElement = myElement.parentElement;
counter++;
if(counter>=4){
break;
}
}
return myElement;
}
</script>
</j:jelly>