Package org.geotools.validation.dto

Examples of org.geotools.validation.dto.TestSuiteDTO


            } catch (FileNotFoundException e3) {
                MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),Messages.ValidationDialog_fileNotFound, e3.toString());
                ValidationPlugin.log(e3.toString()); //log the error, but don't throw the exception
                return;
            }
            TestSuiteDTO newDTO;
            try {
                newDTO = XMLReader.readTestSuite(fileName, reader, processor.getPluginDTOs());
            } catch (ValidationException e3) {
                String errorMsg = e3.toString();
                MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),"Exception Occurred", errorMsg); //$NON-NLS-1$
                ValidationPlugin.log(errorMsg, e3);
                return;
            }
            try {
                reader.close();
            } catch (IOException e2) {
                MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),"Exception Occurred", e2.toString()); //$NON-NLS-1$
                ValidationPlugin.log(e2.toString(), e2);
                return;
            }
            //get the existing testSuites
            Map<String, TestSuiteDTO> suites = processor.getTestSuiteDTOs();
            //ensure there is at least one test in the new testSuite
            if (newDTO.getTests().size() == 0) {
                //nothing to see here, move along
                return;
            }
            //if no testSuites exist, just copy the new one directly in
            if (suites.size() == 0) {
                suites.put(newDTO.getName(), newDTO);                       
                defaultTestSuite = newDTO.getName();
            //does the testSuite exist? if so, add the new tests to the existing one
            } else if (suites.containsKey(newDTO.getName())) {
                //ensure the current testSuite is selected
                defaultTestSuite = newDTO.getName();
                //get the existing testSuite
                TestSuiteDTO testSuite = (TestSuiteDTO) suites.get(defaultTestSuite);
                //move the tests to the existing testSuite
                testSuite = processor.moveTests(testSuite, newDTO.getTests(), false);
                suites.put(defaultTestSuite, testSuite); //overwrite the suite
            //a test Suite exists, but it isn't this one; put the new tests into the existing testSuite
            } else {
                TestSuiteDTO testSuite = (TestSuiteDTO) suites.get(defaultTestSuite);
                Map<String, TestDTO> tests = newDTO.getTests();
                testSuite = processor.moveTests(testSuite, tests, false);
                suites.put(defaultTestSuite, testSuite); //overwrite the suite with new map of tests
            }
            //do multiple testSuites exist? if so, merge them
            while (suites.size() > 1) {
                //find the first testSuite which isn't the defaultTestSuite
                Object key = null;
                for (Iterator i = suites.keySet().iterator(); i.hasNext();) {
                    Object thisKey = i.next();
                    if (!(thisKey.equals(defaultTestSuite))) {
                        key = thisKey;
                        break;
                    }
                }
                if (key != null) {
                    TestSuiteDTO alphaSuite = (TestSuiteDTO) suites.get(defaultTestSuite);
                    TestSuiteDTO betaSuite = (TestSuiteDTO) suites.get(key);
                    alphaSuite = processor.moveTests(alphaSuite, betaSuite.getTests(), false);
                    suites.remove(key); //bye betaSuite!
                    suites.put(defaultTestSuite, alphaSuite); //overwrite the suite (alphaSuite has now assimilated betaSuite)
                }
            }
            //all done; save the Map of testSuites and refresh the Tree
View Full Code Here


            Display display = Display.getCurrent();
            if (display == null) { // not on the ui thread?
                display = Display.getDefault();
            }
            //grab the testSuite we want to save
            TestSuiteDTO testSuite = (TestSuiteDTO) processor.getTestSuiteDTOs().get(defaultTestSuite);
            //testSuite is empty?
            if (testSuite.getTests().size() == 0) {
                MessageBox mb = new MessageBox( display.getActiveShell(), SWT.ICON_ERROR  | SWT.OK);
                mb.setMessage(Messages.ValidationDialog_noSuitePre+defaultTestSuite+Messages.ValidationDialog_noSuiteSuf)
                mb.open();
                return;
            }
View Full Code Here

      if (fileExists) {
            testSuiteDTOs = XMLReader.loadValidations(testSuiteFile, pluginDTOs);
        } else {
          //construct a map for DTO testSuites (empty)
          testSuiteDTOs = new HashMap<String, TestSuiteDTO>();
           TestSuiteDTO testSuite1 = new TestSuiteDTO();
           testSuite1.setName("testSuite1"); //$NON-NLS-1$
           testSuite1.setDescription(""); //$NON-NLS-1$
           //create an empty map of tests (required!)
           Map emptyTestsMap = new HashMap();
           testSuite1.setTests(emptyTestsMap);
           //store it
           testSuiteDTOs.put("testSuite1", testSuite1); //$NON-NLS-1$
        }
        //save the plugins and testSuites for future use
        this.pluginDTOs = pluginDTOs;
View Full Code Here

    //remove from all testSuites
    Map oldTests;
    Map newTests; // = new HashMap();
    //for each testSuite
    for (Iterator i = testSuiteDTOs.keySet().iterator(); i.hasNext();) {
      TestSuiteDTO testSuite = (TestSuiteDTO) testSuiteDTOs.get(i.next());
      oldTests = testSuite.getTests();
      newTests = new HashMap(testSuite.getTests()); //create a new copy of the object, so we can modify it
      //for each test
      for (Iterator j = ((HashMap) oldTests).keySet().iterator(); j.hasNext();) {
        Object testKey = j.next();
        TestDTO currentTest = (TestDTO) oldTests.get(testKey);
        if (currentTest.equals(test)) {
          newTests.remove(testKey); //this is the test we want to delete
        }
      }
      testSuite.setTests(newTests); //save the modified map of tests in the testSuite
    }
  }
