diff options
author | Thomas Nelson arthudent3 <nelson24@att.com> | 2019-06-19 22:19:10 +0000 |
---|---|---|
committer | Thomas Nelson arthudent3 <nelson24@att.com> | 2019-06-25 13:20:59 +0000 |
commit | 881f14bc8676cedd68e17bd007a869fa85578fa1 (patch) | |
tree | 0dc37c36af2483d5d0925dd84993f93f344688f8 /src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java | |
parent | 078f69315e4b4faffc50e1c7dfde717396e48194 (diff) |
Some bug fixes and Minor Chages.
Remove some Commented out code.
Cleaned up Variables.
Encryption of passwords added
Updated Test Cases
Fixed some errors in how they were reported.
Reduced Logging clutter
Some Vulnerability fixes.
Change-Id: I64c7935d167d4a976681b5a18fd51aa667d0cd95
Issue-ID: MUSIC-413
Signed-off-by: Thomas Nelson arthudent3 <nelson24@att.com>
Diffstat (limited to 'src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java')
-rw-r--r-- | src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java b/src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java index 3bf33179..407d0323 100644 --- a/src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java +++ b/src/test/java/org/onap/music/unittests/TstRestMusicDataAPI.java @@ -194,6 +194,16 @@ public class TstRestMusicDataAPI { System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); assertEquals(200, response.getStatus()); } + + @Test + public void test3_createTableNoBody() throws Exception { + System.out.println("Testing create table w/o body"); + + Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, + authorization, null, keyspaceName, tableName); + System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); + assertEquals(400, response.getStatus()); + } @Test public void test3_createTableNoName() throws Exception { @@ -312,7 +322,7 @@ public class TstRestMusicDataAPI { assertEquals(400, response2.getStatus()); Map<String, String> respMap = (Map<String, String>) response2.getEntity(); assertEquals(ResultType.FAILURE, respMap.get("status")); - assertEquals("Table " + keyspaceName + "." + tableNameDup + " already exists", respMap.get("error")); + assertEquals("AlreadyExistsException: Table " + keyspaceName + "." + tableNameDup + " already exists", respMap.get("error")); } @@ -539,8 +549,37 @@ public class TstRestMusicDataAPI { assertEquals(200, response.getStatus()); } + + @Test + public void test4_insertIntoTableNoBody() throws Exception { + System.out.println("Testing insert into table w/o body"); + createTable(); + Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, + authorization, null, keyspaceName, tableName); + System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); + + assertEquals(400, response.getStatus()); + } @Test + public void test4_insertIntoTableNoaValues() throws Exception { + System.out.println("Testing insert into table"); + createTable(); + JsonInsert jsonInsert = new JsonInsert(); + Map<String, String> consistencyInfo = new HashMap<>(); + consistencyInfo.put("type", "eventual"); + jsonInsert.setConsistencyInfo(consistencyInfo); + jsonInsert.setKeyspaceName(keyspaceName); + jsonInsert.setTableName(tableName); + + Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, + authorization, jsonInsert, keyspaceName, tableName); + System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); + + assertEquals(400, response.getStatus()); + } + + @Test public void test4_insertIntoTableNoValues() throws Exception { System.out.println("Testing insert into table"); createTable(); @@ -827,6 +866,23 @@ public class TstRestMusicDataAPI { @Test + public void test6_critical_select() throws Exception { + System.out.println("Testing critical select w/o body"); + createAndInsertIntoTable(); + MultivaluedMap<String, String> row = new MultivaluedMapImpl(); + row.add("emp_name", "testname"); + Mockito.when(info.getQueryParameters()).thenReturn(row); + Response response = data.selectCritical("1", "1", "1","abc66ccc-d857-4e90-b1e5-df98a3d40ce6", + appName, authorization, null, keyspaceName, tableName,info); + HashMap<String,HashMap<String,Object>> map = (HashMap<String, HashMap<String, Object>>) response.getEntity(); + HashMap<String, Object> result = map.get("result"); + System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); + + assertEquals(400, response.getStatus()); + } + + // Added during merge? + @Test public void test6_critical_selectCritical_nolockid() throws Exception { System.out.println("Testing critical select critical w/o lockid"); createAndInsertIntoTable(); @@ -872,8 +928,8 @@ public class TstRestMusicDataAPI { consistencyInfo.put("type", "atomic"); jsonSelect.setConsistencyInfo(consistencyInfo); Mockito.when(info.getQueryParameters()).thenReturn(row); - Response response = data.select("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization, - keyspaceName, tableName, info); + Response response = data.selectWithCritical("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName, authorization, + null,keyspaceName, tableName, info); HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) response.getEntity(); HashMap<String, Object> result = map.get("result"); System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); @@ -891,8 +947,8 @@ public class TstRestMusicDataAPI { Map<String, String> consistencyInfo = new HashMap<>(); consistencyInfo.put("type", "atomic"); jsonSelect.setConsistencyInfo(consistencyInfo); - Response response = data.select("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", - appName, wrongAuthorization, keyspaceName, null, info); + Response response = data.selectWithCritical("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", + appName, wrongAuthorization,null, keyspaceName, null, info); System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); assertEquals(400, response.getStatus()); |