Skip to content
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

added missing javadoc and fixed checkstyle errors #51

Merged
merged 1 commit into from
Jun 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
import com.epam.wilma.mock.util.UrlBuilderUtils;
import com.google.common.base.Optional;

/**
* Collects the Wilma server related commands.
*
* @author Tamas_Pinter
*
*/
public class WilmaApplication {
private static final Logger LOG = LoggerFactory.getLogger(WilmaApplication.class);

Expand All @@ -41,16 +47,32 @@ public class WilmaApplication {
private WilmaHttpClient wilmaClient;
private WilmaMockConfig config;

/**
* Constructor.
*
* @param config the Wilma server configuration
*/
public WilmaApplication(WilmaMockConfig config) {
this(config, null);
}

/**
* Constructor.
*
* @param config the Wilma server configuration
* @param client the Wilma http client
*/
public WilmaApplication(WilmaMockConfig config, WilmaHttpClient client) {
checkArgument(config != null, "config must not be null!");
this.config = config;
this.wilmaClient = client == null ? new WilmaHttpClient() : client;
}

/**
* Gets the actual load information of the application.
*
* @return actual load information
*/
public JSONObject getActualLoadInformation() {
LOG.debug("Call actual load information API.");

Expand All @@ -63,6 +85,11 @@ public JSONObject getActualLoadInformation() {
: EMPTY_JSON;
}

/**
* Shutdown the Wilma application.
*
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
*/
public boolean shutdownApplication() {
LOG.debug("Call application shutdown API.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
import com.epam.wilma.mock.domain.WilmaMockConfig;
import com.epam.wilma.mock.resource.Upload;

/**
* The main class of Wilma mock project.
*
* @author Tamas_Pinter
*
*/
public final class WilmaMock {
private static final Logger LOG = LoggerFactory.getLogger(WilmaMock.class);

Expand All @@ -55,6 +61,19 @@ public final class WilmaMock {
private StubConfiguration stubConfiguration;
private Upload fileUpload;

/**
* Constructor.<br>
* The given properties object has to contain the Wilma server
* configuration:
* <ul>
* <li>
* <b>wilma.host</b>: the Wilma server host</li>
* <li>
* <b>wilma.port</b>: the Wilma server port</li>
* </ul>
*
* @param properties the Wilma server configuration
*/
public WilmaMock(Properties properties) {
LOG.debug("Initialize Wilma mock.");

Expand Down Expand Up @@ -170,7 +189,8 @@ public JSONObject getStubConfigInformation() {
}

/**
*
* Enable/disable the given group.
*
* @param groupName name of the stub configuration group
* @param status the new status
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
import com.epam.wilma.mock.util.UrlBuilderUtils;
import com.google.common.base.Optional;

/**
* Abstract class for Wilma configuration related commands.
*
* @author Tamas_Pinter
*
*/
public abstract class AbstractConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(AbstractConfiguration.class);

Expand All @@ -40,18 +46,37 @@ public abstract class AbstractConfiguration {
private WilmaHttpClient wilmaClient;
private WilmaMockConfig config;

/**
* Constructor.
*
* @param config the Wilma server configuration
*/
public AbstractConfiguration(WilmaMockConfig config) {
this(config, null);
}

/**
* Constructor.
*
* @param config the Wilma server configuration
* @param client the Wilma HTTP client
*/
public AbstractConfiguration(WilmaMockConfig config, WilmaHttpClient client) {
checkArgument(config != null, "config must not be null!");
this.config = config;
this.wilmaClient = client == null ? new WilmaHttpClient() : client;
}

protected JSONObject getterRequest(String prefix) {
String url = buildUrl(prefix, null);
/**
* Calls Wilma server via Wilma HTTP client with URL build from the given
* postfix and Wilma configuration. Returns the requested information in
* JSONObject.
*
* @param postfix the URL postfix
* @return the requested information in JSONObject
*/
protected JSONObject getterRequest(String postfix) {
String url = buildUrl(postfix, null);

LOG.debug("Send getter request to: " + url);
Optional<String> response = wilmaClient.sendGetterRequest(url);
Expand All @@ -60,8 +85,17 @@ protected JSONObject getterRequest(String prefix) {
: EMPTY_JSON;
}

protected JSONObject getterRequest(String prefix, Map<String, String> params) {
String url = buildUrl(prefix, params);
/**
* Calls Wilma server via Wilma HTTP client with URL build from the given
* postfix, parameters and Wilma configuration. Returns the requested
* information in JSONObject.
*
* @param postfix the URL postfix
* @param params the URL parameters
* @return the requested information in JSONObject
*/
protected JSONObject getterRequest(String postfix, Map<String, String> params) {
String url = buildUrl(postfix, params);

LOG.debug("Send getter request to: " + url);
Optional<String> response = wilmaClient.sendGetterRequest(url);
Expand All @@ -70,13 +104,30 @@ protected JSONObject getterRequest(String prefix, Map<String, String> params) {
: EMPTY_JSON;
}

/**
* Calls Wilma server via Wilma HTTP client with URL build from the given
* postfix and Wilma configuration. Returns <tt>true</tt> if the request was
* successful, otherwise returns <tt>false</tt>.
*
* @param postfix the URL postfix
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
*/
protected boolean setterRequest(String postfix) {
String url = buildUrl(postfix, null);

LOG.debug("Send setter request to: " + url);
return wilmaClient.sendSetterRequest(url);
}

/**
* Calls Wilma server via Wilma HTTP client with URL build from the given
* postfix, parameters and Wilma configuration. Returns <tt>true</tt> if the
* request was successful, otherwise returns <tt>false</tt>.
*
* @param postfix the URL postfix
* @param params the URL parameters
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
*/
protected boolean setterRequest(String postfix, Map<String, String> params) {
String url = buildUrl(postfix, params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,54 @@
import com.epam.wilma.mock.domain.WilmaMockConfig;
import com.epam.wilma.mock.http.WilmaHttpClient;

/**
* Collects the localhost blocking configuration related commands.
*
* @author Tamas_Pinter
*
*/
public class LocalhostBlockingConfiguration extends AbstractConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(LocalhostBlockingConfiguration.class);

private static final String STATUS_GETTER_URL_POSTFIX = "config/public/localhost/status";
private static final String STATUS_SETTER_URL_POSTFIX_FORMAT = "config/admin/localhost/%s";

/**
* Constructor.
*
* @param config the Wilma server configuration
*/
public LocalhostBlockingConfiguration(WilmaMockConfig config) {
super(config);
}

/**
* Constructor.
*
* @param config the Wilma server configuration
* @param client the Wilma HTTP client
*/
public LocalhostBlockingConfiguration(WilmaMockConfig config, WilmaHttpClient client) {
super(config, client);
}


/**
* Gets the localhost blocking status.
*
* @return localhost blocking status in JSONObject
*/
public JSONObject getLocalhostBlockingStatus() {
LOG.debug("Call localhost blocking status API.");

return getterRequest(STATUS_GETTER_URL_POSTFIX);
}

/**
* Sets the localhost blocking status.
*
* @param control the new blocking status
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
*/
public boolean setLocalhostBlockingStatus(LocalhostControl control) {
LOG.debug("Call localhost blocking setter API with value: " + control);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,54 @@
import com.epam.wilma.mock.domain.WilmaMockConfig;
import com.epam.wilma.mock.http.WilmaHttpClient;

/**
* Collects the message logging configuration related commands.
*
* @author Tamas_Pinter
*
*/
public class MessageLoggingConfiguration extends AbstractConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(MessageLoggingConfiguration.class);

private static final String STATUS_GETTER_URL_POSTFIX = "config/public/logging/status";
private static final String STATUS_SETTER_URL_POSTFIX_FORMAT = "config/admin/logging/%s";

/**
* Constructor.
*
* @param config the Wilma server configuration
*/
public MessageLoggingConfiguration(WilmaMockConfig config) {
super(config);
}

/**
* Constructor.
*
* @param config the Wilma server configuration
* @param client the Wilma HTTP client
*/
public MessageLoggingConfiguration(WilmaMockConfig config, WilmaHttpClient client) {
super(config, client);
}

/**
* Gets the message logging status.
*
* @return message logging status in JSONObject
*/
public JSONObject getMessageLoggingStatus() {
LOG.debug("Call message logging status API.");

return getterRequest(STATUS_GETTER_URL_POSTFIX);
}

/**
* Sets the message logging status.
*
* @param control the new message logging status
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
*/
public boolean setMessageLoggingStatus(MessageLoggingControl control) {
LOG.debug("Call message logging status setter API with value: " + control);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,54 @@
import com.epam.wilma.mock.domain.WilmaMockConfig;
import com.epam.wilma.mock.http.WilmaHttpClient;

/**
* Collects the operation configuration related commands.
*
* @author Tamas_Pinter
*
*/
public class OperationConfiguration extends AbstractConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(MessageLoggingConfiguration.class);

private static final String STATUS_GETTER_URL_POSTFIX = "config/public/switch/status";
private static final String STATUS_SETTER_URL_POSTFIX_FORMAT = "config/admin/switch/%s";

/**
* Constructor.
*
* @param config the Wilma server configuration
*/
public OperationConfiguration(WilmaMockConfig config) {
super(config);
}

/**
* Constructor.
*
* @param config the Wilma server configuration
* @param client the Wilma HTTP client
*/
public OperationConfiguration(WilmaMockConfig config, WilmaHttpClient client) {
super(config, client);
}

/**
* Gets the actual operation mode.
*
* @return actual operation mode in JSONObject
*/
public JSONObject getOperationMode() {
LOG.debug("Call operation status API.");

return getterRequest(STATUS_GETTER_URL_POSTFIX);
}

/**
* Sets the operation mode.
*
* @param mode the new operation mode
* @return <tt>true</tt> if the request is successful, otherwise return <tt>false</tt>
*/
public boolean setOperationMode(OperationMode mode) {
LOG.debug("Call operation mode setter API with value: " + mode);

Expand Down
Loading