/** Refreshes the AutMainList of the Project. */ private void refreshAutMainList() throws ProjectDeletedException { try { GeneralStorage.getInstance() .getMasterSession() .refresh(GeneralStorage.getInstance().getProject().getAutCont()); } catch (EntityNotFoundException enfe) { // Occurs if any Object Mapping information has been deleted while // the Project Properties were being edited. // Refresh the entire master session to ensure that AUT settings // and Object Mappings are in sync GeneralStorage.getInstance().reloadMasterSession(new NullProgressMonitor()); } }
/** * @param ts current testsuite * @return if testsuite meets general requirements for execution */ private boolean areGeneralRequirementsAchieved(ITestSuitePO ts) { Locale workingLanguage = WorkingLanguageBP.getInstance().getWorkingLanguage(); return workingLanguage != null && AutAgentRegistration.getRunningAuts(GeneralStorage.getInstance().getProject(), null) .keySet() .contains(ts.getAut()); }
/** @return the displayable lanugages */ public List<Locale> getDisplayableLanguages() { IProjectPO currentProject = GeneralStorage.getInstance().getProject(); if (currentProject != null) { return currentProject.getLangHelper().getLanguageList(); } List<Locale> emptyList = Collections.emptyList(); return emptyList; }
/** @return current WorkingLanguage or null! */ public Locale getWorkingLanguage() { Locale workingLang = null; IProjectPO project = GeneralStorage.getInstance().getProject(); if (project != null) { workingLang = (m_currentLanguage != null) ? m_currentLanguage : project.getDefaultLanguage(); } return workingLang; }
/** {@inheritDoc} */ public void handleProjectStateChanged(ProjectState state) { if (ProjectState.prop_modified.equals(state)) { List<Locale> langs = GeneralStorage.getInstance().getProject().getLangHelper().getLanguageList(); if (m_currentLanguage != null && !langs.contains(m_currentLanguage)) { m_currentLanguage = null; setCurrentLanguage(getWorkingLanguage()); } } }
/** {@inheritDoc} */ protected IContributionItem[] getContributionItems() { List<IContributionItem> contributionItems = new ArrayList<IContributionItem>(); if (GeneralStorage.getInstance().getProject() != null) { for (AutIdentifier autId : RunningAutBP.getListOfDefinedRunningAuts()) { contributionItems.add(createItem(autId)); } } return contributionItems.toArray(new IContributionItem[contributionItems.size()]); }
/** {@inheritDoc} */ public List<ITestDataCubePO> getAll() { IProjectPO project = GeneralStorage.getInstance().getProject(); // Try to load the Test Suites of the project try { return Arrays.asList(TestDataCubeBP.getAllTestDataCubesFor(project)); } catch (NullPointerException exc) { // That means that there are none so return an empty list return Collections.emptyList(); } }
/** {@inheritDoc} */ public void run(IMarker marker) { INodePO node = NodePM.getNode(GeneralStorage.getInstance().getProject().getId(), m_nodeGUID); if (node != null) { while (!(NodeBP.isEditable(node) && (node instanceof ITestSuitePO || node instanceof ITestJobPO || node instanceof ISpecTestCasePO))) { node = node.getParentNode(); } AbstractOpenHandler.openEditor(node); } }
/** {@inheritDoc} */ public String getText(Object element) { if (element instanceof AutIdentifier) { AutIdentifier autId = ((AutIdentifier) element); IProjectPO currentProject = GeneralStorage.getInstance().getProject(); String displayText = autId.getExecutableName(); if (currentProject != null && AutAgentRegistration.getAutForId(autId, currentProject) != null) { return displayText; } return displayText + " (unknown AUT ID)"; // $NON-NLS-1$ } return super.getText(element); }
/** @return all startable testsuites */ public SortedSet<ITestSuitePO> getAllTestSuites() { SortedSet<ITestSuitePO> testSuites = new TreeSet<ITestSuitePO>(); IProjectPO project = GeneralStorage.getInstance().getProject(); if (project != null) { List<ITestSuitePO> tsInProject = TestSuiteBP.getListOfTestSuites(project); for (ITestSuitePO ts : tsInProject) { if (isTestSuiteStartable(ts)) { testSuites.add(ts); } } } return testSuites; }
@SuppressWarnings("synthetic-access") public void handleDataChanged( IPersistentObject po, DataState dataState, UpdateState updateState) { if (updateState == UpdateState.onlyInEditor) { return; } if (dataState == DataState.Deleted && po instanceof IProjectPO && GeneralStorage.getInstance().getProject() == null) { m_isProjectLoaded = false; m_lastUsedTestSuite = null; m_isAutStarted = false; m_atLeastOneTsAvailable = false; updateTestSuiteButtonState(false); } }
/** {@inheritDoc} */ public void run(IProgressMonitor monitor) { progressMonitor = monitor; IProjectPO project = GeneralStorage.getInstance().getProject(); progressMonitor.setTaskName(Messages.PreparingConvertProjectTaskName); String basePath = genPath + StringConstants.SLASH + genPackage.replace(StringConstants.DOT, StringConstants.SLASH); uuidToNodeInfoMap = new HashMap<String, NodeInfo>(); NodeInfo.setUuidToNodeInfoMap(uuidToNodeInfoMap); projects = new HashSet<IProjectPO>(); workUnits = 0; if (project != null) { defaultToolkit = determineDefaultToolkit(project); addProjectsToConvert(project); try { for (IProjectPO p : projects) { determineClassNamesForProject(p, basePath); } progressMonitor.beginTask(Messages.PreparingConvertProjectTaskName, workUnits); for (IProjectPO p : projects) { progressMonitor.setTaskName(NLS.bind(Messages.ConvertProjectTaskName, p.getName())); handleProject(p, basePath); } } catch (StopConversionException e) { progressMonitor.setCanceled(true); if (!e.wasManuallyTriggered()) { ErrorHandlingUtil.createMessageDialog( new JBException(e.getMessage(), e, MessageIDs.E_CONVERSION_ABORTED_ERROR)); } return; } } progressMonitor.done(); }
/** * Creates a new project, stops a started AUT, closes all opened editors. * * @param newProjectName the name for this project * @param monitor The progress monitor for this potentially long-running operation. * @throws InterruptedException if the operation is canceled. */ private void createNewProject(final String newProjectName, IProgressMonitor monitor) throws InterruptedException { Plugin.closeAllOpenedJubulaEditors(false); m_newProject.setIsReusable(m_projectSettingWizardPage.isProjectReusable()); m_newProject.setIsProtected(m_projectSettingWizardPage.isProjectProtected()); if (m_autMain.getName() == null || StringConstants.EMPTY.equals(m_autMain.getName())) { m_newProject.removeAUTMain(m_autMain); } if (m_autConfig.getName() == null || StringConstants.EMPTY.equals(m_autConfig.getName())) { m_autMain.removeAutConfig(m_autConfig); } ParamNameBPDecorator paramNameMapper = new ParamNameBPDecorator(ParamNameBP.getInstance()); final IWritableComponentNameMapper compNamesMapper = new ProjectComponentNameMapper(new ComponentNamesDecorator(null), m_newProject); List<INameMapper> mapperList = new ArrayList<INameMapper>(); List<IWritableComponentNameMapper> compNameCacheList = new ArrayList<IWritableComponentNameMapper>(); addUnboundModules(m_newProject); mapperList.add(paramNameMapper); compNameCacheList.add(compNamesMapper); try { GeneralStorage.getInstance().reset(); ProjectPM.attachProjectToROSession( m_newProject, newProjectName, mapperList, compNameCacheList, monitor); } catch (PMSaveException e) { PMExceptionHandler.handlePMExceptionForMasterSession( new PMSaveException(e.getMessage(), MessageIDs.E_CREATE_NEW_PROJECT_FAILED)); } catch (PMException e) { PMExceptionHandler.handlePMExceptionForMasterSession(e); } catch (ProjectDeletedException e) { PMExceptionHandler.handleProjectDeletedException(); } catch (InterruptedException ie) { throw ie; } }
/** * clears the content of client * * @param alsoProjectIndependent whether also project independent editors should be closed such as * the testresultviewer */ public static void clearClient(final boolean alsoProjectIndependent) { final DataEventDispatcher ded = DataEventDispatcher.getInstance(); TestExecution.getInstance().stopExecution(); GeneralStorage gs = GeneralStorage.getInstance(); if (gs != null && Persistor.instance() != null) { IProjectPO currProj = gs.getProject(); if (currProj != null) { gs.nullProject(); } gs.reset(); } Plugin.getDisplay() .syncExec( new Runnable() { public void run() { Plugin.clearAllEditorsClipboard(); final ProblemsBP problemsBP = ProblemsBP.getInstance(); problemsBP.clearOldProblems(); problemsBP.cleanupProblems(); TestExecutionContributor.getInstance().getClientTest().resetToTesting(); ded.fireRecordModeStateChanged(RecordModeState.notRunning); ded.fireOMStateChanged(OMState.notRunning); ded.fireProjectStateChanged(ProjectState.closed); Plugin.closeAllOpenedJubulaEditors(alsoProjectIndependent); ded.fireTestresultChanged(TestresultState.Clear); setTreeViewerInputNull(Constants.TESTRE_ID); for (TestCaseBrowser tcb : MultipleTCBTracker.getInstance().getOpenTCBs()) { tcb.getTreeViewer().setInput(null); } setTreeViewerInputNull(Constants.TS_BROWSER_ID); setTreeViewerInputNull(Constants.COMPNAMEBROWSER_ID); clearAnalyzeResultPage(); } }); ded.fireProjectLoadedListener(new NullProgressMonitor()); }
/** {@inheritDoc} */ protected void initPropDescriptor() { if (!getPropertyDescriptorList().isEmpty()) { clearPropertyDescriptors(); } // TestCase Name if (m_namePropDesc == null) { m_namePropDesc = new TextPropertyDescriptor(new ExecNameController(), P_REFERNCE_DISPLAY_NAME); } addPropertyDescriptor(m_namePropDesc); // Specification Name if (m_specNamePropDesc == null) { JBPropertyDescriptor propDes = new JBPropertyDescriptor(new SpecNameController(), P_SPECNAME_DISPLAY_NAME); propDes.setLabelProvider(new DisabledLabelProvider()); m_specNamePropDesc = propDes; } addPropertyDescriptor(m_specNamePropDesc); // Comment if (m_commentPropDesc == null) { m_commentPropDesc = new TextPropertyDescriptor(new CommentController(), P_ELEMENT_DISPLAY_COMMENT); } addPropertyDescriptor(m_commentPropDesc); // Data Source addPropertyDescriptor( getDataSourcePropertyDescr(new ExecTestCaseTestDataSourceController(this))); // External data file if (m_extDataPropDesc == null) { m_extDataPropDesc = new TextPropertyDescriptor(new ExternalDataController(this), P_ELEMENT_DISPLAY_DATEFILE); m_extDataPropDesc.setCategory(P_TESTDATA_CAT); } addPropertyDescriptor(m_extDataPropDesc); // Referenced Test Data Cube if (m_referencedCubePropDesc == null) { IProjectPO activeProject = GeneralStorage.getInstance().getProject(); IContentProposalProvider dataCubeRefProposalProvider = null; IValidator dataCubeRefValidator = null; if (activeProject != null) { dataCubeRefProposalProvider = new TestDataCubeRefContentProposalProvider( activeProject, (IParameterInterfacePO) getPoNode()); dataCubeRefValidator = new TestDataCubeReferenceValidator(activeProject); } m_referencedCubePropDesc = new ContentAssistedTextPropertyDescriptor( new ReferenceTestDataController(this), P_ELEMENT_DISPLAY_REFDATA, dataCubeRefProposalProvider, dataCubeRefValidator, ContentProposalAdapter.PROPOSAL_REPLACE); m_referencedCubePropDesc.setCategory(P_TESTDATA_CAT); } addPropertyDescriptor(m_referencedCubePropDesc); // Parameters addPropertyDescriptor(createParamDescriptors()); }
/** {@inheritDoc} */ public boolean performOk() { try { if (!m_oldProjectName.equals(m_newProjectName)) { if (ProjectPM.doesProjectNameExist(m_newProjectName)) { ErrorHandlingUtil.createMessageDialog( MessageIDs.E_PROJECTNAME_ALREADY_EXISTS, new Object[] {m_newProjectName}, null); return false; } } if (m_isReusableCheckbox != null) { getProject().setIsReusable(m_isReusableCheckbox.getSelection()); } if (m_isProtectedCheckbox != null) { getProject().setIsProtected(m_isProtectedCheckbox.getSelection()); } storeAutoTestResultCleanup(); if (!m_oldProjectName.equals(m_newProjectName)) { ProjectNameBP.getInstance() .setName(getEditSupport().getSession(), getProject().getGuid(), m_newProjectName); } fireOkPressed(); Set<IReusedProjectPO> origReused = ((IProjectPropertiesPO) getEditSupport().getOriginal()).getUsedProjects(); Set<IReusedProjectPO> newReused = new HashSet<IReusedProjectPO>( ((IProjectPropertiesPO) getEditSupport().getWorkVersion()).getUsedProjects()); newReused.removeAll(origReused); getEditSupport().saveWorkVersion(); refreshAutMainList(); DataEventDispatcher.getInstance().fireProjectStateChanged(ProjectState.prop_modified); for (IReusedProjectPO reused : newReused) { try { IProjectPO reusedProject = ProjectPM.loadReusedProject(reused); if (reusedProject != null) { // incomplete database, see https://bxapps.bredex.de/bugzilla/show_bug.cgi?id=854 ComponentNamesBP.getInstance().refreshNames(reusedProject.getId()); } } catch (JBException e) { // Could not refresh Component Name information for // reused project. Log the exception. log.error(Messages.ErrorWhileRetrievingReusedProjectInformation, e); } } // FIXME zeb This updates the Test Case Browser. Once we have separate // EditSupports for each property page, then we can use // "real" ReusedProjectPOs instead of a placeholder. DataEventDispatcher.getInstance() .fireDataChangedListener( PoMaker.createReusedProjectPO("1", 1, 1), // $NON-NLS-1$ DataState.ReuseChanged, UpdateState.notInEditor); DataEventDispatcher.getInstance() .fireDataChangedListener( GeneralStorage.getInstance().getProject(), DataState.Renamed, UpdateState.notInEditor); CompletenessBP.getInstance().completeProjectCheck(); } catch (PMException e) { ErrorHandlingUtil.createMessageDialog(e, null, null); } catch (ProjectDeletedException e) { PMExceptionHandler.handleProjectDeletedException(); } catch (IncompatibleTypeException ite) { ErrorHandlingUtil.createMessageDialog(ite, ite.getErrorMessageParams(), null); } return true; }
/** * This validator checks a list of Test Cases before it can be used to change the CTDS column usage. * * @author BREDEX GmbH */ public class TestCasesValidator { /** The current project ID. */ private Long m_projectId = GeneralStorage.getInstance().getProject().getId(); /** * True, if all Test Cases are using the same Central Test Data Set and this Central Test Data Set * has got one or more columns, otherwise false. */ private boolean m_isReferencedCtdsOk = false; /** The list of referenced Test Cases with different CTDS. */ private List<IExecTestCasePO> m_execsWithDifferentCTDS = new ArrayList<IExecTestCasePO>(); /** The list of Test Cases with a specification not defined in the current project. */ private List<ITestCasePO> m_testCasesWithSpecNotDefinedInCurrentProject = new ArrayList<ITestCasePO>(); /** The list of valid Test Cases. */ private List<ITestCasePO> m_validTestCases = new ArrayList<ITestCasePO>(); /** * Creates the distinct invalid and valid lists from the given list of Test Cases. * * @param testCases The list of Test Cases to check. * @see #getExecsWithDifferentCTDS() * @see #getTCsWithSpecNotDefinedInCurrentProject() * @see #getValidTestCases() */ public TestCasesValidator(Collection<ITestCasePO> testCases) { IParameterInterfacePO dataCube = null; for (ITestCasePO testCase : testCases) { IParameterInterfacePO currentDataCube = testCase.getReferencedDataCube(); if (dataCube == null && currentDataCube != null) { dataCube = currentDataCube; if (dataCube.getParameterListSize() == 0) { return; } } else if (currentDataCube == null || !dataCube.equals(currentDataCube)) { return; } boolean isValid = false; if (testCase instanceof IExecTestCasePO) { IExecTestCasePO exec = (IExecTestCasePO) testCase; isValid = checkSpecDefinedInCurrentProject(exec) && checkHasOnlyOneCTDS(exec); } else { // should be a specification Test Case ISpecTestCasePO spec = (ISpecTestCasePO) testCase; isValid = checkSpecDefinedInCurrentProject(spec); } if (isValid) { m_validTestCases.add(testCase); } } m_isReferencedCtdsOk = true; } /** * @return True, if all Test Cases are using the same Central Test Data Set and this Central Test * Data Set has got one or more columns, otherwise false. */ public boolean isReferencedDataCubeOk() { return m_isReferencedCtdsOk; } /** * Add invalid Test Case automatically to list returned by {@link * #getTCsWithSpecNotDefinedInCurrentProject()}. * * @param exec The execution Test Case. * @return True, if the specification Test Case of the given execution Test Case is defined in the * current project, otherwise false. */ private boolean checkSpecDefinedInCurrentProject(IExecTestCasePO exec) { if (m_projectId.equals(exec.getSpecTestCase().getParentProjectId())) { return true; } m_testCasesWithSpecNotDefinedInCurrentProject.add(exec); return false; } /** * Add invalid Test Case automatically to list returned by {@link * #getTCsWithSpecNotDefinedInCurrentProject()}. * * @param spec The specification Test Case. * @return True, if the specification Test Case is defined in the current project, otherwise * false. */ private boolean checkSpecDefinedInCurrentProject(ISpecTestCasePO spec) { if (m_projectId.equals(spec.getParentProjectId())) { return true; } m_testCasesWithSpecNotDefinedInCurrentProject.add(spec); return false; } /** @return The list of Test Cases with a specification not defined in the current project. */ public List<ITestCasePO> getTCsWithSpecNotDefinedInCurrentProject() { return m_testCasesWithSpecNotDefinedInCurrentProject; } /** * Add invalid Test Case automatically to list returned by {@link #getExecsWithDifferentCTDS()}. * * @param exec The execution Test Case to check. * @return True, if the specification Test Case has no CTDS, or it is the same as the CTDS at the * execution Test Case. */ private boolean checkHasOnlyOneCTDS(IExecTestCasePO exec) { if (exec.getSpecTestCase().getReferencedDataCube() == null || exec.getReferencedDataCube() == exec.getSpecTestCase().getReferencedDataCube()) { return true; } m_execsWithDifferentCTDS.add(exec); return false; } /** @return The list of execution Test Cases with different CTDS. */ public List<IExecTestCasePO> getExecsWithDifferentCTDS() { return m_execsWithDifferentCTDS; } /** * @return True, if all invalid lists are empty, otherwise false. A Test Case is invalid, if the * specification Test Case is not defined in the current project or if the specification of a * referenced Test Case use a different CTDS. */ public boolean areAllTestCasesOk() { return m_testCasesWithSpecNotDefinedInCurrentProject.isEmpty() && m_execsWithDifferentCTDS.isEmpty(); } /** @return The list of valid Test Cases. */ public List<ITestCasePO> getInvalidTestCases() { List<ITestCasePO> testCases = new ArrayList<ITestCasePO>(); testCases.addAll(m_testCasesWithSpecNotDefinedInCurrentProject); testCases.addAll(m_execsWithDifferentCTDS); return testCases; } /** @return The list of valid Test Cases. */ public List<ITestCasePO> getValidTestCases() { return m_validTestCases; } }