SystemSettingDaoImpl implements SystemSettingDao { public List<SystemSetting> readAll() { Response response = cassandraOperation.getAllRecords(KEYSPACE_NAME, TABLE_NAME); List<Map<String, Object>> list = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE); List<SystemSetting> systemSettings = new ArrayList<>(); list.forEach( map -> { SystemSetting systemSetting = mapper.convertValue(map, SystemSetting.class); systemSettings.add(systemSetting); }); return systemSettings; } SystemSettingDaoImpl(CassandraOperation cassandraOperation); @Override Response write(SystemSetting systemSetting); @Override SystemSetting readById(String id); @Override SystemSetting readByField(String field); List<SystemSetting> readAll();  }
@Test public void testReadAllSystemSettingsSuccess() { PowerMockito.when(cassandraOperation.getAllRecords(Mockito.anyString(), Mockito.anyString())) .thenReturn(getSystemSettingSuccessResponse(false)); List<SystemSetting> result = systemSettingDaoImpl.readAll(); Assert.assertTrue(null != result); }
@Test public void testReadAllSystemSettingsEmpty() { PowerMockito.when(cassandraOperation.getAllRecords(Mockito.anyString(), Mockito.anyString())) .thenReturn(getSystemSettingSuccessResponse(true)); List<SystemSetting> result = systemSettingDaoImpl.readAll(); Assert.assertTrue(null != result); }