{"action":"created","comment":{"url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/comments/224443589","pull_request_review_id":163809843,"id":224443589,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDQ0MzU4OQ==","diff_hunk":"@@ -0,0 +1,643 @@\n+package org.sunbird.cassandra;\n+\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertTrue;\n+import static org.mockito.Mockito.reset;\n+import static org.powermock.api.mockito.PowerMockito.when;\n+\n+import com.datastax.driver.core.*;\n+import com.datastax.driver.core.querybuilder.Delete;\n+import com.datastax.driver.core.querybuilder.QueryBuilder;\n+import com.datastax.driver.core.querybuilder.Select;\n+import com.google.common.util.concurrent.Uninterruptibles;\n+import java.util.*;\n+import org.junit.Before;\n+import org.junit.BeforeClass;\n+import org.junit.FixMethodOrder;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.junit.runners.MethodSorters;\n+import org.mockito.Mockito;\n+import org.powermock.api.mockito.PowerMockito;\n+import org.powermock.core.classloader.annotations.PowerMockIgnore;\n+import org.powermock.core.classloader.annotations.PrepareForTest;\n+import org.powermock.modules.junit4.PowerMockRunner;\n+import org.sunbird.cassandraimpl.CassandraOperationImpl;\n+import org.sunbird.common.CassandraUtil;\n+import org.sunbird.common.Constants;\n+import org.sunbird.common.exception.ProjectCommonException;\n+import org.sunbird.common.models.response.Response;\n+import org.sunbird.common.models.util.JsonKey;\n+import org.sunbird.common.models.util.PropertiesCache;\n+import org.sunbird.common.responsecode.ResponseCode;\n+import org.sunbird.helper.CassandraConnectionManagerImpl;\n+import org.sunbird.helper.CassandraConnectionMngrFactory;\n+import org.sunbird.helper.ServiceFactory;\n+\n+@FixMethodOrder(MethodSorters.NAME_ASCENDING)\n+/** @author kirti. Junit test cases */\n+@RunWith(PowerMockRunner.class)\n+@PrepareForTest({\n+  Cluster.class,\n+  CassandraOperationImpl.class,\n+  Uninterruptibles.class,\n+  PreparedStatement.class,\n+  BoundStatement.class,\n+  Session.class,\n+  Metadata.class,\n+  CassandraConnectionMngrFactory.class,\n+  ResultSet.class,\n+  CassandraUtil.class,\n+  Cluster.Builder.class,\n+  Select.class,\n+  Row.class,\n+  ColumnDefinitions.class,\n+  String.class,\n+  Select.Where.class,\n+  Select.Builder.class,\n+  QueryBuilder.class,\n+  Select.Selection.class,\n+  Delete.Where.class,\n+  Delete.Selection.class\n+})\n+@PowerMockIgnore(\"javax.management.*\")\n+public class CassandraMockTest {\n+\n+  private static Cluster cluster;\n+  private static Session session = PowerMockito.mock(Session.class);;\n+  private static PreparedStatement statement;\n+  private static ResultSet resultSet;\n+  private static Select selectQuery;\n+  private static Select.Where where;\n+  private static Delete.Where deleteWhere;\n+  private static Select.Builder selectBuilder;\n+  private static Metadata metadata;\n+  private static CassandraOperation operation;\n+  private static Map<String, Object> address = null;\n+  private static Map<String, Object> dummyAddress = null;\n+\n+  private static PropertiesCache cach = PropertiesCache.getInstance();\n+  private static String host = cach.getProperty(\"contactPoint\");\n+  private static String port = cach.getProperty(\"port\");\n+  private static String cassandraKeySpace = cach.getProperty(\"keyspace\");\n+\n+  private static final Cluster.Builder builder = PowerMockito.mock(Cluster.Builder.class);\n+  private static BoundStatement boundStatement;\n+  private static Select.Selection selectSelection;\n+  private static Delete.Selection deleteSelection;\n+  private static Delete delete;\n+  private static KeyspaceMetadata keyspaceMetadata;\n+\n+  private static CassandraConnectionManagerImpl connectionManager =\n+      (CassandraConnectionManagerImpl)\n+          CassandraConnectionMngrFactory.getObject(\n+              cach.getProperty(JsonKey.SUNBIRD_CASSANDRA_MODE));\n+\n+  @BeforeClass\n+  public static void init() {\n+\n+    PowerMockito.mockStatic(Cluster.class);\n+    cluster = PowerMockito.mock(Cluster.class);\n+    when(cluster.connect(Mockito.anyString())).thenReturn(session);\n+    metadata = PowerMockito.mock(Metadata.class);\n+    when(cluster.getMetadata()).thenReturn(metadata);\n+\n+    when(Cluster.builder()).thenReturn(builder);\n+    when(builder.addContactPoint(Mockito.anyString())).thenReturn(builder);\n+    when(builder.withPort(Mockito.anyInt())).thenReturn(builder);\n+    when(builder.withProtocolVersion(Mockito.any())).thenReturn(builder);\n+    when(builder.withRetryPolicy(Mockito.any())).thenReturn(builder);\n+    when(builder.withTimestampGenerator(Mockito.any())).thenReturn(builder);\n+    when(builder.withPoolingOptions(Mockito.any())).thenReturn(builder);\n+    when(builder.build()).thenReturn(cluster);\n+    connectionManager.createConnection(host, port, \"cassandra\", \"password\", cassandraKeySpace);\n+  }\n+\n+  @Before\n+  public void setUp() throws Exception {\n+\n+    reset(session);\n+    address = new HashMap<>();\n+    address.put(JsonKey.ID, \"123\");\n+    address.put(JsonKey.ADDRESS_LINE1, \"Line 1\");\n+    address.put(JsonKey.USER_ID, \"USR1\");\n+\n+    dummyAddress = new HashMap<>();\n+    dummyAddress.put(JsonKey.ID, \"12345\");\n+    dummyAddress.put(JsonKey.ADDRESS_LINE1, \"Line 111\");\n+    dummyAddress.put(JsonKey.USER_ID, \"USR111\");\n+    dummyAddress.put(\"DummyColumn\", \"USR111\");\n+\n+    statement = PowerMockito.mock(PreparedStatement.class);\n+    selectQuery = PowerMockito.mock(Select.class);\n+    where = PowerMockito.mock(Select.Where.class);\n+    selectBuilder = PowerMockito.mock(Select.Builder.class);\n+    PowerMockito.mockStatic(QueryBuilder.class);\n+    selectSelection = PowerMockito.mock(Select.Selection.class);\n+    deleteSelection = PowerMockito.mock(Delete.Selection.class);\n+    deleteWhere = PowerMockito.mock(Delete.Where.class);\n+    delete = PowerMockito.mock(Delete.class);\n+    operation = ServiceFactory.getInstance();\n+    resultSet = PowerMockito.mock(ResultSet.class);\n+    keyspaceMetadata = PowerMockito.mock(KeyspaceMetadata.class);\n+\n+    when(QueryBuilder.select()).thenReturn(selectSelection);\n+    when(QueryBuilder.delete()).thenReturn(deleteSelection);\n+    when(deleteSelection.from(Mockito.anyString(), Mockito.anyString())).thenReturn(delete);\n+    when(delete.where(QueryBuilder.eq(Constants.IDENTIFIER, \"123\"))).thenReturn(deleteWhere);\n+    when(selectQuery.where()).thenReturn(where);\n+    when(metadata.getKeyspace(\"sunbird\")).thenReturn(keyspaceMetadata);\n+\n+    when(cluster.connect(Mockito.anyString())).thenReturn(session);\n+\n+    boundStatement = PowerMockito.mock(BoundStatement.class);\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenReturn(boundStatement);\n+    when(session.execute(boundStatement)).thenReturn(resultSet);\n+    when(session.prepare(Mockito.anyString())).thenReturn(statement);\n+\n+    when(selectSelection.all()).thenReturn(selectBuilder);\n+    when(selectBuilder.from(Mockito.anyString(), Mockito.anyString())).thenReturn(selectQuery);\n+    when(session.execute(selectQuery)).thenReturn(resultSet);\n+    when(session.execute(boundStatement.bind(\"123\"))).thenReturn(resultSet);\n+\n+    ColumnDefinitions cd = PowerMockito.mock(ColumnDefinitions.class);\n+    String str = \"qwertypower(king\";\n+    when(resultSet.getColumnDefinitions()).thenReturn(cd);\n+    when(cd.toString()).thenReturn(str);\n+    when(str.substring(8, resultSet.getColumnDefinitions().toString().length() - 1))\n+        .thenReturn(str);\n+  }\n+\n+  @Test\n+  public void testCassandraConnectionWithoutUserNameAndPassword() throws Exception {\n+\n+    boolean bool = connectionManager.createConnection(host, port, null, null, cassandraKeySpace);\n+    assertEquals(true, bool);\n+  }\n+\n+  @Test\n+  public void testCassandraConnectionWithUserNameAndPassword() throws Exception {\n+\n+    Boolean bool =\n+        connectionManager.createConnection(host, port, \"cassandra\", \"password\", cassandraKeySpace);\n+    assertEquals(true, bool);\n+  }\n+\n+  @Test\n+  public void testFailedCassandraConnection() {\n+\n+    try {\n+      connectionManager.createConnection(\"127.0.0.1\", \"9042\", \"cassandra\", \"pass\", \"eySpace\");\n+    } catch (Exception ex) {\n+    }\n+    assertTrue(500 == ResponseCode.SERVER_ERROR.getResponseCode());\n+  }\n+\n+  @Test\n+  public void testCassandraInsertOperation() throws Exception {\n+\n+    Response response = operation.insertRecord(cassandraKeySpace, \"address1\", address);\n+    assertEquals(\"SUCCESS\", response.get(\"response\"));\n+  }\n+\n+  @Test\n+  public void testCassandraInsertOperationFailed() throws Exception {\n+\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.dbInsertionError.getErrorCode(),\n+                ResponseCode.dbInsertionError.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.insertRecord(cassandraKeySpace, \"address1\", address);\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue(\"DB insert operation failed.\".equals(exception.getMessage()));\n+  }\n+\n+  @Test\n+  public void testCassandraInsertFailedOperationWithInvalidProperty() throws Exception {\n+\n+    Throwable exception = null;\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.invalidPropertyError.getErrorCode(),\n+                JsonKey.UNKNOWN_IDENTIFIER,\n+                ResponseCode.CLIENT_ERROR.getResponseCode()));\n+\n+    try {\n+      operation.insertRecord(cassandraKeySpace, \"address1\", address);\n+    } catch (Exception exp) {\n+      exception = exp;\n+    }\n+    assertTrue(\"invalid property .\".equals(exception.getMessage()));\n+  }\n+\n+  @Test\n+  public void testCassandraUpdateOperation() throws Exception {\n+\n+    address.put(JsonKey.CITY, \"city\");\n+    address.put(JsonKey.ADD_TYPE, \"addrType\");\n+\n+    Response response = operation.updateRecord(cassandraKeySpace, \"address\", address);\n+    assertEquals(\"SUCCESS\", response.get(\"response\"));\n+  }\n+\n+  @Test\n+  public void testCassandraUpdateFailedOperation() throws Exception {\n+\n+    dummyAddress.put(JsonKey.CITY, \"city\");\n+    dummyAddress.put(JsonKey.ADD_TYPE, \"addrType\");\n+\n+    when(session.prepare(Mockito.anyString()))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.dbUpdateError.getErrorCode(),\n+                ResponseCode.dbUpdateError.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.updateRecord(cassandraKeySpace, \"address1\", address);\n+\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue(\"Db update operation failed.\".equals(exception.getMessage()));\n+  }\n+\n+  @Test\n+  public void testCassandraUpdateFailedOperationWithInvalidProperty() throws Exception {\n+\n+    when(session.prepare(Mockito.anyString()))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.invalidPropertyError.getErrorCode(),\n+                JsonKey.UNKNOWN_IDENTIFIER,\n+                ResponseCode.CLIENT_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.updateRecord(cassandraKeySpace, \"address\", address);\n+    } catch (Exception exp) {\n+      exception = exp;\n+    }\n+    assertTrue(\"invalid property .\".equals(exception.getMessage()));\n+  }\n+\n+  @Test\n+  public void testCassandraGetAllRecordsOperation() throws Exception {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenReturn(boundStatement);\n+\n+    Response response = operation.getAllRecords(cassandraKeySpace, \"address\");\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetAllRecordsFailedOperation() throws Exception {\n+\n+    when(session.execute(selectQuery))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenReturn(boundStatement);\n+\n+    Throwable exception = null;\n+    try {\n+      operation.getAllRecords(cassandraKeySpace, \"address\");\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraGetPropertiesValueByIdOperation() throws Exception {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenReturn(boundStatement);\n+    Response response =\n+        operation.getPropertiesValueById(\n+            cassandraKeySpace, \"address\", \"123\", JsonKey.ID, JsonKey.CITY, JsonKey.ADD_TYPE);\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetPropertiesValueByIdFailedOperation() throws Exception {\n+\n+    Throwable exception = null;\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    try {\n+      operation.getPropertiesValueById(\n+          cassandraKeySpace, \"address\", \"123\", JsonKey.ID, JsonKey.CITY, JsonKey.ADD_TYPE);\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordByIdOperation() {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    when(session.execute(boundStatement.bind(\"123\"))).thenReturn(resultSet);\n+    when(session.execute(where)).thenReturn(resultSet);\n+    when(selectBuilder.from(Mockito.anyString(), Mockito.anyString())).thenReturn(selectQuery);\n+    when(selectSelection.all()).thenReturn(selectBuilder);\n+\n+    Response response = operation.getRecordById(cassandraKeySpace, \"address\", \"123\");\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordByIdFailedOperation() throws Exception {\n+\n+    Throwable exception = null;\n+    PowerMockito.whenNew(BoundStatement.class)\n+        .withArguments(Mockito.any(PreparedStatement.class))\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    try {\n+      operation.getRecordById(cassandraKeySpace, \"address\", \"123\");\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordByPropertiesOperation() throws Exception {\n+\n+    Map<String, Object> map = new HashMap<>();\n+    map.put(JsonKey.USER_ID, \"USR1\");\n+    map.put(JsonKey.ADD_TYPE, \"addrType\");\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    Response response = operation.getRecordsByProperties(cassandraKeySpace, \"address\", map);\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordByPropertiesFailedOperation() throws Exception {\n+\n+    Map<String, Object> map = new HashMap<>();\n+    map.put(JsonKey.USER_ID, \"USR1\");\n+    map.put(JsonKey.ADD_TYPE, \"addrType\");\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    when(selectSelection.all())\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.getRecordsByProperties(cassandraKeySpace, \"address\", map);\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordByPropertiesForListOperation() throws Exception {\n+\n+    List<Object> list = new ArrayList<>();\n+    list.add(\"123\");\n+    list.add(\"321\");\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    Response response =\n+        operation.getRecordsByProperty(cassandraKeySpace, \"address\", JsonKey.ID, list);\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordByPropertiesForListFailedOperation() throws Exception {\n+\n+    List<Object> list = new ArrayList<>();\n+    list.add(\"123\");\n+    list.add(\"321\");\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    when(selectSelection.all())\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.getRecordsByProperty(cassandraKeySpace, \"address\", JsonKey.ID, list);\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordsByPropertyOperation() throws Exception {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    Response response =\n+        operation.getRecordsByProperty(cassandraKeySpace, \"address\", JsonKey.ADD_TYPE, \"addrType\");\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordsByPropertyFailedOperation() throws Exception {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    when(selectSelection.all())\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.getRecordsByProperty(cassandraKeySpace, \"address\", JsonKey.ADD_TYPE, \"addrType\");\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordsByIdOperation() {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+    when(session.execute(where)).thenReturn(resultSet);\n+    when(selectSelection.all()).thenReturn(selectBuilder);\n+\n+    Response response = operation.getRecordById(cassandraKeySpace, \"address\", \"123\");\n+    assertTrue(response.getResult().size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetRecordsByIdFailedOperation() throws Exception {\n+\n+    List<Row> rows = new ArrayList<>();\n+    Row row = Mockito.mock(Row.class);\n+    rows.add(row);\n+    when(resultSet.all()).thenReturn(rows);\n+\n+    when(selectSelection.all())\n+        .thenThrow(\n+            new ProjectCommonException(\n+                ResponseCode.SERVER_ERROR.getErrorCode(),\n+                ResponseCode.SERVER_ERROR.getErrorMessage(),\n+                ResponseCode.SERVER_ERROR.getResponseCode()));\n+\n+    Throwable exception = null;\n+    try {\n+      operation.getRecordById(cassandraKeySpace, \"address1\", \"123\");\n+\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((((ProjectCommonException) exception).getResponseCode()) == 500);\n+  }\n+\n+  @Test\n+  public void testCassandraDeleteOperation() throws Exception {\n+\n+    Response response = getCassandraResponse();\n+    operation.deleteRecord(cassandraKeySpace, \"address\", \"123\");\n+    assertEquals(\"SUCCESS\", response.get(\"response\"));\n+  }\n+\n+  @Test\n+  public void testCassandraDeleteFailedOperation() {\n+\n+    Throwable exception = null;\n+    try {\n+      operation.deleteRecord(cassandraKeySpace, \"address\", \"123\");\n+\n+      throw new ProjectCommonException(\n+          ResponseCode.internalError.getErrorCode(),\n+          Constants.SESSION_IS_NULL + \"sunbird\",\n+          ResponseCode.SERVER_ERROR.getResponseCode());\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue((Constants.SESSION_IS_NULL + \"sunbird\").equals(exception.getMessage()));\n+  }\n+\n+  @Test\n+  public void testCassandraGetTableList() throws Exception {\n+\n+    Collection<TableMetadata> tables = new ArrayList<>();\n+    TableMetadata table = Mockito.mock(TableMetadata.class);\n+    tables.add(table);\n+    when(keyspaceMetadata.getTables()).thenReturn(tables);\n+\n+    List<String> tableList = connectionManager.getTableList(cassandraKeySpace);\n+    assertTrue(tableList.size() > 0);\n+  }\n+\n+  @Test\n+  public void testCassandraGetCluster() throws Exception {\n+\n+    Cluster cluster = connectionManager.getCluster(\"sunbird\");\n+    assertTrue(cluster != null);\n+  }\n+\n+  @Test\n+  public void testCassandraGetClusterFailedWithInvalidKeySpace() {\n+\n+    Throwable exception = null;\n+    try {\n+      connectionManager.getCluster(\"sun\");\n+    } catch (Exception ex) {\n+      exception = ex;\n+    }\n+    assertTrue(\"cassandra cluster value is null for this sun\".equals(exception.getMessage()));\n+  }\n+\n+  private Response getCassandraResponse() {","path":"cassandra-dac/src/test/java/org/sunbird/cassandra/CassandraMockTest.java","position":637,"original_position":637,"commit_id":"76ce5ea69c59fa2ce0573bd19ead44afd5c3f7e0","original_commit_id":"76ce5ea69c59fa2ce0573bd19ead44afd5c3f7e0","user":{"login":"amolnin","id":42316446,"node_id":"MDQ6VXNlcjQyMzE2NDQ2","avatar_url":"https://avatars0.githubusercontent.com/u/42316446?v=4","gravatar_id":"","url":"https://api.github.com/users/amolnin","html_url":"https://github.com/amolnin","followers_url":"https://api.github.com/users/amolnin/followers","following_url":"https://api.github.com/users/amolnin/following{/other_user}","gists_url":"https://api.github.com/users/amolnin/gists{/gist_id}","starred_url":"https://api.github.com/users/amolnin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amolnin/subscriptions","organizations_url":"https://api.github.com/users/amolnin/orgs","repos_url":"https://api.github.com/users/amolnin/repos","events_url":"https://api.github.com/users/amolnin/events{/privacy}","received_events_url":"https://api.github.com/users/amolnin/received_events","type":"User","site_admin":false},"body":"remove this function, once it be unused","created_at":"2018-10-11T13:17:52Z","updated_at":"2018-10-11T13:17:53Z","html_url":"https://github.com/project-sunbird/sunbird-utils/pull/165#discussion_r224443589","pull_request_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/comments/224443589"},"html":{"href":"https://github.com/project-sunbird/sunbird-utils/pull/165#discussion_r224443589"},"pull_request":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165"}}},"pull_request":{"url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165","id":221072162,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxMDcyMTYy","html_url":"https://github.com/project-sunbird/sunbird-utils/pull/165","diff_url":"https://github.com/project-sunbird/sunbird-utils/pull/165.diff","patch_url":"https://github.com/project-sunbird/sunbird-utils/pull/165.patch","issue_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/165","number":165,"state":"open","locked":false,"title":"Cassandra unit test","user":{"login":"kirtisagarksj","id":42571566,"node_id":"MDQ6VXNlcjQyNTcxNTY2","avatar_url":"https://avatars3.githubusercontent.com/u/42571566?v=4","gravatar_id":"","url":"https://api.github.com/users/kirtisagarksj","html_url":"https://github.com/kirtisagarksj","followers_url":"https://api.github.com/users/kirtisagarksj/followers","following_url":"https://api.github.com/users/kirtisagarksj/following{/other_user}","gists_url":"https://api.github.com/users/kirtisagarksj/gists{/gist_id}","starred_url":"https://api.github.com/users/kirtisagarksj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirtisagarksj/subscriptions","organizations_url":"https://api.github.com/users/kirtisagarksj/orgs","repos_url":"https://api.github.com/users/kirtisagarksj/repos","events_url":"https://api.github.com/users/kirtisagarksj/events{/privacy}","received_events_url":"https://api.github.com/users/kirtisagarksj/received_events","type":"User","site_admin":false},"body":"cassandra unit test new","created_at":"2018-10-08T10:44:17Z","updated_at":"2018-10-11T13:17:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"415f216b1dcdfb5e325819eaf569f97cd0b74181","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165/commits","review_comments_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165/comments","review_comment_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/165/comments","statuses_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/statuses/76ce5ea69c59fa2ce0573bd19ead44afd5c3f7e0","head":{"label":"project-sunbird:cassandra_unit_test","ref":"cassandra_unit_test","sha":"76ce5ea69c59fa2ce0573bd19ead44afd5c3f7e0","user":{"login":"project-sunbird","id":26705730,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NzA1NzMw","avatar_url":"https://avatars1.githubusercontent.com/u/26705730?v=4","gravatar_id":"","url":"https://api.github.com/users/project-sunbird","html_url":"https://github.com/project-sunbird","followers_url":"https://api.github.com/users/project-sunbird/followers","following_url":"https://api.github.com/users/project-sunbird/following{/other_user}","gists_url":"https://api.github.com/users/project-sunbird/gists{/gist_id}","starred_url":"https://api.github.com/users/project-sunbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-sunbird/subscriptions","organizations_url":"https://api.github.com/users/project-sunbird/orgs","repos_url":"https://api.github.com/users/project-sunbird/repos","events_url":"https://api.github.com/users/project-sunbird/events{/privacy}","received_events_url":"https://api.github.com/users/project-sunbird/received_events","type":"Organization","site_admin":false},"repo":{"id":96123627,"node_id":"MDEwOlJlcG9zaXRvcnk5NjEyMzYyNw==","name":"sunbird-utils","full_name":"project-sunbird/sunbird-utils","private":false,"owner":{"login":"project-sunbird","id":26705730,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NzA1NzMw","avatar_url":"https://avatars1.githubusercontent.com/u/26705730?v=4","gravatar_id":"","url":"https://api.github.com/users/project-sunbird","html_url":"https://github.com/project-sunbird","followers_url":"https://api.github.com/users/project-sunbird/followers","following_url":"https://api.github.com/users/project-sunbird/following{/other_user}","gists_url":"https://api.github.com/users/project-sunbird/gists{/gist_id}","starred_url":"https://api.github.com/users/project-sunbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-sunbird/subscriptions","organizations_url":"https://api.github.com/users/project-sunbird/orgs","repos_url":"https://api.github.com/users/project-sunbird/repos","events_url":"https://api.github.com/users/project-sunbird/events{/privacy}","received_events_url":"https://api.github.com/users/project-sunbird/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/project-sunbird/sunbird-utils","description":"Common java utilities used by other Sunbird components","fork":false,"url":"https://api.github.com/repos/project-sunbird/sunbird-utils","forks_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/forks","keys_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/teams","hooks_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/hooks","issue_events_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/events{/number}","events_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/events","assignees_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/assignees{/user}","branches_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/branches{/branch}","tags_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/tags","blobs_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/languages","stargazers_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/stargazers","contributors_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/contributors","subscribers_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/subscribers","subscription_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/subscription","commits_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/contents/{+path}","compare_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/merges","archive_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/downloads","issues_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues{/number}","pulls_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/labels{/name}","releases_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/releases{/id}","deployments_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/deployments","created_at":"2017-07-03T15:10:45Z","updated_at":"2018-09-10T03:43:08Z","pushed_at":"2018-10-11T12:04:30Z","git_url":"git://github.com/project-sunbird/sunbird-utils.git","ssh_url":"git@github.com:project-sunbird/sunbird-utils.git","clone_url":"https://github.com/project-sunbird/sunbird-utils.git","svn_url":"https://github.com/project-sunbird/sunbird-utils","homepage":null,"size":21851,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":8,"open_issues":6,"watchers":3,"default_branch":"master"}},"base":{"label":"project-sunbird:release-1.11","ref":"release-1.11","sha":"f342b654c539b6f8628ac5eded9b8379d2159d63","user":{"login":"project-sunbird","id":26705730,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NzA1NzMw","avatar_url":"https://avatars1.githubusercontent.com/u/26705730?v=4","gravatar_id":"","url":"https://api.github.com/users/project-sunbird","html_url":"https://github.com/project-sunbird","followers_url":"https://api.github.com/users/project-sunbird/followers","following_url":"https://api.github.com/users/project-sunbird/following{/other_user}","gists_url":"https://api.github.com/users/project-sunbird/gists{/gist_id}","starred_url":"https://api.github.com/users/project-sunbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-sunbird/subscriptions","organizations_url":"https://api.github.com/users/project-sunbird/orgs","repos_url":"https://api.github.com/users/project-sunbird/repos","events_url":"https://api.github.com/users/project-sunbird/events{/privacy}","received_events_url":"https://api.github.com/users/project-sunbird/received_events","type":"Organization","site_admin":false},"repo":{"id":96123627,"node_id":"MDEwOlJlcG9zaXRvcnk5NjEyMzYyNw==","name":"sunbird-utils","full_name":"project-sunbird/sunbird-utils","private":false,"owner":{"login":"project-sunbird","id":26705730,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2NzA1NzMw","avatar_url":"https://avatars1.githubusercontent.com/u/26705730?v=4","gravatar_id":"","url":"https://api.github.com/users/project-sunbird","html_url":"https://github.com/project-sunbird","followers_url":"https://api.github.com/users/project-sunbird/followers","following_url":"https://api.github.com/users/project-sunbird/following{/other_user}","gists_url":"https://api.github.com/users/project-sunbird/gists{/gist_id}","starred_url":"https://api.github.com/users/project-sunbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-sunbird/subscriptions","organizations_url":"https://api.github.com/users/project-sunbird/orgs","repos_url":"https://api.github.com/users/project-sunbird/repos","events_url":"https://api.github.com/users/project-sunbird/events{/privacy}","received_events_url":"https://api.github.com/users/project-sunbird/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/project-sunbird/sunbird-utils","description":"Common java utilities used by other Sunbird components","fork":false,"url":"https://api.github.com/repos/project-sunbird/sunbird-utils","forks_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/forks","keys_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/teams","hooks_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/hooks","issue_events_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/events{/number}","events_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/events","assignees_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/assignees{/user}","branches_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/branches{/branch}","tags_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/tags","blobs_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/languages","stargazers_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/stargazers","contributors_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/contributors","subscribers_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/subscribers","subscription_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/subscription","commits_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/contents/{+path}","compare_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/merges","archive_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/downloads","issues_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues{/number}","pulls_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/labels{/name}","releases_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/releases{/id}","deployments_url":"https://api.github.com/repos/project-sunbird/sunbird-utils/deployments","created_at":"2017-07-03T15:10:45Z","updated_at":"2018-09-10T03:43:08Z","pushed_at":"2018-10-11T12:04:30Z","git_url":"git://github.com/project-sunbird/sunbird-utils.git","ssh_url":"git@github.com:project-sunbird/sunbird-utils.git","clone_url":"https://github.com/project-sunbird/sunbird-utils.git","svn_url":"https://github.com/project-sunbird/sunbird-utils","homepage":null,"size":21851,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":8,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165"},"html":{"href":"https://github.com/project-sunbird/sunbird-utils/pull/165"},"issue":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/165"},"comments":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/issues/165/comments"},"review_comments":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165/comments"},"review_comment":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/pulls/165/commits"},"statuses":{"href":"https://api.github.com/repos/project-sunbird/sunbird-utils/statuses/76ce5ea69c59fa2ce0573bd19ead44afd5c3f7e0"}},"author_association":"NONE"}}
{"actor":{"display_login":"amolnin"}}