Java Code Examples for io.fabric8.utils.Strings#notEmpty()

The following examples show how to use io.fabric8.utils.Strings#notEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PomHelperTest.java    From updatebot with Apache License 2.0 6 votes vote down vote up
protected static void assertPluginVersionChanged(File file, Document doc, DependencyVersionChange change) {
    boolean found = false;
    List<Element> elements = findElementsWithName(doc.getRootElement(), "plugin");
    for (Element element : elements) {
        String groupId = firstChildTextContent(element, "groupId");
        String artifactId = firstChildTextContent(element, "artifactId");
        String version = firstChildTextContent(element, "version");
        if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
            if (change.matches(groupId, artifactId)) {
                found = true;
                if (!version.startsWith("$")) {
                    LOG.info("File " + file + " has plugin " + change.getDependency() + " version: " + version);
                    assertThat(version).describedAs("File " + file + " plugin version for " + change.getDependency()).isEqualTo(change.getVersion());
                }
            }
        }
    }
    assertThat(found).describedAs("File " + file + " does not have plugin " +
            change.getDependency() + " version: " + change.getVersion()).isTrue();
}
 
Example 2
Source File: PomHelperTest.java    From updatebot with Apache License 2.0 6 votes vote down vote up
protected static void assertDependencyVersionChanged(File file, Document doc, DependencyVersionChange change) {
        boolean found = false;
        List<Element> elements = findElementsWithName(doc.getRootElement(), "dependency");
        for (Element element : elements) {
            String groupId = firstChildTextContent(element, "groupId");
            String artifactId = firstChildTextContent(element, "artifactId");
            String version = firstChildTextContent(element, "version");
            if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
                if (change.matches(groupId, artifactId)) {
                    found = true;
                    if (!version.startsWith("$")) {
                        LOG.info("File " + file + " has dependency " + change.getDependency() + " version: " + version);
                        assertThat(version).describedAs("File " + file + " dependency version for " + change.getDependency()).isEqualTo(change.getVersion());
                    }
                }
            }
        }
/*
        assertThat(found).describedAs("File " + file + " does not have dependency " +
                change.getDependency() + " version: " + change.getVersion()).isTrue();
*/
    }
 
Example 3
Source File: GitHelper.java    From updatebot with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the repository string split its organisation and name
 */
public static GitRepositoryInfo parseRepository(String orgAndRepoName, String host) {
    if (Strings.notEmpty(orgAndRepoName)) {
        String[] paths = orgAndRepoName.split("/", 2);
        if (paths.length > 1) {
            return new GitRepositoryInfo(host, paths[0], paths[1]);
        }
    }
    return null;
}
 
Example 4
Source File: GitPlugin.java    From updatebot with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if the given directory has modified files
 */
static boolean hasChangedFiles(File dir) {
    try {
        String output = ProcessHelper.runCommandCaptureOutput(dir, "git", "status", "-s");
        if (output != null) {
            output = output.trim();
        }
        return Strings.notEmpty(output);
    } catch (IOException e) {
        return false;
    }
}
 
Example 5
Source File: ProcessHelper.java    From updatebot with Apache License 2.0 5 votes vote down vote up
protected static void logOutput(String output, boolean error) {
    if (Strings.notEmpty(output)) {
        String[] lines = output.split("\n");
        for (String line : lines) {
            if (error) {
                LOG.error(line);
            } else {
                LOG.info(line);
            }
        }
    }
}
 
Example 6
Source File: ProcessHelper.java    From updatebot with Apache License 2.0 5 votes vote down vote up
protected static void logOutput(Configuration configuration, Logger log, String output, boolean error) {
    if (Strings.notEmpty(output)) {
        String[] lines = output.split("\n");
        for (String line : lines) {
            if (error) {
                configuration.error(log, line);
            } else {
                configuration.info(log, line);
            }
        }
    }
}