Package org.netbeans.modules.php.api.validation

Examples of org.netbeans.modules.php.api.validation.ValidationResult


        FileObject fuelFile = sourceDirectory.createData("myfuel.php");

        // directory
        FuelPhpCustomizerValidator validator = new FuelPhpCustomizerValidator()
                .validateFuelDirectoryName(sourceDirectory, "myfuel");
        ValidationResult result = validator.getResult();
        assertFalse(result.hasErrors());
        assertFalse(result.hasWarnings());

        // not existing directory
        validator = new FuelPhpCustomizerValidator()
                .validateFuelDirectoryName(sourceDirectory, "something");
        result = validator.getResult();
        assertFalse(result.hasErrors());
        assertTrue(result.hasWarnings());

        // file
        validator = new FuelPhpCustomizerValidator()
                .validateFuelDirectoryName(sourceDirectory, "myfuel.php");
        result = validator.getResult();
        assertFalse(result.hasErrors());
        assertTrue(result.hasWarnings());

    }
View Full Code Here


        FileObject oil = sourceDirectory.createData("oil");

        // directory
        FuelPhpCustomizerValidator validator = new FuelPhpCustomizerValidator()
                .validateOilPath(sourceDirectory);
        ValidationResult result = validator.getResult();
        assertFalse(result.hasErrors());
        assertFalse(result.hasWarnings());
    }
View Full Code Here

        FileObject sourceDirectory = fileSystem.getRoot();
        FileObject oil = sourceDirectory.createFolder("oil");
        // directory
        FuelPhpCustomizerValidator validator = new FuelPhpCustomizerValidator()
                .validateOilPath(sourceDirectory);
        ValidationResult result = validator.getResult();
        assertFalse(result.hasErrors());
        assertTrue(result.hasWarnings());
    }
View Full Code Here

     * Test of validateName method, of class WordPressDirectoryNameValidator.
     */
    @Test
    public void testValidateName() {
        // invalid
        ValidationResult result = new WordPressDirectoryNameValidator()
                .validateName(null)
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("@")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(" ")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("/")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("?")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("<")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(">")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("!")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("\"")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("#")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("$")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("%")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("&")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("'")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("(")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(")")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("=")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("~")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("|")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("\\")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("^")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("`")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("{")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("}")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("[")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("]")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("+")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("*")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(";")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(":")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(",")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("あ")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("日本語")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("ア")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("A")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("test/")
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        // valid
        result = new WordPressDirectoryNameValidator()
                .validateName("a")
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("A")
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("-")
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName(".")
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("_")
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateName("test-child")
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

    }
View Full Code Here

     * WordPressDirectoryNameValidator.
     */
    @Test
    public void testValidateExistingName() {
        // invalid
        ValidationResult result = new WordPressDirectoryNameValidator()
                .validateExistingName("parent", Arrays.asList("parent", "parent2"))
                .getResult();
        Assert.assertTrue(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        // valid
        result = new WordPressDirectoryNameValidator()
                .validateExistingName("child", Arrays.asList("parent", "parent2"))
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());

        result = new WordPressDirectoryNameValidator()
                .validateExistingName("child", Collections.<String>emptyList())
                .getResult();
        Assert.assertFalse(result.hasWarnings());
        Assert.assertFalse(result.hasErrors());
    }
View Full Code Here

        if (descriptor == null || panel == null) {
            return;
        }
        String childThemeName = getPanel().getChildDirectoryName();
        WordPressDirectoryNameValidator validator = new WordPressDirectoryNameValidator();
        ValidationResult result = validator.validateName(childThemeName)
                .validateExistingName(childThemeName, themes)
                .getResult();

        // errors
        List<ValidationResult.Message> errors = result.getErrors();
        if (!errors.isEmpty()) {
            getDescriptor().setValid(false);
            getPanel().setError(result.getErrors().get(0).getMessage());
            return;
        }

        // warnings
        List<ValidationResult.Message> warnings = result.getWarnings();
        if (!warnings.isEmpty()) {
            getDescriptor().setValid(false);
            getPanel().setError(result.getWarnings().get(0).getMessage());
            return;
        }

        // everything ok
        getDescriptor().setValid(true);
View Full Code Here

        FileObject wordPressRoot = null;
        if (sourceDirectory != null) {
            wordPressRoot = sourceDirectory.getFileObject(wordPressRootDirectoryPath);
        }

        ValidationResult result = new WordPressCustomizerValidator()
                .validateWpContent(phpModule, wordPressRoot, contentName)
                .validateWordPressRootDirectory(phpModule, getPanel().getWordPressRootDirectory())
                .validatePluginsDirectory(phpModule, getPanel().getPluginsDirectory())
                .validateThemesDirectory(phpModule, getPanel().getThemesDirectory())
                .getResult();

        if (wordPressRoot != null) {
            ValidationResult wpResult = new WordPressModuleValidator()
                    .validateWordPressDirectories(wordPressRoot, contentName)
                    .getResult();
            result.merge(wpResult);
        }
View Full Code Here

            // auto detection
            FileObject wordPressRoot = phpModule.getSourceDirectory();
            if (wordPressRoot == null) {
                return;
            }
            ValidationResult result = new WordPressModuleValidator()
                    .validateWordPressDirectories(wordPressRoot, WordPressPreferences.getCustomContentName(phpModule))
                    .getResult();
            if (result.hasWarnings()) {
                return;
            }

            // show notification displayer
            if (!WordPressPreferences.isEnabled(phpModule)) {
View Full Code Here

public final class WordPressOptionsValidator {

    private final ValidationResult result;

    public WordPressOptionsValidator() {
        this.result = new ValidationResult();
    }
View Full Code Here

            }
        });
    }

    boolean valid() {
        ValidationResult result = new WordPressOptionsValidator()
                .validate(getWpCliPath())
                .getResult();
        // errors
        if (result.hasErrors()) {
            setError(result.getErrors().get(0).getMessage());
            return false;
        }

        // warnings
        if (result.hasWarnings()) {
            setWarning(result.getWarnings().get(0).getMessage());
            return true;
        }

        // everything ok
        setError(" "); // NOI18N
View Full Code Here

TOP

Related Classes of org.netbeans.modules.php.api.validation.ValidationResult

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.