View Full Code Here

   */
  public Map getTests() {
    Map<String, TestDTO> testMap = new HashMap<String, TestDTO>();
    //for each testSuite
    for (Iterator i = testSuiteDTOs.keySet().iterator(); i.hasNext();) {
      TestSuiteDTO testSuite = (TestSuiteDTO) testSuiteDTOs.get(i.next());
      //for each test
      for (Iterator j = ((HashMap) testSuite.getTests()).keySet().iterator(); j.hasNext();) {
        TestDTO currentTest = (TestDTO) testSuite.getTests().get(j.next());
        testMap.put(currentTest.getName(), currentTest);
      }
    }
    return testMap;
  }
View Full Code Here

   */
  public Object[] getTests(Object plugin) {
    Set<TestDTO> testSet = new HashSet<TestDTO>();
    //for each testSuite
    for (Iterator i = testSuiteDTOs.keySet().iterator(); i.hasNext();) {
      TestSuiteDTO testSuite = (TestSuiteDTO) testSuiteDTOs.get(i.next());
      //for each test
      for (Iterator j = ((HashMap) testSuite.getTests()).keySet().iterator(); j.hasNext();) {
        TestDTO currentTest = (TestDTO) testSuite.getTests().get(j.next());
        PlugInDTO thisPlugin = (PlugInDTO) plugin;
        // matching plugin?
        if (currentTest.getPlugIn().equals(thisPlugin)) {
          testSet.add(currentTest);
        }
View Full Code Here

   *
   * @param testSuiteKey
   * @return
   */
  public boolean testsExist(Object testSuiteKey) {
    TestSuiteDTO testSuite = (TestSuiteDTO) testSuiteDTOs.get(testSuiteKey);
    if (testSuite.getTests().size() > 0) return true;
    else return false;
  }
View Full Code Here

        // step 1 make a list required plug-ins
        Set plugInNames = new HashSet();
        Iterator i = testSuites.keySet().iterator();

        while (i.hasNext()) {
            TestSuiteDTO dto = (TestSuiteDTO) testSuites.get(i.next());
            Iterator j = dto.getTests().keySet().iterator();

            while (j.hasNext()) {
                TestDTO tdto = (TestDTO) dto.getTests().get(j.next());
                plugInNames.add(tdto.getPlugIn().getName());
            }
        }

        // Mark all plug-ins as not loaded
        //
        i = plugIns.values().iterator();

        while (i.hasNext()) {
            PlugInDTO dto = (PlugInDTO) i.next();
            errors.put(dto, Boolean.FALSE);
        }

        // step 2 configure plug-ins with defaults
        Map defaultPlugIns = new HashMap(plugInNames.size());
        i = plugInNames.iterator();

        while (i.hasNext()) {
            String plugInName = (String) i.next();
            PlugInDTO dto = (PlugInDTO) plugIns.get(plugInName);
            Class plugInClass = null;

            try {
                plugInClass = Class.forName(dto.getClassName());
            } catch (ClassNotFoundException e) {
                //Error, using default.
                errors.put(dto, e);
                e.printStackTrace();
            }

            if (plugInClass == null) {
                plugInClass = Validation.class;
            }

            Map plugInArgs = dto.getArgs();

            if (plugInArgs == null) {
                plugInArgs = new HashMap();
            }

            try {
                PlugIn plugIn = new org.geotools.validation.PlugIn(plugInName, plugInClass,
                        dto.getDescription(), plugInArgs);
                defaultPlugIns.put(plugInName, plugIn);
            } catch (ValidationException e) {
                e.printStackTrace();
                // Update dto entry w/ an error?
                errors.put(dto, e);

                continue;
            }

            // mark dto entry as a success
            errors.put(dto, Boolean.TRUE);
        }

        // step 3 configure plug-ins with tests + add to processor
        i = testSuites.keySet().iterator();

        while (i.hasNext()) {
            TestSuiteDTO tdto = (TestSuiteDTO) testSuites.get(i.next());
            Iterator j = tdto.getTests().keySet().iterator();

            while (j.hasNext()) {
                TestDTO dto = (TestDTO) tdto.getTests().get(j.next());

                // deal with test
                Map testArgs = dto.getArgs();

                if (testArgs == null) {
View Full Code Here

        }

        i = testSuites.keySet().iterator();

        while (i.hasNext()) {
            TestSuiteDTO dto = (TestSuiteDTO) testSuites.get(i.next());
            TestSuiteConfig config = new TestSuiteConfig(dto, this.plugIns);
            this.testSuites.put(config.getName(), config);
        }
    }
View Full Code Here

        }

        i = this.testSuites.keySet().iterator();

        while (i.hasNext()) {
            TestSuiteDTO dto = ((TestSuiteConfig) this.testSuites.get(i.next())).toDTO(plugIns);
            testSuites.put(dto.getName(), dto);
        }

        return true;
    }
View Full Code Here

TOP

Related Classes of org.geotools.validation.dto.TestSuiteDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.