New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor toString() for DefaultConfiguration and CubeOpenShiftConfiguration #1018

Closed
dipak-pawar opened this Issue Mar 22, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@dipak-pawar
Contributor

dipak-pawar commented Mar 22, 2018

Currently there is lot of duplications in toString() method from DefaultConfiguration and CubeOpenShiftConfiguration.

 public String toString() {

        String lineSeparator = System.lineSeparator();
        StringBuilder content = new StringBuilder();

        content.append("CubeKubernetesConfiguration: ").append(lineSeparator);
        if (namespace != null) {
            content.append("  ").append(NAMESPACE).append(" = ").append(namespace).append(lineSeparator);
        }
        if (masterUrl != null) {
            content.append("  ").append(MASTER_URL).append(" = ").append(masterUrl).append(lineSeparator);
        }
        if (scriptEnvironmentVariables != null) {
            content.append("  ").append(ENVIRONMENT_SCRIPT_ENV).append(" = ").append(scriptEnvironmentVariables).append(lineSeparator);
        }
        if (environmentSetupScriptUrl != null) {
            content.append("  ").append(ENVIRONMENT_SETUP_SCRIPT_URL).append(" = ").append(environmentSetupScriptUrl).append(lineSeparator);
        }

        if (environmentTeardownScriptUrl != null) {
            content.append("  ").append(ENVIRONMENT_TEARDOWN_SCRIPT_URL).append(" = ").append(environmentTeardownScriptUrl).append(lineSeparator);
        }
        if (environmentConfigUrl != null) {
            content.append("  ").append(ENVIRONMENT_CONFIG_URL).append(" = ").append(environmentConfigUrl).append(lineSeparator);
        }
        if (environmentDependencies != null) {
            content.append("  ").append(ENVIRONMENT_DEPENDENCIES).append(" = ").append(environmentDependencies).append(lineSeparator);
        }

        content.append("  ").append(NAMESPACE_LAZY_CREATE_ENABLED).append(" = ").append(namespaceLazyCreateEnabled).append(lineSeparator);

        content.append("  ").append(NAMESPACE_CLEANUP_ENABLED).append(" = ").append(namespaceCleanupEnabled).append(lineSeparator);
        content.append("  ").append(NAMESPACE_CLEANUP_TIMEOUT).append(" = ").append(namespaceCleanupTimeout).append(lineSeparator);
        content.append("  ").append(NAMESPACE_CLEANUP_CONFIRM_ENABLED).append(" = ").append(namespaceCleanupConfirmationEnabled).append(lineSeparator);

        content.append("  ").append(NAMESPACE_DESTROY_ENABLED).append(" = ").append(namespaceDestroyEnabled).append(lineSeparator);
        content.append("  ").append(NAMESPACE_DESTROY_CONFIRM_ENABLED).append(" = ").append(namespaceDestroyConfirmationEnabled).append(lineSeparator);
        content.append("  ").append(NAMESPACE_DESTROY_TIMEOUT).append(" = ").append(namespaceDestroyTimeout).append(lineSeparator);

        content.append("  ").append(WAIT_ENABLED).append(" = ").append(waitEnabled).append(lineSeparator);
        content.append("  ").append(WAIT_TIMEOUT).append(" = ").append(waitTimeout).append(lineSeparator);
        content.append("  ").append(WAIT_POLL_INTERVAL).append(" = ").append(waitPollInterval).append(lineSeparator);

        content.append("  ").append(ANSI_LOGGER_ENABLED).append(" = ").append(ansiLoggerEnabled).append(lineSeparator);
        content.append("  ").append(ENVIRONMENT_INIT_ENABLED).append(" = ").append(environmentInitEnabled).append(lineSeparator);
        content.append("  ").append(LOGS_COPY).append(" = ").append(logCopyEnabled).append(lineSeparator);


        if (waitForServiceList != null) {
            content.append("  ").append(WAIT_FOR_SERVICE_LIST).append(" = ").append(waitForServiceList).append(lineSeparator);
        }
        if (logPath != null) {
            content.append("  ").append(LOGS_PATH).append(" = ").append(logPath).append(lineSeparator);
        }
        if (kubernetesDomain != null) {
            content.append("  ").append(KUBERNETES_DOMAIN).append(" = ").append(kubernetesDomain).append(lineSeparator);

        }

        if (dockerRegistry != null) {
            content.append("  ").append(DOCKER_REGISTY).append(" = ").append(dockerRegistry).append(lineSeparator);
        }
        if (apiVersion != null) {
            content.append("  ").append(API_VERSION).append(" = ").append(apiVersion).append(lineSeparator);
        }

        if (username != null) {
            content.append("  ").append(USERNAME).append(" = ").append(username).append(lineSeparator);
        }
        if (password != null) {
            content.append("  ").append(PASSWORD).append(" = ").append(password).append(lineSeparator);
        }

        if (token != null) {
            content.append("  ").append(AUTH_TOKEN).append(" = ").append(token).append(lineSeparator);
        }
        content.append("  ").append(TRUST_CERTS).append(" = ").append(trustCerts).append(lineSeparator);

        return content.toString();
    }

Found all list and map elements (waitForServiceList, environmentDependencies, scriptEnvironmentVariables) are checking != null, but in general they are initializing to empty list and empty map, Update logic for all list and map variables for !isEmpty()

@dipak-pawar dipak-pawar self-assigned this Mar 22, 2018

dipak-pawar added a commit to dipak-pawar/arquillian-cube that referenced this issue Mar 22, 2018

dipak-pawar added a commit to dipak-pawar/arquillian-cube that referenced this issue Mar 28, 2018

dipak-pawar added a commit that referenced this issue Mar 28, 2018

@dipak-pawar dipak-pawar added this to the 1.15.3 milestone Apr 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment