01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.teststeps.actions;
14:
15: import java.awt.event.ActionEvent;
16:
17: import javax.swing.AbstractAction;
18: import javax.swing.Action;
19:
20: import com.eviware.soapui.impl.wsdl.support.assertions.Assertable;
21: import com.eviware.soapui.impl.wsdl.teststeps.WsdlMessageAssertion;
22: import com.eviware.soapui.impl.wsdl.teststeps.assertions.WsdlAssertionRegistry;
23: import com.eviware.soapui.support.UISupport;
24:
25: /**
26: * Adds a WsdlAssertion to a WsdlTestRequest
27: *
28: * @author Ole.Matzura
29: */
30:
31: public class AddAssertionAction extends AbstractAction {
32: private final Assertable assertable;
33:
34: public AddAssertionAction(Assertable assertable) {
35: super ("Add Assertion");
36: this .assertable = assertable;
37:
38: putValue(Action.SHORT_DESCRIPTION,
39: "Adds an assertion to this test assertable");
40: putValue(Action.SMALL_ICON, UISupport
41: .createImageIcon("/addAssertion.gif"));
42: }
43:
44: public void actionPerformed(ActionEvent e) {
45: String[] assertions = WsdlAssertionRegistry.getInstance()
46: .getAvailableAssertionNames(
47: assertable.getAssertionType());
48:
49: if (assertions == null || assertions.length == 0) {
50: UISupport
51: .showErrorMessage("No assertions available for this message");
52: return;
53: }
54:
55: String selection = (String) UISupport.prompt(
56: "Select assertion to add", "Select Assertion",
57: assertions);
58: if (selection == null)
59: return;
60:
61: WsdlMessageAssertion assertion = assertable
62: .addAssertion(selection);
63: if (assertion == null) {
64: UISupport.showErrorMessage("Failed to add assertion");
65: return;
66: }
67:
68: if (assertion.isConfigurable()) {
69: assertion.configure();
70: }
71: }
72: }
|