okAction.setDialog( dialog );
cancelAction.setDialog( dialog );
applyAction.setDialog( dialog );
final TestCase testCase = securityScan.getTestStep().getTestCase();
final Project project = testCase.getTestSuite().getProject();
dialog.getFormField( CloneParameterDialog.TARGET_TESTSUITE ).addFormFieldListener( new XFormFieldListener()
{
public void valueChanged( XFormField sourceField, String newValue, String oldValue )
{
TestSuite testSuite = project.getTestSuiteByName( newValue );
String[] testCaseNames = ModelSupport.getNames( testSuite.getTestCaseList() );
dialog.setOptions( CloneParameterDialog.TARGET_TESTCASE, testCaseNames );
if( testCaseNames.length > 0 )
{
dialog.setValue( CloneParameterDialog.TARGET_TESTCASE, testCaseNames[0] );
TestCase testCase = testSuite.getTestCaseByName( testCaseNames[0] );
String[] testStepNames = new String[0];
String[] securityTestNames = ModelSupport.getNames( testCase.getSecurityTestList() );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames );
if( securityTestNames.length > 0 )
{
testStepNames = getSecurableTestStepsNames( testCase );
}
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, testStepNames );
if( securityTestNames.length > 0 )
{
dialog.setValue( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0] );
if( testStepNames.length > 0 )
{
dialog.setValue( CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0] );
}
else
{
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
}
String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
TestStep testStep = testCase.getTestStepByName( testStepName );
String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
testStep.getId(), AbstractSecurityScanWithProperties.class ) );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
}
else
{
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, new String[0] );
}
}
else
{
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
}
}
} );
dialog.getFormField( CloneParameterDialog.TARGET_TESTCASE ).addFormFieldListener( new XFormFieldListener()
{
public void valueChanged( XFormField sourceField, String newValue, String oldValue )
{
String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
TestCase testCase = testSuite.getTestCaseByName( newValue );
String[] testStepNames = new String[0];
String[] securityTestNames = ModelSupport.getNames( testCase.getSecurityTestList() );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames );
if( securityTestNames.length > 0 )
{
testStepNames = getSecurableTestStepsNames( testCase );
}
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, testStepNames );
if( securityTestNames.length > 0 )
{
dialog.setValue( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0] );
if( testStepNames.length > 0 )
{
dialog.setValue( CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0] );
}
else
{
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
}
String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
TestStep testStep = testCase.getTestStepByName( testStepName );
String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
testStep.getId(), AbstractSecurityScanWithProperties.class ) );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
}
else
{
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, new String[0] );
}
}
} );
dialog.getFormField( CloneParameterDialog.TARGET_TESTSTEP ).addFormFieldListener( new XFormFieldListener()
{
public void valueChanged( XFormField sourceField, String newValue, String oldValue )
{
String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
String testCaseName = dialog.getValue( CloneParameterDialog.TARGET_TESTCASE );
TestCase testCase = testSuite.getTestCaseByName( testCaseName );
String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
TestStep testStep = testCase.getTestStepByName( newValue );
String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
testStep.getId(), AbstractSecurityScanWithProperties.class ) );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
}
} );
dialog.getFormField( CloneParameterDialog.TARGET_SECURITYTEST ).addFormFieldListener( new XFormFieldListener()
{
public void valueChanged( XFormField sourceField, String newValue, String oldValue )
{
String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
String testCaseName = dialog.getValue( CloneParameterDialog.TARGET_TESTCASE );
TestCase testCase = testSuite.getTestCaseByName( testCaseName );
SecurityTest securityTest = testCase.getSecurityTestByName( newValue );
String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
TestStep testStep = testCase.getTestStepByName( testStepName );
String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
testStep.getId(), AbstractSecurityScanWithProperties.class ) );
dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
}