You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2015/08/06 16:06:23 UTC

[07/12] stratos git commit: fixing intellij idea suggestions

fixing intellij idea suggestions


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/08b9696b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/08b9696b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/08b9696b

Branch: refs/heads/master
Commit: 08b9696b409c475cb6750fda8dcfb9e99e83f73d
Parents: f995fb3
Author: reka <rt...@gmail.com>
Authored: Wed Aug 5 14:26:33 2015 +0530
Committer: reka <rt...@gmail.com>
Committed: Thu Aug 6 19:33:43 2015 +0530

----------------------------------------------------------------------
 .../tests/ApplicationPolicyTest.java            |  3 +-
 .../integration/tests/ApplicationTest.java      |  3 +-
 .../tests/AutoscalingPolicyTest.java            |  3 +-
 .../integration/tests/CartridgeGroupTest.java   |  3 +-
 .../integration/tests/CartridgeTest.java        |  3 +-
 .../integration/tests/DeploymentPolicyTest.java |  3 +-
 .../integration/tests/NetworkPartitionTest.java |  3 +-
 .../integration/tests/rest/RestClient.java      | 50 +++++++++++++-------
 8 files changed, 41 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
index ec5bf04..dafa36e 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
@@ -41,10 +41,9 @@ public class ApplicationPolicyTest {
 
     public ApplicationPolicyBean getApplicationPolicy(String applicationPolicyId, RestClient restClient) {
 
-        ApplicationPolicyBean bean = (ApplicationPolicyBean) restClient.
+        return (ApplicationPolicyBean) restClient.
                 getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
                         ApplicationPolicyBean.class, entityName);
-        return bean;
     }
 
     public boolean updateApplicationPolicy(String applicationPolicyId, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
index af18163..c886644 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
@@ -40,10 +40,9 @@ public class ApplicationTest {
 
     public ApplicationBean getApplication(String applicationId,
                                           RestClient restClient) {
-        ApplicationBean bean = (ApplicationBean) restClient.
+        return (ApplicationBean) restClient.
                 getEntity(RestConstants.APPLICATIONS, applicationId,
                         ApplicationBean.class, entityName);
-        return bean;
     }
 
     public boolean updateApplication(String applicationId, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
index 7c04d92..1c99cad 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
@@ -39,10 +39,9 @@ public class AutoscalingPolicyTest {
     }
 
     public AutoscalePolicyBean getAutoscalingPolicy(String autoscalingPolicyName, RestClient restClient) {
-        AutoscalePolicyBean bean = (AutoscalePolicyBean) restClient.
+        return (AutoscalePolicyBean) restClient.
                 getEntity(RestConstants.AUTOSCALING_POLICIES, autoscalingPolicyName,
                         AutoscalePolicyBean.class, entityName);
-        return bean;
     }
 
     public boolean updateAutoscalingPolicy(String autoscalingPolicyName, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
index caf2838..9aae646 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
@@ -39,10 +39,9 @@ public class CartridgeGroupTest {
     }
 
     public CartridgeGroupBean getCartridgeGroup(String groupName, RestClient restClient) {
-        CartridgeGroupBean bean = (CartridgeGroupBean) restClient.
+        return (CartridgeGroupBean) restClient.
                 getEntity(RestConstants.CARTRIDGE_GROUPS, groupName,
                         CartridgeGroupBean.class, entityName);
-        return bean;
     }
 
     public boolean updateCartridgeGroup(String groupName, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
index fc5cfa0..1d135dd 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
@@ -42,10 +42,9 @@ public class CartridgeTest {
 
     public CartridgeBean getCartridge(String cartridgeType,
                                       RestClient restClient) {
-        CartridgeBean bean = (CartridgeBean) restClient.
+        return (CartridgeBean) restClient.
                 getEntity(RestConstants.CARTRIDGES, cartridgeType,
                         CartridgeBean.class, entityName);
-        return bean;
     }
 
     public boolean updateCartridge(String cartridgeType, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
index 707f750..eeb3ed9 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
@@ -40,10 +40,9 @@ public class DeploymentPolicyTest {
 
     public DeploymentPolicyBean getDeploymentPolicy(String deploymentPolicyId,
                                                     RestClient restClient) {
-        DeploymentPolicyBean bean = (DeploymentPolicyBean) restClient.
+        return (DeploymentPolicyBean) restClient.
                 getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
                         DeploymentPolicyBean.class, entityName);
-        return bean;
     }
 
     public boolean updateDeploymentPolicy(String deploymentPolicyId, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
index ff27ea6..8593a09 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
@@ -40,10 +40,9 @@ public class NetworkPartitionTest {
 
     public NetworkPartitionBean getNetworkPartition(String networkPartitionId,
                                                     RestClient restClient) {
-        NetworkPartitionBean bean = (NetworkPartitionBean) restClient.
+        return (NetworkPartitionBean) restClient.
                 getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
                         NetworkPartitionBean.class, entityName);
-        return bean;
     }
 
     public boolean updateNetworkPartition(String networkPartitionId, RestClient restClient) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/08b9696b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
index a1b07e1..5ff8fd3 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
@@ -80,7 +80,7 @@ public class RestClient {
             input.setContentType("application/json");
             postRequest.setEntity(input);
 
-            String userPass = "admin" + ":" + "admin";
+            String userPass = getUsernamePassword();
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             postRequest.addHeader("Authorization", basicAuth);
 
@@ -103,7 +103,7 @@ public class RestClient {
         try {
             getRequest = new HttpGet(resourcePath);
             getRequest.addHeader("Content-Type", "application/json");
-            String userPass = "admin" + ":" + "admin";
+            String userPass = getUsernamePassword();
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             getRequest.addHeader("Authorization", basicAuth);
 
@@ -118,7 +118,7 @@ public class RestClient {
         try {
             httpDelete = new HttpDelete(resourcePath);
             httpDelete.addHeader("Content-Type", "application/json");
-            String userPass = "admin" + ":" + "admin";
+            String userPass = getUsernamePassword();
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             httpDelete.addHeader("Authorization", basicAuth);
             return httpClient.execute(httpDelete, new HttpResponseHandler());
@@ -136,7 +136,7 @@ public class RestClient {
             StringEntity input = new StringEntity(jsonParamString);
             input.setContentType("application/json");
             putRequest.setEntity(input);
-            String userPass = "admin" + ":" + "admin";
+            String userPass = getUsernamePassword();
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             putRequest.addHeader("Authorization", basicAuth);
             return httpClient.execute(putRequest, new HttpResponseHandler());
@@ -169,8 +169,9 @@ public class RestClient {
                     }
                 }
             }
-            log.error("An unknown error occurred while trying to add " + entityName);
-            throw new RuntimeException("An unknown error occurred while trying to add" + entityName);
+            String msg = "An unknown error occurred while trying to add ";
+            log.error(msg + entityName);
+            throw new RuntimeException(msg + entityName);
         } catch (Exception e) {
             String message = "Could not add " + entityName;
             log.error(message, e);
@@ -195,8 +196,9 @@ public class RestClient {
                     }
                 }
             }
-            log.error("An unknown error occurred while trying to deploy " + entityName);
-            throw new RuntimeException("An unknown error occurred while trying to deploy " + entityName);
+            String msg = "An unknown error occurred while trying to deploy ";
+            log.error(msg + entityName);
+            throw new RuntimeException(msg + entityName);
         } catch (Exception e) {
             String message = "Could not deploy  " + entityName;
             log.error(message, e);
@@ -221,8 +223,9 @@ public class RestClient {
                     }
                 }
             }
-            log.error("An unknown error occurred while trying to deploy " + entityName);
-            throw new RuntimeException("An unknown error occurred while trying to deploy " + entityName);
+            String msg = "An unknown error occurred while trying to undeploy ";
+            log.error(msg + entityName);
+            throw new RuntimeException(msg + entityName);
         } catch (Exception e) {
             String message = "Could not deploy  " + entityName;
             log.error(message, e);
@@ -308,8 +311,9 @@ public class RestClient {
                     }
                 }
             }
-            log.error("An unknown error occurred while trying to update " + entityName);
-            throw new RuntimeException("An unknown error occurred while trying to update" + entityName);
+            String msg = "An unknown error occurred while trying to update ";
+            log.error(msg + entityName);
+            throw new RuntimeException(msg + entityName);
         } catch (Exception e) {
             String message = "Could not add " + entityName;
             log.error(message, e);
@@ -317,23 +321,37 @@ public class RestClient {
         }
     }
 
+    /**
+     * Get the json string from the artifacts directory
+     *
+     * @param filePath path of the artifacts
+     * @return json string of the relevant artifact
+     * @throws FileNotFoundException
+     */
     public String getJsonStringFromFile(String filePath) throws FileNotFoundException {
         JsonParser parser = new JsonParser();
         Object object = parser.parse(new FileReader(getResourcesFolderPath() + filePath));
         GsonBuilder gsonBuilder = new GsonBuilder();
         Gson gson = gsonBuilder.create();
-        String content = gson.toJson(object);
-        return content;
-
+        return gson.toJson(object);
     }
 
     /**
      * Get resources folder path
      *
-     * @return
+     * @return the resource path
      */
     private String getResourcesFolderPath() {
         String path = getClass().getResource("/").getPath();
         return StringUtils.removeEnd(path, File.separator);
     }
+
+    /**
+     * Get the username and password
+     *
+     * @return username:password
+     */
+    private String getUsernamePassword() {
+        return this.userName + ":" + this.password;
+    }
 }