RoleDaoImpl implements RoleDao { @SuppressWarnings("unchecked") @Override public List<Role> getRoles() { Response roleResults = getCassandraOperation().getAllRecords(Util.KEY_SPACE_NAME, TABLE_NAME); TypeReference<List<Role>> roleMapType = new TypeReference<List<Role>>() {}; List<Map<String, Object>> roleMapList = (List<Map<String, Object>>) roleResults.get(JsonKey.RESPONSE); List<Role> roleList = mapper.convertValue(roleMapList, roleMapType); return roleList; }  static RoleDao getInstance(); @SuppressWarnings("unchecked") @Override List<Role> getRoles(); CassandraOperation getCassandraOperation();  }
@Test public void testGetRoles(){ try{ cassandraOperation=PowerMockito.mock(CassandraOperation.class); PowerMockito.mockStatic(ServiceFactory.class); when(ServiceFactory.getInstance()).thenReturn(cassandraOperation); when(cassandraOperation.getAllRecords(Util.KEY_SPACE_NAME, TABLE_NAME)).thenReturn(response); List<Role>roleList=roleDao.getRoles(); Assert.assertEquals("TEACHER",roleList.get(0).getName()); }catch (Exception e){ Assert.assertTrue(false); } }