refactord RestMusicAdminAPI.java as per spring MVC 60/76060/1
authorSandeep J <sandeejh@in.ibm.com>
Mon, 21 Jan 2019 10:13:09 +0000 (15:43 +0530)
committerSandeep J <sandeejh@in.ibm.com>
Mon, 21 Jan 2019 10:13:53 +0000 (15:43 +0530)
refactored the class and updated unit test cases as per the code changes

Issue-ID: MUSIC-212
Change-Id: Id66854be3894d36e2c2b0a6d86c2f6bb29e48db6
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
pom.xml
src/main/java/org/onap/music/datastore/jsonobjects/JsonOnboard.java
src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
src/main/java/org/onap/music/rest/repository/RestMusicAdminRepository.java [new file with mode: 0644]
src/main/java/org/onap/music/rest/repository/impl/RestMusicAdminRepositoryImpl.java [new file with mode: 0644]
src/main/java/org/onap/music/rest/service/RestMusicAdminService.java [new file with mode: 0644]
src/main/java/org/onap/music/rest/service/impl/RestMusicAdminServiceImpl.java [new file with mode: 0644]
src/main/java/org/onap/music/rest/util/RestMusicAdminAPIUtil.java [new file with mode: 0644]
src/main/resources/application.properties
src/test/java/org/onap/music/unittests/TestRestMusicAdminAPI.java [new file with mode: 0644]
src/test/java/org/onap/music/unittests/TestRestMusicData.java

diff --git a/pom.xml b/pom.xml
index 5b12313..fbb1ad6 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
 <!-- ============LICENSE_START========================================== 
        org.onap.music =================================================================== 
-       Copyright (c) 2017 AT&T Intellectual Property 
-       Modifications Copyright (c) 2018 IBM=================================================================== 
+       Copyright (c) 2017 AT&T Intellectual Property ============Modifications Copyright 
+       (c) 2018-2019 IBM=================================================================== 
        Licensed under the Apache License, Version 2.0 (the "License"); you may not 
        use this file except in compliance with the License. You may obtain a copy 
        of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
                <relativePath /> <!-- lookup parent from repository -->
        </parent>
 
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <jersey1.version>1.19</jersey1.version>
-        <jersey2.version>2.25.1</jersey2.version>
-        <jaxrs.version>2.0.1</jaxrs.version>
-        <cassandra.version>3.6.0</cassandra.version>
-        <zookeeper.version>3.4.11</zookeeper.version>
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <jersey1.version>1.19</jersey1.version>
+               <jersey2.version>2.25.1</jersey2.version>
+               <jaxrs.version>2.0.1</jaxrs.version>
+               <cassandra.version>3.6.0</cassandra.version>
+               <zookeeper.version>3.4.11</zookeeper.version>
 
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                                        </execution>
                                </executions>
                        </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                        <configuration>
-                            <shadedArtifactAttached>true</shadedArtifactAttached>
-                            <transformers>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-shade-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>shade</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <shadedArtifactAttached>true</shadedArtifactAttached>
+                                                       <transformers>
                                                                <transformer
-                                                                               implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                                                                       implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                                                        <resource>META-INF/spring.handlers</resource>
                                                                </transformer>
                                                                <transformer
-                                                                               implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
+                                                                       implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
                                                                        <resource>META-INF/spring.factories</resource>
                                                                </transformer>
                                                                <transformer
-                                                                               implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                                                                       implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                                                        <resource>META-INF/spring.schemas</resource>
                                                                </transformer>
                                                                <transformer
-                                                                               implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"
-                                                               />
-                                                               <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                                    <mainClass>org.onap.music.testruns.MTBench</mainClass>
-                                </transformer>
-                            </transformers>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
+                                                                       implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+                                                               <transformer
+                                                                       implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                                                                       <mainClass>org.onap.music.testruns.MTBench</mainClass>
+                                                               </transformer>
+                                                       </transformers>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-install-plugin</artifactId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <scope>test</scope>
                </dependency>
-               <!-- Development -->
-               <dependency>
-                       <groupId>javax.servlet</groupId>
-                       <artifactId>servlet-api</artifactId>
-                       <version>2.4</version>
-                       <scope>provided</scope>
-               </dependency>
                <dependency>
                        <groupId>javax.servlet</groupId>
                        <artifactId>javax.servlet-api</artifactId>
                        <artifactId>jbcrypt</artifactId>
                        <version>0.4</version>
                </dependency>
-               <dependency>            
-                               <groupId>io.netty</groupId>             
-                               <artifactId>netty-buffer</artifactId>           
-                               <version>4.1.30.Final</version>         
-                       </dependency>
-               
+               <dependency>
+                       <groupId>io.netty</groupId>
+                       <artifactId>netty-buffer</artifactId>
+                       <version>4.1.30.Final</version>
+               </dependency>
+
                <!-- <dependency> <groupId>com.owlike</groupId> <artifactId>genson</artifactId> 
                        <version>1.3</version> </dependency> -->
        </dependencies>
-               <reporting>
+       <reporting>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
index 0bac1e3..c0c1d32 100755 (executable)
@@ -4,6 +4,8 @@
  * ===================================================================
  *  Copyright (c) 2017 AT&T Intellectual Property
  * ===================================================================
+ *  Modifications Copyright (c) 2018-2019 IBM.
+ * ===================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
@@ -35,6 +37,18 @@ public class JsonOnboard {
     private String isAAF;
     private String aid;
 
+    public JsonOnboard() {
+    }
+
+    public JsonOnboard(String appname, String userId, String password, String isAAF, String aid) {
+        super();
+        this.appname = appname;
+        this.userId = userId;
+        this.password = password;
+        this.isAAF = isAAF;
+        this.aid = aid;
+    }
+
     @ApiModelProperty(value = "Application Password")
     public String getPassword() {
         return password;
index 9043649..27c0985 100755 (executable)
@@ -2,7 +2,9 @@
  * ============LICENSE_START==========================================
  * org.onap.music
  * ===================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * Modifications Copyright (c) 2018-2019 IBM.
  * ===================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  */
 package org.onap.music.rest;
 
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.Response.Status;
 
-import org.mindrot.jbcrypt.BCrypt;
-import org.onap.music.datastore.PreparedQueryObject;
 import org.onap.music.datastore.jsonobjects.JSONObject;
 import org.onap.music.datastore.jsonobjects.JsonOnboard;
 import org.onap.music.eelf.logging.EELFLoggerDelegate;
-import org.onap.music.eelf.logging.format.AppMessages;
-import org.onap.music.eelf.logging.format.ErrorSeverity;
-import org.onap.music.eelf.logging.format.ErrorTypes;
-import org.onap.music.main.CachingUtil;
-import org.onap.music.main.MusicCore;
-import org.onap.music.main.MusicUtil;
-import org.onap.music.main.ResultType;
-import com.datastax.driver.core.DataType;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
+import org.onap.music.rest.service.RestMusicAdminService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
-@Path("/v2/admin")
+@Controller
+@RequestMapping("/v2/admin")
 // @Path("/v{version: [0-9]+}/admin")
 // @Path("/admin")
 @Api(value = "Admin Api", hidden = true)
 public class RestMusicAdminAPI {
-    private static EELFLoggerDelegate logger =
-                    EELFLoggerDelegate.getLogger(RestMusicAdminAPI.class);
+    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicAdminAPI.class);
+    @Autowired
+    private RestMusicAdminService restAdminService;
 
     /*
-     * API to onboard an application with MUSIC. This is the mandatory first step.
+     * API to onboard an application with MUSIC. This is the mandatory first
+     * step.
      * 
      */
     @POST
-    @Path("/onboardAppWithMusic")
+    @RequestMapping("/onboardAppWithMusic")
     @ApiOperation(value = "Onboard application", response = String.class)
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response onboardAppWithMusic(JsonOnboard jsonObj) throws Exception {
-        ResponseBuilder response =
-                        Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
-        Map<String, Object> resultMap = new HashMap<>();
-        String appName = jsonObj.getAppname();
-        String userId = jsonObj.getUserId();
-        String isAAF = jsonObj.getIsAAF();
-        String password = jsonObj.getPassword();
-        if (appName == null || userId == null || isAAF == null || password == null) {
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGINFO,
-                            ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
-            resultMap.put("Exception",
-                            "Unauthorized: Please check the request parameters. Some of the required values appName(ns), userId, password, isAAF are missing.");
-            return Response.status(Status.UNAUTHORIZED).entity(resultMap).build();
-        }
-
-        PreparedQueryObject pQuery = new PreparedQueryObject();
-        pQuery.appendQueryString(
-                        "select uuid from admin.keyspace_master where application_name = ? allow filtering");
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
-        ResultSet rs = MusicCore.get(pQuery);
-        if (!rs.all().isEmpty()) {
-            resultMap.put("Exception", "Application " + appName
-                            + " has already been onboarded. Please contact admin.");
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
-
-        pQuery = new PreparedQueryObject();
-        String uuid = CachingUtil.generateUUID();
-        pQuery.appendQueryString(
-                        "INSERT INTO admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
-                                        + "password, username, is_aaf) VALUES (?,?,?,?,?,?,?)");
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(),
-                        MusicUtil.DEFAULTKEYSPACENAME));
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), "True"));
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
-
-        String returnStr = MusicCore.eventualPut(pQuery).toString();
-        if (returnStr.contains("Failure")) {
-            resultMap.put("Exception",
-                            "Oops. Something wrong with onboarding process. Please retry later or contact admin.");
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
-        CachingUtil.updateisAAFCache(appName, isAAF);
-        resultMap.put("Success", "Your application " + appName + " has been onboarded with MUSIC.");
-        resultMap.put("Generated AID", uuid);
-        return Response.status(Status.OK).entity(resultMap).build();
+    public @ResponseBody Response onboardAppWithMusic(@RequestBody JsonOnboard jsonObj) throws Exception {
+        Response res = restAdminService.onboardAppWithMusic(jsonObj);
+        return res;
     }
 
-
     @POST
-    @Path("/search")
+    @RequestMapping("/search")
     @ApiOperation(value = "Search Onboard application", response = String.class)
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response getOnboardedInfoSearch(JsonOnboard jsonObj) throws Exception {
-        Map<String, Object> resultMap = new HashMap<>();
-        ResponseBuilder response =
-                        Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
-        String appName = jsonObj.getAppname();
-        String uuid = jsonObj.getAid();
-        String isAAF = jsonObj.getIsAAF();
-
-        if (appName == null && uuid == null && isAAF == null) {
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGINFO,
-                            ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
-            resultMap.put("Exception",
-                            "Unauthorized: Please check the request parameters. Enter atleast one of the following parameters: appName(ns), aid, isAAF.");
-            return Response.status(Status.UNAUTHORIZED).entity(resultMap).build();
-        }
-
-        PreparedQueryObject pQuery = new PreparedQueryObject();
-        String cql = "select uuid, keyspace_name from admin.keyspace_master where ";
-        if (appName != null)
-            cql = cql + "application_name = ? AND ";
-        if (uuid != null)
-            cql = cql + "uuid = ? AND ";
-        if (isAAF != null)
-            cql = cql + "is_aaf = ?";
-
-        if (cql.endsWith("AND "))
-            cql = cql.trim().substring(0, cql.length() - 4);
-        System.out.println("Query is: " + cql);
-        cql = cql + " allow filtering";
-        System.out.println("Get OnboardingInfo CQL: " + cql);
-        pQuery.appendQueryString(cql);
-        if (appName != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
-        if (uuid != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
-        if (isAAF != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(),
-                            Boolean.parseBoolean(isAAF)));
-        ResultSet rs = MusicCore.get(pQuery);
-        Iterator<Row> it = rs.iterator();
-        while (it.hasNext()) {
-            Row row = (Row) it.next();
-            resultMap.put(row.getUUID("uuid").toString(), row.getString("keyspace_name"));
-        }
-        if (resultMap.isEmpty()) {
-            if (uuid != null) {
-                resultMap.put("Exception",
-                                "Please make sure Aid is correct and application is onboarded.");
-                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-            } else {
-                resultMap.put("Exception",
-                                "Application is not onboarded. Please make sure all the information is correct.");
-                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-            }
-        }
-        return Response.status(Status.OK).entity(resultMap).build();
+    public @ResponseBody Response getOnboardedInfoSearch(@RequestBody JsonOnboard jsonObj) throws Exception {
+        Response res = restAdminService.getOnboardedInfoSearch(jsonObj);
+        return res;
     }
 
-
     @DELETE
-    @Path("/onboardAppWithMusic")
+    @RequestMapping("/deleteOnboardApp")
     @ApiOperation(value = "Delete Onboard application", response = String.class)
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response deleteOnboardApp(JsonOnboard jsonObj) throws Exception {
-        Map<String, Object> resultMap = new HashMap<>();
-        ResponseBuilder response =
-                        Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
-        String appName = jsonObj.getAppname();
-        String aid = jsonObj.getAid();
-        PreparedQueryObject pQuery = new PreparedQueryObject();
-        String consistency = MusicUtil.EVENTUAL;;
-        if (appName == null && aid == null) {
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGINFO,
-                            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-            resultMap.put("Exception", "Please make sure either appName(ns) or Aid is present");
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
-        if (aid != null) {
-            pQuery.appendQueryString(
-                            "SELECT keyspace_name FROM admin.keyspace_master WHERE uuid = ?");
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
-                            UUID.fromString(aid)));
-            Row row = MusicCore.get(pQuery).one();
-            if (row != null) {
-                String ks = row.getString("keyspace_name");
-                if (!ks.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
-                    PreparedQueryObject queryObject = new PreparedQueryObject();
-                    queryObject.appendQueryString("DROP KEYSPACE IF EXISTS " + ks + ";");
-                    MusicCore.nonKeyRelatedPut(queryObject, consistency);
-                }
-            }
-            pQuery = new PreparedQueryObject();
-            pQuery.appendQueryString("delete from admin.keyspace_master where uuid = ? IF EXISTS");
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
-                            UUID.fromString(aid)));
-            ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency);
-            if (result == ResultType.SUCCESS) {
-                resultMap.put("Success", "Your application has been deleted successfully");
-            } else {
-                resultMap.put("Exception",
-                                "Oops. Something went wrong. Please make sure Aid is correct or Application is onboarded");
-                logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA,
-                                ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-
-            }
-            return Response.status(Status.OK).entity(resultMap).build();
-        }
-
-        pQuery.appendQueryString(
-                        "select uuid from admin.keyspace_master where application_name = ? allow filtering");
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
-        ResultSet rs = MusicCore.get(pQuery);
-        List<Row> rows = rs.all();
-        String uuid = null;
-        if (rows.size() == 0) {
-            resultMap.put("Exception",
-                            "Application not found. Please make sure Application exists.");
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA,
-                            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        } else if (rows.size() == 1) {
-            uuid = rows.get(0).getUUID("uuid").toString();
-            pQuery = new PreparedQueryObject();
-            pQuery.appendQueryString(
-                            "SELECT keyspace_name FROM admin.keyspace_master WHERE uuid = ?");
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
-                            UUID.fromString(uuid)));
-            Row row = MusicCore.get(pQuery).one();
-            String ks = row.getString("keyspace_name");
-            if (!ks.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
-                PreparedQueryObject queryObject = new PreparedQueryObject();
-                queryObject.appendQueryString("DROP KEYSPACE " + ks + ";");
-                MusicCore.nonKeyRelatedPut(queryObject, consistency);
-            }
-
-            pQuery = new PreparedQueryObject();
-            pQuery.appendQueryString("delete from admin.keyspace_master where uuid = ?");
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
-                            UUID.fromString(uuid)));
-            MusicCore.eventualPut(pQuery);
-            resultMap.put("Success", "Your application " + appName + " has been deleted.");
-            return Response.status(Status.OK).entity(resultMap).build();
-        } else {
-            resultMap.put("Failure",
-                            "More than one Aid exists for this application, so please provide Aid.");
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MULTIPLERECORDS,
-                            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
+    public @ResponseBody Response deleteOnboardApp(@RequestBody JsonOnboard jsonObj) throws Exception {
+        Response res = restAdminService.deleteOnboardApp(jsonObj);
+        return res;
     }
 
-
     @PUT
-    @Path("/onboardAppWithMusic")
+    @RequestMapping("/updateOnboardApp")
     @ApiOperation(value = "Update Onboard application", response = String.class)
-    @Consumes(MediaType.APPLICATION_JSON)
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response updateOnboardApp(JsonOnboard jsonObj) throws Exception {
-        Map<String, Object> resultMap = new HashMap<>();
-        ResponseBuilder response =
-                        Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
-        String aid = jsonObj.getAid();
-        String appName = jsonObj.getAppname();
-        String userId = jsonObj.getUserId();
-        String isAAF = jsonObj.getIsAAF();
-        String password = jsonObj.getPassword();
-        String consistency = "eventual";
-        PreparedQueryObject pQuery;
-
-        if (aid == null) {
-            resultMap.put("Exception", "Please make sure Aid is present");
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-                            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
-
-        if (appName == null && userId == null && password == null && isAAF == null) {
-            resultMap.put("Exception",
-                            "No parameters found to update. Please update atleast one parameter.");
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-                            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
-
-        if (appName != null) {
-            pQuery = new PreparedQueryObject();
-            pQuery.appendQueryString(
-                            "select uuid from admin.keyspace_master where application_name = ? allow filtering");
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
-            ResultSet rs = MusicCore.get(pQuery);
-            if (!rs.all().isEmpty()) {
-                resultMap.put("Exception", "Application " + appName
-                                + " has already been onboarded. Please contact admin.");
-                logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.ALREADYEXIST,
-                                ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-            }
-        }
-
-        pQuery = new PreparedQueryObject();
-        StringBuilder preCql = new StringBuilder("UPDATE admin.keyspace_master SET ");
-        if (appName != null)
-            preCql.append(" application_name = ?,");
-        if (userId != null)
-            preCql.append(" username = ?,");
-        if (password != null)
-            preCql.append(" password = ?,");
-        if (isAAF != null)
-            preCql.append(" is_aaf = ?,");
-        preCql.deleteCharAt(preCql.length() - 1);
-        preCql.append(" WHERE uuid = ? IF EXISTS");
-        pQuery.appendQueryString(preCql.toString());
-        if (appName != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
-        if (userId != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
-        if (password != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
-        if (isAAF != null)
-            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
-
-        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), UUID.fromString(aid)));
-        ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency);
-
-        if (result == ResultType.SUCCESS) {
-            resultMap.put("Success", "Your application has been updated successfully");
-        } else {
-            resultMap.put("Exception",
-                            "Oops. Something went wrong. Please make sure Aid is correct and application is onboarded");
-            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA,
-                            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
-        }
-
-        return Response.status(Status.OK).entity(resultMap).build();
+    public @ResponseBody Response updateOnboardApp(@RequestBody JsonOnboard jsonObj) throws Exception {
+        Response res = restAdminService.updateOnboardApp(jsonObj);
+        return res;
     }
-    
+
     @POST
-    @Path("/callbackOps")
-    @Produces(MediaType.APPLICATION_JSON)
-    @Consumes(MediaType.APPLICATION_JSON)
+    @RequestMapping("/callbackOps")
     public String callbackOps(JSONObject inputJsonObj) throws Exception {
-       
-       System.out.println("Input JSON: "+inputJsonObj.getData());
-       return "Success";
+
+        System.out.println("Input JSON: " + inputJsonObj.getData());
+        return "Success";
     }
 }
diff --git a/src/main/java/org/onap/music/rest/repository/RestMusicAdminRepository.java b/src/main/java/org/onap/music/rest/repository/RestMusicAdminRepository.java
new file mode 100644 (file)
index 0000000..0b7e223
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ============LICENSE_START==========================================
+ *  org.onap.music
+ * ===================================================================
+ *  Copyright (c) 2019 IBM.
+ * ===================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * 
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.rest.repository;
+
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.main.ResultType;
+
+import com.datastax.driver.core.ResultSet;
+
+public interface RestMusicAdminRepository {
+
+       ResultSet getUuidFromKeySpaceMasterUsingAppName(String appName) throws Exception;
+
+       String insertValuesIntoKeySpaceMaster(String uuid, String appName, String userId, String isAAF, String password)
+                       throws Exception;
+
+       ResultSet fetchOnboardedInfoSearch(String appName, String uuid, String isAAF) throws Exception;
+
+       ResultSet getKeySpaceNameFromKeySpaceMasterWithUuid(String aid) throws Exception;
+
+       void dropKeySpace(String ks, String consistency) throws MusicServiceException;
+
+       ResultType deleteFromKeySpaceMasterWithUuid(String aid, String consistency) throws Exception;
+
+       ResultSet getKeySpaceNameFromKeySpaceMasterWithAppName(String appName) throws Exception;
+
+       ResultType updateKeySpaceMaster(String appName, String userId, String password, String isAAF, String aid,
+                       String consistency) throws Exception;
+}
diff --git a/src/main/java/org/onap/music/rest/repository/impl/RestMusicAdminRepositoryImpl.java b/src/main/java/org/onap/music/rest/repository/impl/RestMusicAdminRepositoryImpl.java
new file mode 100644 (file)
index 0000000..bf841dc
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * ============LICENSE_START==========================================
+ *  org.onap.music
+ * ===================================================================
+ *  Copyright (c) 2019 IBM.
+ * ===================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * 
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.rest.repository.impl;
+
+import java.util.UUID;
+
+import org.mindrot.jbcrypt.BCrypt;
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.main.MusicCore;
+import org.onap.music.main.MusicUtil;
+import org.onap.music.main.ResultType;
+import org.onap.music.rest.repository.RestMusicAdminRepository;
+import org.onap.music.rest.util.RestMusicAdminAPIUtil;
+import org.springframework.stereotype.Repository;
+
+import com.datastax.driver.core.DataType;
+import com.datastax.driver.core.ResultSet;
+
+@Repository
+public class RestMusicAdminRepositoryImpl implements RestMusicAdminRepository {
+
+    private PreparedQueryObject pQuery;
+
+    @Override
+    public ResultSet getUuidFromKeySpaceMasterUsingAppName(String appName) throws Exception {
+        pQuery = new PreparedQueryObject();
+        pQuery.appendQueryString("select uuid from admin.keyspace_master where application_name = ? allow filtering");
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
+        ResultSet rs = MusicCore.get(pQuery);
+        return rs;
+    }
+
+    @Override
+    public String insertValuesIntoKeySpaceMaster(String uuid, String appName, String userId, String isAAF,
+            String password) throws Exception {
+        pQuery = new PreparedQueryObject();
+        pQuery.appendQueryString("INSERT INTO admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
+                + "password, username, is_aaf) VALUES (?,?,?,?,?,?,?)");
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), MusicUtil.DEFAULTKEYSPACENAME));
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), "True"));
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
+
+        String returnStr = MusicCore.eventualPut(pQuery).toString();
+        return returnStr;
+    }
+
+    @Override
+    public ResultSet fetchOnboardedInfoSearch(String appName, String uuid, String isAAF) throws Exception {
+        pQuery = new PreparedQueryObject();
+        pQuery = RestMusicAdminAPIUtil.getQueryString(appName, uuid, isAAF);
+        ResultSet rs = MusicCore.get(pQuery);
+        return rs;
+    }
+
+    @Override
+    public ResultSet getKeySpaceNameFromKeySpaceMasterWithUuid(String aid) throws Exception {
+        pQuery = new PreparedQueryObject();
+        pQuery.appendQueryString("SELECT keyspace_name FROM admin.keyspace_master WHERE uuid = ?");
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), UUID.fromString(aid)));
+        ResultSet rs = MusicCore.get(pQuery);
+        return rs;
+    }
+
+    @Override
+    public void dropKeySpace(String ks, String consistency) throws MusicServiceException {
+        pQuery = new PreparedQueryObject();
+        pQuery.appendQueryString("DROP KEYSPACE IF EXISTS " + ks + ";");
+        MusicCore.nonKeyRelatedPut(pQuery, consistency);
+
+    }
+
+    @Override
+    public ResultType deleteFromKeySpaceMasterWithUuid(String aid, String consistency) throws Exception {
+        pQuery = new PreparedQueryObject();
+        pQuery.appendQueryString("delete from admin.keyspace_master where uuid = ? IF EXISTS");
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), UUID.fromString(aid)));
+
+        ResultType rt = MusicCore.nonKeyRelatedPut(pQuery, consistency);
+        return rt;
+    }
+
+    @Override
+    public ResultSet getKeySpaceNameFromKeySpaceMasterWithAppName(String appName) throws Exception {
+        pQuery = new PreparedQueryObject();
+        pQuery.appendQueryString("select uuid from admin.keyspace_master where application_name = ? allow filtering");
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
+        ResultSet rs = MusicCore.get(pQuery);
+        return rs;
+    }
+
+    @Override
+    public ResultType updateKeySpaceMaster(String appName, String userId, String password, String isAAF, String aid,
+            String consistency) throws Exception {
+        pQuery = new PreparedQueryObject();
+        StringBuilder preCql = new StringBuilder("UPDATE admin.keyspace_master SET ");
+        if (appName != null)
+            preCql.append(" application_name = ?,");
+        if (userId != null)
+            preCql.append(" username = ?,");
+        if (password != null)
+            preCql.append(" password = ?,");
+        if (isAAF != null)
+            preCql.append(" is_aaf = ?,");
+        preCql.deleteCharAt(preCql.length() - 1);
+        preCql.append(" WHERE uuid = ? IF EXISTS");
+        pQuery.appendQueryString(preCql.toString());
+        if (appName != null)
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
+        if (userId != null)
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
+        if (password != null)
+            pQuery.addValue(
+                    MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
+        if (isAAF != null)
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
+
+        pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), UUID.fromString(aid)));
+        ResultType rs = MusicCore.nonKeyRelatedPut(pQuery, consistency);
+        return rs;
+    }
+
+}
diff --git a/src/main/java/org/onap/music/rest/service/RestMusicAdminService.java b/src/main/java/org/onap/music/rest/service/RestMusicAdminService.java
new file mode 100644 (file)
index 0000000..dd2e5fc
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START==========================================
+ *  org.onap.music
+ * ===================================================================
+ *  Copyright (c) 2019 IBM.
+ * ===================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * 
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.rest.service;
+
+import javax.ws.rs.core.Response;
+
+import org.onap.music.datastore.jsonobjects.JsonOnboard;
+
+public interface RestMusicAdminService {
+       Response onboardAppWithMusic(JsonOnboard jsonObj) throws Exception;
+
+       Response getOnboardedInfoSearch(JsonOnboard jsonObj) throws Exception;
+
+       Response deleteOnboardApp(JsonOnboard jsonObj) throws Exception;
+
+       Response updateOnboardApp(JsonOnboard jsonObj) throws Exception;
+}
diff --git a/src/main/java/org/onap/music/rest/service/impl/RestMusicAdminServiceImpl.java b/src/main/java/org/onap/music/rest/service/impl/RestMusicAdminServiceImpl.java
new file mode 100644 (file)
index 0000000..6cce4f6
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * ============LICENSE_START==========================================
+ *  org.onap.music
+ * ===================================================================
+ *  Copyright (c) 2019 IBM.
+ * ===================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * 
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.rest.service.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+
+import org.mindrot.jbcrypt.BCrypt;
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.datastore.jsonobjects.JsonOnboard;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.eelf.logging.format.AppMessages;
+import org.onap.music.eelf.logging.format.ErrorSeverity;
+import org.onap.music.eelf.logging.format.ErrorTypes;
+import org.onap.music.main.CachingUtil;
+import org.onap.music.main.MusicCore;
+import org.onap.music.main.MusicUtil;
+import org.onap.music.main.ResultType;
+import org.onap.music.rest.repository.RestMusicAdminRepository;
+import org.onap.music.rest.service.RestMusicAdminService;
+import org.onap.music.rest.util.RestMusicAdminAPIUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.datastax.driver.core.DataType;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+@Service("restAdminService")
+@Transactional
+public class RestMusicAdminServiceImpl implements RestMusicAdminService {
+
+    @Autowired
+    private RestMusicAdminRepository restMusicAdminRepository;
+
+    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicAdminServiceImpl.class);
+
+    @Override
+    public Response onboardAppWithMusic(JsonOnboard jsonObj) throws Exception {
+        ResponseBuilder response = Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
+        Map<String, Object> resultMap = new HashMap<>();
+        String appName = jsonObj.getAppname();
+        String userId = jsonObj.getUserId();
+        String isAAF = jsonObj.getIsAAF();
+        String password = jsonObj.getPassword();
+        if (appName == null || userId == null || isAAF == null || password == null) {
+            String message = "Unauthorized: Please check the request parameters. Enter atleast one of the following parameters: appName(ns), aid, isAAF.";
+            return RestMusicAdminAPIUtil.sendUnauthorisedResponseForEmptyParams(logger, message);
+        }
+
+        ResultSet rs = restMusicAdminRepository.getUuidFromKeySpaceMasterUsingAppName(appName);
+        if (!rs.all().isEmpty()) {
+            resultMap.put("Exception", "Application " + appName + " has already been onboarded. Please contact admin.");
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        }
+
+        String uuid = CachingUtil.generateUUID();
+        String returnStr = restMusicAdminRepository.insertValuesIntoKeySpaceMaster(uuid, appName, userId, isAAF,
+                password);
+        if (returnStr.contains("Failure")) {
+            resultMap.put("Exception",
+                    "Oops. Something wrong with onboarding process. Please retry later or contact admin.");
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        }
+        CachingUtil.updateisAAFCache(appName, isAAF);
+        resultMap.put("Success", "Your application " + appName + " has been onboarded with MUSIC.");
+        resultMap.put("Generated AID", uuid);
+        return Response.status(Status.OK).entity(resultMap).build();
+    }
+
+    @Override
+    public Response getOnboardedInfoSearch(JsonOnboard jsonObj) throws Exception {
+        Map<String, Object> resultMap = new HashMap<>();
+        ResponseBuilder response = Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
+        String appName = jsonObj.getAppname();
+        String uuid = jsonObj.getAid();
+        String isAAF = jsonObj.getIsAAF();
+        String message = "Unauthorized: Please check the request parameters. Enter atleast one of the following parameters: appName(ns), aid, isAAF.";
+        if (appName == null && uuid == null && isAAF == null) {
+            return RestMusicAdminAPIUtil.sendUnauthorisedResponseForEmptyParams(logger, message);
+        }
+
+        ResultSet rs = restMusicAdminRepository.fetchOnboardedInfoSearch(appName, uuid, isAAF);
+        Iterator<Row> it = rs.iterator();
+        while (it.hasNext()) {
+            Row row = (Row) it.next();
+            resultMap.put(row.getUUID("uuid").toString(), row.getString("keyspace_name"));
+        }
+        if (resultMap.isEmpty()) {
+            if (uuid != null) {
+                resultMap.put("Exception", "Please make sure Aid is correct and application is onboarded.");
+                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+            } else {
+                resultMap.put("Exception",
+                        "Application is not onboarded. Please make sure all the information is correct.");
+                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+            }
+        }
+        return Response.status(Status.OK).entity(resultMap).build();
+    }
+
+    @Override
+    public Response deleteOnboardApp(JsonOnboard jsonObj) throws Exception {
+        Map<String, Object> resultMap = new HashMap<>();
+        ResponseBuilder response = Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
+        String appName = jsonObj.getAppname();
+        String aid = jsonObj.getAid();
+        PreparedQueryObject pQuery = new PreparedQueryObject();
+        String consistency = MusicUtil.EVENTUAL;
+        ;
+        if (appName == null && aid == null) {
+            String message = "Please make sure either appName(ns) or Aid is present";
+            return RestMusicAdminAPIUtil.sendUnauthorisedResponseForEmptyParams(logger, message);
+        }
+        if (aid != null) {
+
+            ResultSet rs = restMusicAdminRepository.getKeySpaceNameFromKeySpaceMasterWithUuid(aid);
+            Row row = rs.one();
+            if (row != null) {
+                String ks = row.getString("keyspace_name");
+                if (!ks.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
+                    restMusicAdminRepository.dropKeySpace(ks, consistency);
+                }
+            }
+            ResultType result = restMusicAdminRepository.deleteFromKeySpaceMasterWithUuid(aid, consistency);
+            if (result == ResultType.SUCCESS) {
+                resultMap.put("Success", "Your application has been deleted successfully");
+            } else {
+                resultMap.put("Exception",
+                        "Oops. Something went wrong. Please make sure Aid is correct or Application is onboarded");
+                logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA, ErrorSeverity.CRITICAL,
+                        ErrorTypes.DATAERROR);
+                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+
+            }
+            return Response.status(Status.OK).entity(resultMap).build();
+        }
+
+        ResultSet rs = restMusicAdminRepository.getKeySpaceNameFromKeySpaceMasterWithAppName(appName);
+        List<Row> rows = rs.all();
+        String uuid = null;
+        if (rows.size() == 0) {
+            resultMap.put("Exception", "Application not found. Please make sure Application exists.");
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA, ErrorSeverity.CRITICAL,
+                    ErrorTypes.DATAERROR);
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        } else if (rows.size() == 1) {
+            uuid = rows.get(0).getUUID("uuid").toString();
+            pQuery = new PreparedQueryObject();
+            ResultSet rs1 = restMusicAdminRepository.getKeySpaceNameFromKeySpaceMasterWithUuid(aid);
+            Row row = rs1.one();
+            String ks = row.getString("keyspace_name");
+            if (!ks.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
+                restMusicAdminRepository.dropKeySpace(ks, consistency);
+            }
+
+            restMusicAdminRepository.deleteFromKeySpaceMasterWithUuid(uuid, consistency);
+            resultMap.put("Success", "Your application " + appName + " has been deleted.");
+            return Response.status(Status.OK).entity(resultMap).build();
+        } else {
+            resultMap.put("Failure", "More than one Aid exists for this application, so please provide Aid.");
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MULTIPLERECORDS, ErrorSeverity.CRITICAL,
+                    ErrorTypes.DATAERROR);
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        }
+    }
+
+    @Override
+    public Response updateOnboardApp(JsonOnboard jsonObj) throws Exception {
+        Map<String, Object> resultMap = new HashMap<>();
+        ResponseBuilder response = Response.noContent().header("X-latestVersion", MusicUtil.getVersion());
+        String aid = jsonObj.getAid();
+        String appName = jsonObj.getAppname();
+        String userId = jsonObj.getUserId();
+        String isAAF = jsonObj.getIsAAF();
+        String password = jsonObj.getPassword();
+        String consistency = "eventual";
+        PreparedQueryObject pQuery;
+
+        if (aid == null) {
+            resultMap.put("Exception", "Please make sure Aid is present");
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA, ErrorSeverity.CRITICAL,
+                    ErrorTypes.DATAERROR);
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        }
+
+        if (appName == null && userId == null && password == null && isAAF == null) {
+            resultMap.put("Exception", "No parameters found to update. Please update atleast one parameter.");
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA, ErrorSeverity.CRITICAL,
+                    ErrorTypes.DATAERROR);
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        }
+
+        if (appName != null) {
+            ResultSet rs = restMusicAdminRepository.getUuidFromKeySpaceMasterUsingAppName(appName);
+            if (!rs.all().isEmpty()) {
+                resultMap.put("Exception",
+                        "Application " + appName + " has already been onboarded. Please contact admin.");
+                logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.ALREADYEXIST, ErrorSeverity.CRITICAL,
+                        ErrorTypes.DATAERROR);
+                return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+            }
+        }
+
+        ResultType result = restMusicAdminRepository.updateKeySpaceMaster(appName, userId, password, isAAF, aid,
+                consistency);
+
+        if (result == ResultType.SUCCESS) {
+            resultMap.put("Success", "Your application has been updated successfully");
+        } else {
+            resultMap.put("Exception",
+                    "Oops. Something went wrong. Please make sure Aid is correct and application is onboarded");
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA, ErrorSeverity.CRITICAL,
+                    ErrorTypes.DATAERROR);
+            return Response.status(Status.BAD_REQUEST).entity(resultMap).build();
+        }
+
+        return Response.status(Status.OK).entity(resultMap).build();
+    }
+
+}
diff --git a/src/main/java/org/onap/music/rest/util/RestMusicAdminAPIUtil.java b/src/main/java/org/onap/music/rest/util/RestMusicAdminAPIUtil.java
new file mode 100644 (file)
index 0000000..cc3a0e5
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * ============LICENSE_START==========================================
+ *  org.onap.music
+ * ===================================================================
+ *  Copyright (c) 2019 IBM.
+ * ===================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * 
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.rest.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.eelf.logging.format.AppMessages;
+import org.onap.music.eelf.logging.format.ErrorSeverity;
+import org.onap.music.eelf.logging.format.ErrorTypes;
+import org.onap.music.main.MusicUtil;
+
+import com.datastax.driver.core.DataType;
+
+public class RestMusicAdminAPIUtil {
+    public static Response sendUnauthorisedResponseForEmptyParams(EELFLoggerDelegate logger, String message)
+
+    {
+        Map<String, Object> resultMap = new HashMap<>();
+
+        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGINFO, ErrorSeverity.CRITICAL,
+                ErrorTypes.AUTHENTICATIONERROR);
+        resultMap.put("Exception", message);
+        return Response.status(Status.UNAUTHORIZED).entity(resultMap).build();
+
+    }
+
+    public static PreparedQueryObject getQueryString(String appName, String uuid, String isAAF) throws Exception {
+        PreparedQueryObject pQuery = new PreparedQueryObject();
+        String cql = "select uuid, keyspace_name from admin.keyspace_master where ";
+        if (appName != null)
+            cql = cql + "application_name = ? AND ";
+        if (uuid != null)
+            cql = cql + "uuid = ? AND ";
+        if (isAAF != null)
+            cql = cql + "is_aaf = ?";
+
+        if (cql.endsWith("AND "))
+            cql = cql.trim().substring(0, cql.length() - 4);
+        System.out.println("Query is: " + cql);
+        cql = cql + " allow filtering";
+        System.out.println("Get OnboardingInfo CQL: " + cql);
+        pQuery.appendQueryString(cql);
+        if (appName != null)
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
+        if (uuid != null)
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
+        if (isAAF != null)
+            pQuery.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), Boolean.parseBoolean(isAAF)));
+        return pQuery;
+
+    }
+}
index cdeaa6e..e4958d2 100644 (file)
@@ -1,2 +1,3 @@
 keyspace.name=VotingAppForMusic
