SystemSettingDaoImpl implements SystemSettingDao { @Override public SystemSetting readByField(String field) { Response response = cassandraOperation.getRecordsByIndexedProperty( KEYSPACE_NAME, TABLE_NAME, JsonKey.FIELD, field); List<Map<String, Object>> list = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE); if (CollectionUtils.isEmpty(list)) { return null; } return getSystemSetting(list); } SystemSettingDaoImpl(CassandraOperation cassandraOperation); @Override Response write(SystemSetting systemSetting); @Override SystemSetting readById(String id); @Override SystemSetting readByField(String field); List<SystemSetting> readAll();  }
@Test public void testReadSystemSettingSuccess() { PowerMockito.when( cassandraOperation.getRecordsByIndexedProperty( Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())) .thenReturn(getSystemSettingSuccessResponse(false)); SystemSetting systemSetting = systemSettingDaoImpl.readByField(ROOT_ORG_ID); Assert.assertTrue(null != systemSetting); }
@Test public void testReadSystemSettingEmpty() { PowerMockito.when( cassandraOperation.getRecordsByIndexedProperty( Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())) .thenReturn(getSystemSettingSuccessResponse(true)); SystemSetting systemSetting = systemSettingDaoImpl.readByField(FIELD); Assert.assertTrue(null == systemSetting); }