X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Fmusic%2Funittests%2FTstRestMusicDataAPI.java;h=407d0323e77407bfc3628109cd1dacd961461a41;hb=refs%2Fchanges%2F01%2F90201%2F2;hp=3bf331791e43736ebc95d8ad827dc03451cfcf2b;hpb=078f69315e4b4faffc50e1c7dfde717396e48194;p=music.git 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 respMap = (Map) 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,7 +549,36 @@ 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 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"); @@ -826,6 +865,23 @@ public class TstRestMusicDataAPI { } + @Test + public void test6_critical_select() throws Exception { + System.out.println("Testing critical select w/o body"); + createAndInsertIntoTable(); + MultivaluedMap 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> map = (HashMap>) response.getEntity(); + HashMap 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"); @@ -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> map = (HashMap>) response.getEntity(); HashMap result = map.get("result"); System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); @@ -891,8 +947,8 @@ public class TstRestMusicDataAPI { Map 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());