-server.port=1010
\ No newline at end of file
+server.port=8080
+server.servlet.context-path=/MUSIC
\ No newline at end of file
diff --git a/src/test/java/org/onap/music/unittests/TestRestMusicAdminAPI.java b/src/test/java/org/onap/music/unittests/TestRestMusicAdminAPI.java
new file mode 100644 (file)
index 0000000..7fdad7d
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START==========================================
+ *  org.onap.music
+ * ===================================================================
+ *  Copyright (c) 2019 IBM.
+ * ===================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * 
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.unittests;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.Response;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.music.datastore.jsonobjects.JSONObject;
+import org.onap.music.datastore.jsonobjects.JsonOnboard;
+import org.onap.music.rest.RestMusicAdminAPI;
+import org.onap.music.rest.service.RestMusicAdminService;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestRestMusicAdminAPI {
+
+    @InjectMocks
+    RestMusicAdminAPI restMusicAdminAPI;
+
+    @Mock
+    RestMusicAdminService restMusicAdminService;
+
+    @Mock
+    Response response;
+
+    private JsonOnboard json;
+
+    public String mapToJson(Object obj) throws JsonProcessingException {
+        ObjectMapper objectMapper = new ObjectMapper();
+        return objectMapper.writeValueAsString(obj);
+    }
+
+    @Test
+    public void testOnboardAppWithMusic() throws Exception {
+        json = new JsonOnboard("testApp", "testUser", "testPassword", "false", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
+        Mockito.when(restMusicAdminService.onboardAppWithMusic(json)).thenReturn(response);
+        Assert.assertNotNull(restMusicAdminAPI.onboardAppWithMusic(json));
+
+    }
+
+    @Test
+    public void testGetOnboardedInfoSearch() throws Exception {
+
+        JsonOnboard json = new JsonOnboard("testApp", "", "", "false", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
+        Mockito.when(restMusicAdminService.getOnboardedInfoSearch(json)).thenReturn(response);
+        Assert.assertNotNull(restMusicAdminAPI.getOnboardedInfoSearch(json));
+
+    }
+
+    @Test
+    public void testDeleteOnboardApp() throws Exception {
+
+        JsonOnboard json = new JsonOnboard("testApp", "", "", "", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
+        Mockito.when(restMusicAdminService.deleteOnboardApp(json)).thenReturn(response);
+        Assert.assertNotNull(restMusicAdminAPI.deleteOnboardApp(json));
+
+    }
+
+    @Test
+    public void testUpdateOnboardApp() throws Exception {
+
+        JsonOnboard json = new JsonOnboard("testApp", "testUser", "testPassword", "false",
+                "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
+        Mockito.when(restMusicAdminService.updateOnboardApp(json)).thenReturn(response);
+        Assert.assertNotNull(restMusicAdminAPI.updateOnboardApp(json));
+
+    }
+
+    @Test
+    public void testCallbackOps() throws Exception {
+        JSONObject json = new JSONObject();
+        assertEquals("Success", restMusicAdminAPI.callbackOps(json));
+
+    }
+
+}
index c8dd083..8b6248d 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START========================================== org.onap.music
  * =================================================================== Copyright (c) 2017 AT&T
  * Intellectual Property ===================================================================
+ * Modifications Copyright (c) 2018-2019 IBM ===============================
+ * ===========================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  * in compliance with the License. You may obtain a copy of the License at
  * 
@@ -71,7 +73,7 @@ public class TestRestMusicData {
 
     RestMusicDataAPI data = new RestMusicDataAPI();
     RestMusicAdminAPI admin = new RestMusicAdminAPI();
-    RestMusicLocksAPI lock = new RestMusicLocksAPI(); 
+    RestMusicLocksAPI lock = new RestMusicLocksAPI();
     static PreparedQueryObject testObject;
     static TestingServer zkServer;
 
@@ -80,12 +82,12 @@ public class TestRestMusicData {
 
     @Mock
     UriInfo info;
-    
+
     static String appName = "TestApp";
     static String userId = "TestUser";
     static String password = "TestPassword";
-    static String authData = userId+":"+password;
-    static String wrongAuthData = userId+":"+"pass";
+    static String authData = userId + ":" + password;
+    static String wrongAuthData = userId + ":" + "pass";
     static String authorization = new String(Base64.encode(authData.getBytes()));
     static String wrongAuthorization = new String(Base64.encode(wrongAuthData.getBytes()));
     static boolean isAAF = false;
@@ -99,7 +101,7 @@ public class TestRestMusicData {
 
     @BeforeClass
     public static void init() throws Exception {
-       try {
+        try {
             MusicDataStoreHandle.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
             MusicCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.mDstoreHandle);
         } catch (Exception e) {
@@ -115,59 +117,56 @@ public class TestRestMusicData {
         testObject = new PreparedQueryObject();
         testObject.appendQueryString("DROP KEYSPACE IF EXISTS admin");
         MusicCore.eventualPut(testObject);
-        if(MusicDataStoreHandle.mDstoreHandle!=null)
-               MusicDataStoreHandle.mDstoreHandle.close();
-        if(zkServer!=null)
-               zkServer.stop();
+        if (MusicDataStoreHandle.mDstoreHandle != null)
+            MusicDataStoreHandle.mDstoreHandle.close();
+        if (zkServer != null)
+            zkServer.stop();
     }
 
     @Test
     public void Test1_createKeyspace() throws Exception {
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString("CREATE KEYSPACE admin WITH REPLICATION = "
-                        + "{'class' : 'SimpleStrategy' , "
-                        + "'replication_factor': 1} AND DURABLE_WRITES = true");
+        testObject.appendQueryString("CREATE KEYSPACE admin WITH REPLICATION = " + "{'class' : 'SimpleStrategy' , "
+                + "'replication_factor': 1} AND DURABLE_WRITES = true");
         MusicCore.eventualPut(testObject);
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(
-                        "CREATE TABLE admin.keyspace_master (" + "  uuid uuid, keyspace_name text,"
-                                        + "  application_name text, is_api boolean,"
-                                        + "  password text, username text,"
-                                        + "  is_aaf boolean, PRIMARY KEY (uuid)\n" + ");");
+        testObject.appendQueryString("CREATE TABLE admin.keyspace_master (" + "  uuid uuid, keyspace_name text,"
+                + "  application_name text, is_api boolean," + "  password text, username text,"
+                + "  is_aaf boolean, PRIMARY KEY (uuid)\n" + ");");
         MusicCore.eventualPut(testObject);
 
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(
-                        "INSERT INTO admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
-                                        + "password, username, is_aaf) VALUES (?,?,?,?,?,?,?)");
+        testObject
+                .appendQueryString("INSERT INTO admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
+                        + "password, username, is_aaf) VALUES (?,?,?,?,?,?,?)");
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
-        testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(),
-                        MusicUtil.DEFAULTKEYSPACENAME));
+        testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), MusicUtil.DEFAULTKEYSPACENAME));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), "True"));
-        testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
+        testObject.addValue(
+                MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
         MusicCore.eventualPut(testObject);
 
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(
-                        "INSERT INTO admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
-                                        + "password, username, is_aaf) VALUES (?,?,?,?,?,?,?)");
+        testObject
+                .appendQueryString("INSERT INTO admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
+                        + "password, username, is_aaf) VALUES (?,?,?,?,?,?,?)");
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.uuid(),
-                        UUID.fromString("bbc66ccc-d857-4e90-b1e5-df98a3d40de6")));
-        testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(),
-                        MusicUtil.DEFAULTKEYSPACENAME));
+                UUID.fromString("bbc66ccc-d857-4e90-b1e5-df98a3d40de6")));
+        testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), MusicUtil.DEFAULTKEYSPACENAME));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), "TestApp1"));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), "True"));
-        testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
+        testObject.addValue(
+                MusicUtil.convertToActualDataType(DataType.text(), BCrypt.hashpw(password, BCrypt.gensalt())));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), "TestUser1"));
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
         MusicCore.eventualPut(testObject);
 
         testObject = new PreparedQueryObject();
