All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.cpollet.maven.plugins.postman.EnvironmentAdapter Maven / Gradle / Ivy

Go to download

A maven plugin to export JAX-RS annotated classes and methods to Postman collection

The newest version!
package net.cpollet.maven.plugins.postman;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public class EnvironmentAdapter {
    private static final String DEFAULT_NAME = "default";
    private static final String DEFAULT_URL = "http://localhost";

    private final Environment environment;

    public String getBaseUrl() {
        if (environment.getBaseUrl() == null) {
            return DEFAULT_URL;
        }
        return environment.getBaseUrl().toExternalForm();
    }

    public String getName() {
        if (environment.getName() == null || environment.getName().trim().isEmpty()) {
            return DEFAULT_NAME;
        }

        return environment.getName();
    }

    public String getUsername() {
        if (environment.getBasicAuth() == null) {
            return null;
        }

        return environment.getBasicAuth().getUsername();
    }

    public String getPassword() {
        if (environment.getBasicAuth() == null) {
            return null;
        }

        return environment.getBasicAuth().getPassword();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy