Class NewTestCaseWizardPageOne

  • All Implemented Interfaces:
    IDialogPage, IMessageProvider, IWizardPage

    public class NewTestCaseWizardPageOne
    extends NewTypeWizardPage
    The class NewTestCaseWizardPageOne contains controls and validation routines for the first page of the 'New JUnit TestCase Wizard'.

    Clients can use the page as-is and add it to their own wizard, or extend it to modify validation or add and remove controls.

    Since:
    3.1
    • Field Detail

      • CLASS_UNDER_TEST

        public static final String CLASS_UNDER_TEST
        Field ID of the class under test field.
        See Also:
        Constant Field Values
      • JUNIT4TOGGLE

        public static final String JUNIT4TOGGLE
        Field ID of the JUnit version radio buttons
        Since:
        3.2
        See Also:
        Constant Field Values
    • Constructor Detail

      • NewTestCaseWizardPageOne

        public NewTestCaseWizardPageOne​(NewTestCaseWizardPageTwo page2)
        Creates a new NewTestCaseCreationWizardPage.
        Parameters:
        page2 - The second page
        Since:
        3.1
    • Method Detail

      • init

        public void init​(IStructuredSelection selection)
        Initialized the page with the current selection
        Parameters:
        selection - The selection
      • setJUnit4

        @Deprecated
        public void setJUnit4​(boolean isJUnit4,
                              boolean isEnabled)
        Specifies if the test should be created as JUnit 4 test.
        Parameters:
        isJUnit4 - if set, a JUnit 4 test will be created; otherwise a JUnit 3 test will be created
        isEnabled - if true, the modifier fields are editable; otherwise they are read-only
        Since:
        3.2
      • setJUnitVersion

        public void setJUnitVersion​(NewTestCaseWizardPageOne.JUnitVersion version)
        Specifies the JUnit version to create the test.
        Parameters:
        version - the JUnit version
        Since:
        3.11
      • setEnabled

        public void setEnabled​(boolean enabled)
        Specifies if the JUnit version radio buttons are enabled.
        Parameters:
        enabled - if true, the JUnit version radio buttons are enabled; otherwise they are read-only
        Since:
        3.11
      • isJUnit4

        @Deprecated
        public boolean isJUnit4()
        Deprecated.
        use getJUnitVersion() instead
        Returns true if the test should be created as Junit 4 test
        Returns:
        returns true if the test should be created as Junit 4 test
        Since:
        3.2
      • getJUnitVersion

        public NewTestCaseWizardPageOne.JUnitVersion getJUnitVersion()
        Returns the JUnit version to create the test.
        Returns:
        the JUnit version to create the test
        Since:
        3.11
      • handleFieldChanged

        protected void handleFieldChanged​(String fieldName)
        Description copied from class: NewContainerWizardPage
        Hook method that gets called when a field on this page has changed. For this page the method gets called when the source folder field changes.

        Every sub type is responsible to call this method when a field on its page has changed. Subtypes override (extend) the method to add verification when a own field has a dependency to an other field. For example the class name input must be verified again when the package field changes (check for duplicated class names).

        Overrides:
        handleFieldChanged in class NewTypeWizardPage
        Parameters:
        fieldName - The name of the field that has changed (field id). For the source folder the field id is CONTAINER
      • getStatusList

        protected IStatus[] getStatusList()
        Returns all status to be consider for the validation. Clients can override.
        Returns:
        The list of status to consider for the validation.
      • createControl

        public void createControl​(Composite parent)
      • createMethodStubSelectionControls

        protected void createMethodStubSelectionControls​(Composite composite,
                                                         int nColumns)
        Creates the controls for the method stub selection buttons. Expects a GridLayout with at least 3 columns.
        Parameters:
        composite - the parent composite
        nColumns - number of columns to span
      • createClassUnderTestControls

        protected void createClassUnderTestControls​(Composite composite,
                                                    int nColumns)
        Creates the controls for the 'class under test' field. Expects a GridLayout with at least 3 columns.
        Parameters:
        composite - the parent composite
        nColumns - number of columns to span
      • createJUnit4Controls

        protected void createJUnit4Controls​(Composite composite,
                                            int nColumns)
        Creates the controls for the JUnit version radio buttons. Expects a GridLayout with at least 3 columns.
        Parameters:
        composite - the parent composite
        nColumns - number of columns to span
        Since:
        3.2
      • createBuildPathConfigureControls

        protected void createBuildPathConfigureControls​(Composite composite,
                                                        int nColumns)
        Creates the controls for the JUnit 4 toggle control. Expects a GridLayout with at least 3 columns.
        Parameters:
        composite - the parent composite
        nColumns - number of columns to span
        Since:
        3.2
      • packageChanged

        protected IStatus packageChanged()
        Description copied from class: NewTypeWizardPage
        A hook method that gets called when the package field has changed. The method validates the package name and returns the status of the validation. The validation also updates the package fragment model.

        Subclasses may extend this method to perform their own validation.

        Overrides:
        packageChanged in class NewTypeWizardPage
        Returns:
        the status of the validation
      • classUnderTestChanged

        protected IStatus classUnderTestChanged()
        Hook method that gets called when the class under test has changed. The method class under test returns the status of the validation.

        Subclasses may extend this method to perform their own validation.

        Returns:
        the status of the validation
      • getClassUnderTestText

        public String getClassUnderTestText()
        Returns the content of the class to test text field.
        Returns:
        the name of the class to test
      • getClassUnderTest

        public IType getClassUnderTest()
        Returns the class to be tested.
        Returns:
        the class under test or null if the entered values are not valid
      • setClassUnderTest

        public void setClassUnderTest​(String name)
        Sets the name of the class under test.
        Parameters:
        name - The name to set
      • createTypeMembers

        protected void createTypeMembers​(IType type,
                                         NewTypeWizardPage.ImportsManager imports,
                                         IProgressMonitor monitor)
                                  throws CoreException
        Description copied from class: NewTypeWizardPage
        Hook method that gets called from createType to support adding of unanticipated methods, fields, and inner types to the created type.

        Implementers can use any methods defined on IType to manipulate the new type.

        The source code of the new type will be formatted using the platform's formatter. Needed imports are added by the wizard at the end of the type creation process using the given import manager.

        Overrides:
        createTypeMembers in class NewTypeWizardPage
        Parameters:
        type - the new type created via createType
        imports - an import manager which can be used to add new imports
        monitor - a progress monitor to report progress. Must not be null
        Throws:
        CoreException - thrown when creation of the type members failed
        See Also:
        NewTypeWizardPage.createType(IProgressMonitor)
      • validateIfJUnitProject

        protected IStatus validateIfJUnitProject()
        The method is called when the container has changed to validate if the project is suited for the JUnit test class. Clients can override to modify or remove that validation.
        Returns:
        the status of the validation
      • superClassChanged

        protected IStatus superClassChanged()
        Description copied from class: NewTypeWizardPage
        Hook method that gets called when the superclass name has changed. The method validates the superclass name and returns the status of the validation.

        Subclasses may extend this method to perform their own validation.

        Overrides:
        superClassChanged in class NewTypeWizardPage
        Returns:
        the status of the validation
      • getJUnit3TestSuperclassName

        protected String getJUnit3TestSuperclassName()
        Hook method that is called to determine the name of the superclass set for a JUnit 3 style test case. By default, the name of the JUnit 3 TestCase class is returned. Implementors can override this behavior to return the name of a subclass instead.
        Returns:
        the fully qualified name of a subclass of the JUnit 3 TestCase class.
        Since:
        3.7