-        testObject.appendQueryString(
-                        "select uuid from admin.keyspace_master where application_name = ? allow filtering");
+        testObject
+                .appendQueryString("select uuid from admin.keyspace_master where application_name = ? allow filtering");
         testObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
         ResultSet rs = MusicCore.get(testObject);
         List<Row> rows = rs.all();
@@ -188,11 +187,13 @@ public class TestRestMusicData {
         jsonKeyspace.setDurabilityOfWrites("true");
         jsonKeyspace.setKeyspaceName(keyspaceName);
         jsonKeyspace.setReplicationInfo(replicationInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createKeySpace("1", "1", "1", null,authorization, appName,  jsonKeyspace, keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createKeySpace("1", "1", "1", null, authorization, appName, jsonKeyspace,
+                keyspaceName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        assertEquals(200,response.getStatus());
+        assertEquals(200, response.getStatus());
     }
 
     @Test
@@ -200,24 +201,29 @@ public class TestRestMusicData {
         JsonKeySpace jsonKeyspace = new JsonKeySpace();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, Object> replicationInfo = new HashMap<>();
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createKeySpace("1", "1", "1", null, authorization,appName, jsonKeyspace, keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createKeySpace("1", "1", "1", null, authorization, appName, jsonKeyspace,
+                keyspaceName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        assertEquals(400,response.getStatus());
+        assertEquals(400, response.getStatus());
     }
-//MusicCore.autheticateUser
+
+    // MusicCore.autheticateUser
     @Test
     public void Test2_createKeyspace01() throws Exception {
         JsonKeySpace jsonKeyspace = new JsonKeySpace();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, Object> replicationInfo = new HashMap<>();
         String appName1 = "test";
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createKeySpace("1", "1", "1", null,authorization, appName1, jsonKeyspace, keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createKeySpace("1", "1", "1", null, authorization, appName1, jsonKeyspace,
+                keyspaceName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        assertEquals(401,response.getStatus());
+        assertEquals(401, response.getStatus());
     }
 
     @Test
@@ -232,12 +238,13 @@ public class TestRestMusicData {
         jsonKeyspace.setDurabilityOfWrites("true");
         jsonKeyspace.setKeyspaceName("TestApp1");
         jsonKeyspace.setReplicationInfo(replicationInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createKeySpace("1", "1", "1", null,authorization, "TestApp1",
-                        jsonKeyspace, keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createKeySpace("1", "1", "1", null, authorization, "TestApp1", jsonKeyspace,
+                keyspaceName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        assertEquals(401,response.getStatus());
+        assertEquals(401, response.getStatus());
     }
 
     @Test
@@ -252,22 +259,24 @@ public class TestRestMusicData {
         jsonKeyspace.setDurabilityOfWrites("true");
         jsonKeyspace.setKeyspaceName(keyspaceName);
         jsonKeyspace.setReplicationInfo(replicationInfo);
-        //Map<String, Object> m1= new HashMap<>() ;
-        //Mockito.when(CachingUtil.verifyOnboarding("x","y","x")).thenReturn(m1);
-        //Mockito.when(CachingUtil.verifyOnboarding(appNamex,userId,password).thenReturn(m1));
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        String authDatax = ":"+password;
+        // Map<String, Object> m1= new HashMap<>() ;
+        // Mockito.when(CachingUtil.verifyOnboarding("x","y","x")).thenReturn(m1);
+        // Mockito.when(CachingUtil.verifyOnboarding(appNamex,userId,password).thenReturn(m1));
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        String authDatax = ":" + password;
         String authorizationx = new String(Base64.encode(authDatax.getBytes()));
         try {
-        Response response = data.createKeySpace("1", "1", "1", null,authorizationx, appName,  jsonKeyspace, keyspaceName);
-        System.out.println("#######status is " + response.getStatus());
-        System.out.println("Entity" + response.getEntity());
-        assertNotEquals(200,response.getStatus());
-        } catch (RuntimeException e ) {
-          System.out.println("#######status is runtime exception= " + e);
+            Response response = data.createKeySpace("1", "1", "1", null, authorizationx, appName, jsonKeyspace,
+                    keyspaceName);
+            System.out.println("#######status is " + response.getStatus());
+            System.out.println("Entity" + response.getEntity());
+            assertNotEquals(200, response.getStatus());
+        } catch (RuntimeException e) {
+            System.out.println("#######status is runtime exception= " + e);
         }
     }
-    
+
     @Test
     public void Test3_createTable() throws Exception {
         JsonTable jsonTable = new JsonTable();
@@ -283,16 +292,15 @@ public class TestRestMusicData {
         jsonTable.setPrimaryKey("emp_name");
         jsonTable.setTableName(tableName);
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",appName, authorization, 
-                        jsonTable, keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertEquals(200, response.getStatus());
     }
-    
-    
+
     @Test
     public void Test3_createTableClusterOrderBad() throws Exception {
         JsonTable jsonTable = new JsonTable();
@@ -309,15 +317,15 @@ public class TestRestMusicData {
         jsonTable.setClusteringOrder("ASC");
         jsonTable.setTableName(tableName);
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",appName, authorization, 
-                        jsonTable, keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertNotEquals(200, response.getStatus());
     }
-     
+
     @Test
     public void Test3_createTable_withPropertiesNotNull() throws Exception {
         JsonTable jsonTable = new JsonTable();
@@ -329,24 +337,24 @@ public class TestRestMusicData {
         fields.put("PRIMARY KEY", "(emp_name)");
         consistencyInfo.put("type", "eventual");
         Map<String, Object> properties = new HashMap<>();
-        properties.put("comment","Testing prperties not null");
+        properties.put("comment", "Testing prperties not null");
         jsonTable.setConsistencyInfo(consistencyInfo);
         jsonTable.setKeyspaceName(keyspaceName);
         jsonTable.setPrimaryKey("emp_name");
-        String tableName_prop=tableName+"_Prop";
+        String tableName_prop = tableName + "_Prop";
         jsonTable.setTableName(tableName_prop);
         jsonTable.setFields(fields);
         jsonTable.setProperties(properties);
-        
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",appName, authorization, 
-                        jsonTable, keyspaceName, tableName_prop);
+
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableName_prop);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertEquals(200, response.getStatus());
     }
-    
+
     @Test
     public void Test3_createTable_duplicateTable() throws Exception {
         JsonTable jsonTable = new JsonTable();
@@ -360,26 +368,25 @@ public class TestRestMusicData {
         jsonTable.setConsistencyInfo(consistencyInfo);
         jsonTable.setKeyspaceName(keyspaceName);
         jsonTable.setPrimaryKey("emp_name");
-        String tableNameDup=tableName+"X";
+        String tableNameDup = tableName + "X";
         jsonTable.setTableName(tableNameDup);
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameDup);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameDup);
         System.out.println("#######status for 1st time " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        
-        Response response0 = data.createTable("1", "1", "1",
-                "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                jsonTable, keyspaceName, tableNameDup);
+
+        Response response0 = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameDup);
         // 400 is the duplicate status found in response
-        // Music 113 duplicate testing 
-        //import static org.junit.Assert.assertNotEquals;
+        // Music 113 duplicate testing
+        // import static org.junit.Assert.assertNotEquals;
         System.out.println("#######status for 2nd time " + response0.getStatus());
         System.out.println("Entity" + response0.getEntity());
-        
-        assertFalse("Duplicate table not created for "+tableNameDup, 200==response0.getStatus());
+
+        assertFalse("Duplicate table not created for " + tableNameDup, 200 == response0.getStatus());
 
     }
 
@@ -399,10 +406,10 @@ public class TestRestMusicData {
         jsonTable.setPrimaryKey("emp_name");
         jsonTable.setTableName(tableName);
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, wrongAuthorization,
-                        jsonTable, keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                wrongAuthorization, jsonTable, keyspaceName, tableName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertEquals(401, response.getStatus());
@@ -424,19 +431,19 @@ public class TestRestMusicData {
         jsonTable.setPrimaryKey("emp_name");
         jsonTable.setTableName(tableName);
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, "wrong", tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, "wrong", tableName);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertEquals(401, response.getStatus());
     }
-    
+
     // Improper parenthesis in key field
     @Test
     public void Test3_createTable_badParantesis() throws Exception {
-        String tableNameC ="testTable0";
+        String tableNameC = "testTable0";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -452,21 +459,20 @@ public class TestRestMusicData {
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_id Desc");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        //assertEquals(400, response.getStatus());
+        // assertEquals(400, response.getStatus());
         assertTrue(200 != response.getStatus());
     }
-    
 
     // good clustering key
     @Test
     public void Test3_createTable_1_clusterKey_good() throws Exception {
-        String tableNameC ="testTableC1";
+        String tableNameC = "testTableC1";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -477,14 +483,14 @@ public class TestRestMusicData {
         consistencyInfo.put("type", "eventual");
         jsonTable.setConsistencyInfo(consistencyInfo);
         jsonTable.setKeyspaceName(keyspaceName);
-       // jsonTable.setPrimaryKey("emp_name");
+        // jsonTable.setPrimaryKey("emp_name");
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_salary ASC");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertEquals(200, response.getStatus());
@@ -493,7 +499,7 @@ public class TestRestMusicData {
     // bad partition key=clustering key
     @Test
     public void Test3_createTable_2_clusterKey_bad() throws Exception {
-        String tableNameC ="testTableC2";
+        String tableNameC = "testTableC2";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -504,23 +510,24 @@ public class TestRestMusicData {
         consistencyInfo.put("type", "eventual");
         jsonTable.setConsistencyInfo(consistencyInfo);
         jsonTable.setKeyspaceName(keyspaceName);
-        jsonTable.setPrimaryKey("emp_name");  // "PRIMARY KEY" overrides if primaryKey present
+        jsonTable.setPrimaryKey("emp_name"); // "PRIMARY KEY" overrides if
+                                                // primaryKey present
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_salary ASC");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        assertTrue(200 !=response.getStatus());
+        assertTrue(200 != response.getStatus());
     }
 
     // good composite partition key,clustering key
     @Test
     public void Test3_createTable_3_partition_clusterKey_good() throws Exception {
-        String tableNameC ="testTableC3";
+        String tableNameC = "testTableC3";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -536,10 +543,10 @@ public class TestRestMusicData {
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_salary ASC");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertEquals(200, response.getStatus());
@@ -548,7 +555,7 @@ public class TestRestMusicData {
     // bad - not all cols in order by of composite partition key,clustering key
     @Test
     public void Test3_createTable_4_clusteringOrder_bad() throws Exception {
-        String tableNameC ="testTableC4";
+        String tableNameC = "testTableC4";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -564,10 +571,10 @@ public class TestRestMusicData {
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_salary ASC");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertTrue(200 != response.getStatus());
@@ -576,7 +583,7 @@ public class TestRestMusicData {
     // bad - wrong cols in order by of composite partition key,clustering key
     @Test
     public void Test3_createTable_5_clusteringOrder_bad() throws Exception {
-        String tableNameC ="testTableC5";
+        String tableNameC = "testTableC5";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -592,19 +599,19 @@ public class TestRestMusicData {
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_idx desc, emp_salary ASC");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertTrue(200 != response.getStatus());
     }
-    
+
     // bad - wrong cols in order by of composite partition key,clustering key
     @Test
     public void Test3_createTable_6_clusteringOrder_bad() throws Exception {
-        String tableNameC ="testTableC6";
+        String tableNameC = "testTableC6";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -616,24 +623,24 @@ public class TestRestMusicData {
         consistencyInfo.put("type", "eventual");
         jsonTable.setConsistencyInfo(consistencyInfo);
         jsonTable.setKeyspaceName(keyspaceName);
-        jsonTable.setPrimaryKey("((uuid,emp_name),emp_id,emp_salary)"); // overridden by
+        jsonTable.setPrimaryKey("((uuid,emp_name),emp_id,emp_salary)"); // overridden
+                                                                        // by
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_id desc, emp_salary ASC,uuid desc");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
         assertTrue(200 != response.getStatus());
     }
 
-
     // good clustering key, need to pass queryparameter
     @Test
     public void Test3_createTableIndex_1() throws Exception {
-        String tableNameC ="testTableCinx";
+        String tableNameC = "testTableCinx";
         JsonTable jsonTable = new JsonTable();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, String> fields = new HashMap<>();
@@ -644,29 +651,30 @@ public class TestRestMusicData {
         consistencyInfo.put("type", "eventual");
         jsonTable.setConsistencyInfo(consistencyInfo);
         jsonTable.setKeyspaceName(keyspaceName);
-       // jsonTable.setPrimaryKey("emp_name");
+        // jsonTable.setPrimaryKey("emp_name");
         jsonTable.setTableName(tableNameC);
         jsonTable.setClusteringOrder("emp_salary ASC");
         jsonTable.setFields(fields);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.createTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonTable, keyspaceName, tableNameC);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonTable, keyspaceName, tableNameC);
         System.out.println("#######status is " + response.getStatus());
         System.out.println("Entity" + response.getEntity());
-        // if 200 print to log otherwise fail assertEquals(200, response.getStatus());
-       // info.setQueryParameters("index_name=inx_uuid");
-        Map<String,String> queryParametersMap =new HashMap<String, String>();
+        // if 200 print to log otherwise fail assertEquals(200,
+        // response.getStatus());
+        // info.setQueryParameters("index_name=inx_uuid");
+        Map<String, String> queryParametersMap = new HashMap<String, String>();
 
-        queryParametersMap.put("index_name","inxuuid");
-       // Mockito.when(info.getQueryParameters()).thenReturn(new MultivaluedMap<String, String>(queryParametersMap));
+        queryParametersMap.put("index_name", "inxuuid");
+        // Mockito.when(info.getQueryParameters()).thenReturn(new
+        // MultivaluedMap<String, String>(queryParametersMap));
         try {
-        response = data.createIndex("1", "1", "1",
-                "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                 keyspaceName, tableNameC,"uuid",info);
-        assertEquals(200, response.getStatus());
+            response = data.createIndex("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
+                    keyspaceName, tableNameC, "uuid", info);
+            assertEquals(200, response.getStatus());
         } catch (NullPointerException e) {
-          
+
         }
     }
 
@@ -683,9 +691,10 @@ public class TestRestMusicData {
         jsonInsert.setKeyspaceName(keyspaceName);
         jsonInsert.setTableName(tableName);
         jsonInsert.setValues(values);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",
-                appName, authorization, jsonInsert, keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonInsert, keyspaceName, tableName);
         assertEquals(200, response.getStatus());
     }
 
@@ -702,10 +711,10 @@ public class TestRestMusicData {
         jsonInsert.setKeyspaceName(keyspaceName);
         jsonInsert.setTableName(tableName);
         jsonInsert.setValues(values);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.insertIntoTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonInsert, keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonInsert, keyspaceName, tableName);
         assertEquals(200, response.getStatus());
     }
 
@@ -723,10 +732,10 @@ public class TestRestMusicData {
         jsonInsert.setKeyspaceName(keyspaceName);
         jsonInsert.setTableName(tableName);
         jsonInsert.setValues(values);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.insertIntoTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, wrongAuthorization,
-                        jsonInsert, keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                wrongAuthorization, jsonInsert, keyspaceName, tableName);
         assertEquals(401, response.getStatus());
     }
 
@@ -744,14 +753,13 @@ public class TestRestMusicData {
         jsonInsert.setKeyspaceName(keyspaceName);
         jsonInsert.setTableName(tableName);
         jsonInsert.setValues(values);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.insertIntoTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonInsert, keyspaceName, "wrong");
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonInsert, keyspaceName, "wrong");
         assertEquals(400, response.getStatus());
     }
-    
-    
+
     @Test
     public void Test5_updateTable() throws Exception {
         JsonUpdate jsonUpdate = new JsonUpdate();
@@ -765,17 +773,18 @@ public class TestRestMusicData {
         jsonUpdate.setKeyspaceName(keyspaceName);
         jsonUpdate.setTableName(tableName);
         jsonUpdate.setValues(values);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
         Mockito.when(info.getQueryParameters()).thenReturn(row);
         Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
                 authorization, jsonUpdate, keyspaceName, tableName, info);
         assertEquals(200, response.getStatus());
-    } 
-   
+    }
+
     // need mock code to create error for MusicCore methods
     @Test
     public void Test5_updateTableAuthE() throws Exception {
-      //MockitoAnnotations.initMocks(this);
+        // MockitoAnnotations.initMocks(this);
         JsonUpdate jsonUpdate = new JsonUpdate();
         Map<String, String> consistencyInfo = new HashMap<>();
         MultivaluedMap<String, String> row = new MultivaluedMapImpl();
@@ -787,20 +796,21 @@ public class TestRestMusicData {
         jsonUpdate.setKeyspaceName(keyspaceName);
         jsonUpdate.setTableName(tableName);
         jsonUpdate.setValues(values);
-        //add ttl & timestamp
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
+        // add ttl & timestamp
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
         Mockito.when(info.getQueryParameters()).thenReturn(row);
-        //Map<String, Object> m1= new HashMap<>() ;
-        //Mockito.when(MusicCore.autheticateUser(appName,userId,password,keyspaceName,"abc66ccc-d857-4e90-b1e5-df98a3d40ce6","updateTable")).thenReturn(m1);
+        // Map<String, Object> m1= new HashMap<>() ;
+        // Mockito.when(MusicCore.autheticateUser(appName,userId,password,keyspaceName,"abc66ccc-d857-4e90-b1e5-df98a3d40ce6","updateTable")).thenReturn(m1);
         try {
-        Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
-                authorization, jsonUpdate, keyspaceName, tableName, info);
-        assertEquals(200, response.getStatus());
-        } catch(NullPointerException e) {
-          
+            Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                    authorization, jsonUpdate, keyspaceName, tableName, info);
+            assertEquals(200, response.getStatus());
+        } catch (NullPointerException e) {
+
         }
-    } 
-    
+    }
+
     @Test
     public void Test5_updateTableAuthException1() throws Exception {
         JsonUpdate jsonUpdate = new JsonUpdate();
@@ -814,18 +824,19 @@ public class TestRestMusicData {
         jsonUpdate.setKeyspaceName(keyspaceName);
         jsonUpdate.setTableName(tableName);
         jsonUpdate.setValues(values);
-        
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        //Mockito.when(info.getQueryParameters()).thenReturn(row);
-        String authDatax = ":";//+password;
+
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        // Mockito.when(info.getQueryParameters()).thenReturn(row);
+        String authDatax = ":";// +password;
         String authorizationx = new String(Base64.encode(authDatax.getBytes()));
         try {
-        Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
-                       authorizationx, jsonUpdate, keyspaceName, tableName, info);
-              assertEquals(200, response.getStatus());
-        } catch(RuntimeException e) {
-           System.out.println("Update table Runtime exception="+e);
-          
+            Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                    authorizationx, jsonUpdate, keyspaceName, tableName, info);
+            assertEquals(200, response.getStatus());
+        } catch (RuntimeException e) {
+            System.out.println("Update table Runtime exception=" + e);
+
         }
     }
 
@@ -842,24 +853,25 @@ public class TestRestMusicData {
         jsonUpdate.setKeyspaceName(keyspaceName);
         jsonUpdate.setTableName(tableName);
         jsonUpdate.setValues(values);
-        
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        //Mockito.when(info.getQueryParameters()).thenReturn(row);
-        String authDatax =":"+password;
+
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        // Mockito.when(info.getQueryParameters()).thenReturn(row);
+        String authDatax = ":" + password;
         String authorizationx = new String(Base64.encode(authDatax.getBytes()));
-        String appNamex="xx";
+        String appNamex = "xx";
         try {
-            // Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
-               Response response = data.updateTable("1", "1", "1", "", appNamex,
-                authorizationx, jsonUpdate, keyspaceName, tableName, info);
-              assertEquals(200, response.getStatus());
-        } catch(RuntimeException e) {
-           System.out.println("Update table Runtime exception="+e);
-          
+            // Response response = data.updateTable("1", "1", "1",
+            // "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+            Response response = data.updateTable("1", "1", "1", "", appNamex, authorizationx, jsonUpdate, keyspaceName,
+                    tableName, info);
+            assertEquals(200, response.getStatus());
+        } catch (RuntimeException e) {
+            System.out.println("Update table Runtime exception=" + e);
+
         }
     }
 
-    
     @Test
     public void Test6_select() throws Exception {
         JsonSelect jsonSelect = new JsonSelect();
@@ -868,13 +880,14 @@ public class TestRestMusicData {
         row.add("emp_name", "testName");
         consistencyInfo.put("type", "atomic");
         jsonSelect.setConsistencyInfo(consistencyInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
         Mockito.when(info.getQueryParameters()).thenReturn(row);
-        Response response = data.select("1", "1", "1","abc66ccc-d857-4e90-b1e5-df98a3d40ce6", 
-                        appName, authorization, keyspaceName, tableName, info);
-        HashMap<String,HashMap<String,Object>> map = (HashMap<String, HashMap<String, Object>>) response.getEntity();
+        Response response = data.select("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
+                keyspaceName, tableName, info);
+        HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) response.getEntity();
         HashMap<String, Object> result = map.get("result");
-        assertEquals("2500", ((HashMap<String,Object>) result.get("row 0")).get("emp_salary").toString());
+        assertEquals("2500", ((HashMap<String, Object>) result.get("row 0")).get("emp_salary").toString());
     }
 
     @Test
@@ -885,13 +898,14 @@ public class TestRestMusicData {
         row.add("emp_name", "testName");
         consistencyInfo.put("type", "atomic");
         jsonInsert.setConsistencyInfo(consistencyInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
         Mockito.when(info.getQueryParameters()).thenReturn(row);
-        Response response = data.selectCritical("1", "1", "1","abc66ccc-d857-4e90-b1e5-df98a3d40ce6", 
-                        appName, authorization, jsonInsert, keyspaceName, tableName,info);
-        HashMap<String,HashMap<String,Object>> map = (HashMap<String, HashMap<String, Object>>) response.getEntity();
+        Response response = data.selectCritical("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonInsert, keyspaceName, tableName, info);
+        HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) response.getEntity();
         HashMap<String, Object> result = map.get("result");
-        assertEquals("2500", ((HashMap<String,Object>) result.get("row 0")).get("emp_salary").toString());
+        assertEquals("2500", ((HashMap<String, Object>) result.get("row 0")).get("emp_salary").toString());
     }
 
     @Test
@@ -902,11 +916,11 @@ public class TestRestMusicData {
         row.add("emp_name", "test1");
         consistencyInfo.put("type", "atomic");
         jsonDelete.setConsistencyInfo(consistencyInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
         Mockito.when(info.getQueryParameters()).thenReturn(row);
-        Response response = data.deleteFromTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonDelete, keyspaceName, tableName, info);
+        Response response = data.deleteFromTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonDelete, keyspaceName, tableName, info);
         assertEquals(200, response.getStatus());
     }
 
@@ -919,11 +933,11 @@ public class TestRestMusicData {
         MultivaluedMap<String, String> row = new MultivaluedMapImpl();
         consistencyInfo.put("type", "atomic");
         jsonDelete.setConsistencyInfo(consistencyInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
         Mockito.when(info.getQueryParameters()).thenReturn(row);
-        Response response = data.deleteFromTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        jsonDelete, keyspaceName, tableName, info);
+        Response response = data.deleteFromTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, jsonDelete, keyspaceName, tableName, info);
         assertEquals(400, response.getStatus());
     }
 
@@ -936,11 +950,11 @@ public class TestRestMusicData {
         row.add("emp_name", "test1");
         consistencyInfo.put("type", "atomic");
         jsonDelete.setConsistencyInfo(consistencyInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        //Mockito.when(info.getQueryParameters()).thenReturn(row);
-        Response response = data.deleteFromTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                        null, keyspaceName, tableName, info);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        // Mockito.when(info.getQueryParameters()).thenReturn(row);
+        Response response = data.deleteFromTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, null, keyspaceName, tableName, info);
         assertEquals(400, response.getStatus());
     }
 
@@ -950,14 +964,13 @@ public class TestRestMusicData {
         Map<String, String> consistencyInfo = new HashMap<>();
         consistencyInfo.put("type", "atomic");
         jsonTable.setConsistencyInfo(consistencyInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.dropTable("1", "1", "1",
-                        "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization,
-                         keyspaceName, tableName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.dropTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
+                authorization, keyspaceName, tableName);
         assertEquals(200, response.getStatus());
     }
 
-    
     @Test
     public void Test8_deleteKeyspace() throws Exception {
         JsonKeySpace jsonKeyspace = new JsonKeySpace();
@@ -970,12 +983,13 @@ public class TestRestMusicData {
         jsonKeyspace.setDurabilityOfWrites("true");
         jsonKeyspace.setKeyspaceName("TestApp1");
         jsonKeyspace.setReplicationInfo(replicationInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",
-                       authorization,appName,  keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", authorization,
+                appName, keyspaceName);
         assertEquals(200, response.getStatus());
     }
-    
+
     @Test
     public void Test8_deleteKeyspace2() throws Exception {
         JsonKeySpace jsonKeyspace = new JsonKeySpace();
@@ -988,9 +1002,10 @@ public class TestRestMusicData {
         jsonKeyspace.setDurabilityOfWrites("true");
         jsonKeyspace.setKeyspaceName("TestApp1");
         jsonKeyspace.setReplicationInfo(replicationInfo);
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",
-                       wrongAuthorization, appName, keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", wrongAuthorization,
+                appName, keyspaceName);
         assertEquals(401, response.getStatus());
     }
 
@@ -999,137 +1014,123 @@ public class TestRestMusicData {
         JsonKeySpace jsonKeyspace = new JsonKeySpace();
         Map<String, String> consistencyInfo = new HashMap<>();
         Map<String, Object> replicationInfo = new HashMap<>();
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Response response = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6",
-                       authorization,  appName,  keyspaceName);
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Response response = data.dropKeySpace("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", authorization,
+                appName, keyspaceName);
         assertEquals(400, response.getStatus());
     }
 
-    
-    
-    @Test
-    public void Test6_onboard() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setAppname("TestApp2");
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setUserId("TestUser2");
-        jsonOnboard.setPassword("TestPassword2");
-        Map<String, Object> resultMap = (Map<String, Object>) admin.onboardAppWithMusic(jsonOnboard).getEntity();
-        resultMap.containsKey("success");
-        onboardUUID = resultMap.get("Generated AID").toString();
-        assertEquals("Your application TestApp2 has been onboarded with MUSIC.", resultMap.get("Success"));
-    }
-    // Missing appname
-    @Test
-    public void Test6_onboard1() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setUserId("TestUser2");
-        jsonOnboard.setPassword("TestPassword2");
-        Map<String, Object> resultMap = (Map<String, Object>) admin.onboardAppWithMusic(jsonOnboard).getEntity();
-        resultMap.containsKey("success");
-        System.out.println("--->" + resultMap.toString());
-        assertEquals("Unauthorized: Please check the request parameters. Some of the required values appName(ns), userId, password, isAAF are missing.", resultMap.get("Exception"));
-    }
-
-    
-    @Test
-    public void Test7_onboardSearch() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setAppname("TestApp2");
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setAid(onboardUUID);
-        Map<String, Object> resultMap = (Map<String, Object>) admin.getOnboardedInfoSearch(jsonOnboard).getEntity();
-        resultMap.containsKey("success");
-        assertEquals(MusicUtil.DEFAULTKEYSPACENAME, resultMap.get(onboardUUID));
-
-    }
-
-    // Missing appname
-    @Test
-    public void Test7_onboardSearch1() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setAid(onboardUUID);
-        Map<String, Object> resultMap = (Map<String, Object>) admin.getOnboardedInfoSearch(jsonOnboard).getEntity();
-        System.out.println("--->" + resultMap.toString());
-        resultMap.containsKey("success");
-        assertEquals(MusicUtil.DEFAULTKEYSPACENAME, resultMap.get(onboardUUID));
-
-    }
-
-    @Test
-    public void Test8_onboardUpdate() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setUserId("TestUser3");
-        jsonOnboard.setPassword("TestPassword3");
-        jsonOnboard.setAid(onboardUUID);
-        Map<String, Object> resultMap = (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
-        System.out.println("--->" + resultMap.toString());
-        resultMap.containsKey("success");
-        assertEquals("Your application has been updated successfully", resultMap.get("Success"));
-    }
-
-    // Aid null
-    @Test
-    public void Test8_onboardUpdate1() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setUserId("TestUser3");
-        jsonOnboard.setPassword("TestPassword3");
-        Map<String, Object> resultMap = (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
-        System.out.println("--->" + resultMap.toString());
-        resultMap.containsKey("success");
-        assertEquals("Please make sure Aid is present", resultMap.get("Exception"));
-    }
-
-    // Appname not null
-    @Test
-    public void Test8_onboardUpdate2() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setAppname("TestApp2");
-        jsonOnboard.setIsAAF("false");
-        jsonOnboard.setUserId("TestUser3");
-        jsonOnboard.setPassword("TestPassword3");
-        jsonOnboard.setAid(onboardUUID);
-        Map<String, Object> resultMap = (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
-        resultMap.containsKey("success");
-        System.out.println("--->" + resultMap.toString());
-        assertEquals("Application TestApp2 has already been onboarded. Please contact admin.", resultMap.get("Exception"));
-    }
-
-    // All null
-    @Test
-    public void Test8_onboardUpdate3() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setAid(onboardUUID);
-        Map<String, Object> resultMap = (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
-        assertTrue(resultMap.containsKey("Exception") );
-    }
-
-    @Test
-    public void Test9_onboardDelete() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        jsonOnboard.setAppname("TestApp2");
-        jsonOnboard.setAid(onboardUUID);
-        Map<String, Object> resultMap = (Map<String, Object>) admin.deleteOnboardApp(jsonOnboard).getEntity();
-        resultMap.containsKey("success");
-        assertEquals("Your application has been deleted successfully", resultMap.get("Success"));
-    }
-
-    @Test
-    public void Test9_onboardDelete1() throws Exception {
-        JsonOnboard jsonOnboard = new JsonOnboard();
-        Map<String, Object> resultMap = (Map<String, Object>) admin.deleteOnboardApp(jsonOnboard).getEntity();
-        assertTrue(resultMap.containsKey("Exception"));
-    }
+    /*
+     * @Test public void Test6_onboard() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setAppname("TestApp2");
+     * jsonOnboard.setIsAAF("false"); jsonOnboard.setUserId("TestUser2");
+     * jsonOnboard.setPassword("TestPassword2"); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.onboardAppWithMusic(jsonOnboard).getEntity();
+     * resultMap.containsKey("success"); onboardUUID =
+     * resultMap.get("Generated AID").toString();
+     * assertEquals("Your application TestApp2 has been onboarded with MUSIC.",
+     * resultMap.get("Success")); } // Missing appname
+     * 
+     * @Test public void Test6_onboard1() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setIsAAF("false");
+     * jsonOnboard.setUserId("TestUser2");
+     * jsonOnboard.setPassword("TestPassword2"); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.onboardAppWithMusic(jsonOnboard).getEntity();
+     * resultMap.containsKey("success"); System.out.println("--->" +
+     * resultMap.toString());
+     * assertEquals("Unauthorized: Please check the request parameters. Some of the required values appName(ns), userId, password, isAAF are missing."
+     * , resultMap.get("Exception")); }
+     * 
+     * 
+     * @Test public void Test7_onboardSearch() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setAppname("TestApp2");
+     * jsonOnboard.setIsAAF("false"); jsonOnboard.setAid(onboardUUID);
+     * Map<String, Object> resultMap = (Map<String, Object>)
+     * admin.getOnboardedInfoSearch(jsonOnboard).getEntity();
+     * resultMap.containsKey("success");
+     * assertEquals(MusicUtil.DEFAULTKEYSPACENAME, resultMap.get(onboardUUID));
+     * 
+     * }
+     * 
+     * // Missing appname
+     * 
+     * @Test public void Test7_onboardSearch1() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setIsAAF("false");
+     * jsonOnboard.setAid(onboardUUID); Map<String, Object> resultMap =
+     * (Map<String, Object>)
+     * admin.getOnboardedInfoSearch(jsonOnboard).getEntity();
+     * System.out.println("--->" + resultMap.toString());
+     * resultMap.containsKey("success");
+     * assertEquals(MusicUtil.DEFAULTKEYSPACENAME, resultMap.get(onboardUUID));
+     * 
+     * }
+     * 
+     * @Test public void Test8_onboardUpdate() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setIsAAF("false");
+     * jsonOnboard.setUserId("TestUser3");
+     * jsonOnboard.setPassword("TestPassword3");
+     * jsonOnboard.setAid(onboardUUID); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
+     * System.out.println("--->" + resultMap.toString());
+     * resultMap.containsKey("success");
+     * assertEquals("Your application has been updated successfully",
+     * resultMap.get("Success")); }
+     * 
+     * // Aid null
+     * 
+     * @Test public void Test8_onboardUpdate1() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setIsAAF("false");
+     * jsonOnboard.setUserId("TestUser3");
+     * jsonOnboard.setPassword("TestPassword3"); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
+     * System.out.println("--->" + resultMap.toString());
+     * resultMap.containsKey("success");
+     * assertEquals("Please make sure Aid is present",
+     * resultMap.get("Exception")); }
+     * 
+     * // Appname not null
+     * 
+     * @Test public void Test8_onboardUpdate2() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setAppname("TestApp2");
+     * jsonOnboard.setIsAAF("false"); jsonOnboard.setUserId("TestUser3");
+     * jsonOnboard.setPassword("TestPassword3");
+     * jsonOnboard.setAid(onboardUUID); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.updateOnboardApp(jsonOnboard).getEntity();
+     * resultMap.containsKey("success"); System.out.println("--->" +
+     * resultMap.toString());
+     * assertEquals("Application TestApp2 has already been onboarded. Please contact admin."
+     * , resultMap.get("Exception")); }
+     * 
+     * // All null
+     * 
+     * @Test public void Test8_onboardUpdate3() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setAid(onboardUUID);
+     * Map<String, Object> resultMap = (Map<String, Object>)
+     * admin.updateOnboardApp(jsonOnboard).getEntity();
+     * assertTrue(resultMap.containsKey("Exception") ); }
+     * 
+     * @Test public void Test9_onboardDelete() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); jsonOnboard.setAppname("TestApp2");
+     * jsonOnboard.setAid(onboardUUID); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.deleteOnboardApp(jsonOnboard).getEntity();
+     * resultMap.containsKey("success");
+     * assertEquals("Your application has been deleted successfully",
+     * resultMap.get("Success")); }
+     * 
+     * @Test public void Test9_onboardDelete1() throws Exception { JsonOnboard
+     * jsonOnboard = new JsonOnboard(); Map<String, Object> resultMap =
+     * (Map<String, Object>) admin.deleteOnboardApp(jsonOnboard).getEntity();
+     * assertTrue(resultMap.containsKey("Exception")); }
+     */
 
     @Ignore
     @Test
     public void Test3_createLockReference() throws Exception {
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Map<String, Object> resultMap = (Map<String, Object>) lock.createLockReference(lockName,"1","1",authorization, null, appName).getEntity();
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Map<String, Object> resultMap = (Map<String, Object>) lock
+                .createLockReference(lockName, "1", "1", authorization, null, appName).getEntity();
         @SuppressWarnings("unchecked")
         Map<String, Object> resultMap1 = (Map<String, Object>) resultMap.get("lock");
         lockId = (String) resultMap1.get("lock");
@@ -1139,26 +1140,31 @@ public class TestRestMusicData {
     @Ignore
     @Test
     public void Test4_accquireLock() throws Exception {
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Map<String, Object> resultMap = (Map<String, Object>) lock.accquireLock(lockId,"1","1",authorization, null, appName).getEntity();
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Map<String, Object> resultMap = (Map<String, Object>) lock
+                .accquireLock(lockId, "1", "1", authorization, null, appName).getEntity();
         assertEquals(ResultType.SUCCESS, resultMap.get("status"));
     }
 
     @Ignore
     @Test
     public void Test5_currentLockHolder() throws Exception {
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Map<String, Object> resultMap = (Map<String, Object>) lock.currentLockHolder(lockName,"1","1",authorization, null, appName).getEntity();
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Map<String, Object> resultMap = (Map<String, Object>) lock
+                .currentLockHolder(lockName, "1", "1", authorization, null, appName).getEntity();
         assertEquals(ResultType.SUCCESS, resultMap.get("status"));
     }
-    
+
     @Ignore
     @Test
     public void Test7_unLock() throws Exception {
-        //Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
-        Map<String, Object> resultMap = (Map<String, Object>) lock.unLock(lockId,"1","1",authorization, null, appName).getEntity();
+        // Mockito.doNothing().when(http).addHeader(xLatestVersion,
+        // MusicUtil.getVersion());
+        Map<String, Object> resultMap = (Map<String, Object>) lock
+                .unLock(lockId, "1", "1", authorization, null, appName).getEntity();
         assertEquals(ResultType.SUCCESS, resultMap.get("status"));
     }
 
-
 }
\ No newline at end of file