FeedServiceImpl implements IFeedService { @Override public Response insert(Feed feed) { ProjectLogger.log("FeedServiceImpl:insert method called : ", LoggerEnum.INFO.name()); Map<String, Object> feedData = feed.getData(); Map<String, Object> dbMap = mapper.convertValue(feed, Map.class); String feedId = ProjectUtil.generateUniqueId(); dbMap.put(JsonKey.ID, feedId); dbMap.put(JsonKey.CREATED_ON, new Timestamp(Calendar.getInstance().getTimeInMillis())); try { if (MapUtils.isNotEmpty(feed.getData())) { dbMap.put(JsonKey.FEED_DATA, mapper.writeValueAsString(feed.getData())); } } catch (Exception ex) { ProjectLogger.log("FeedServiceImpl:insert Exception occurred while mapping.", ex); } Response response = saveFeed(dbMap); dbMap.put(JsonKey.FEED_DATA, feedData); dbMap.put(JsonKey.CREATED_ON, Calendar.getInstance().getTimeInMillis()); getESInstance().save(ProjectUtil.EsType.userfeed.getTypeName(), feedId, dbMap); return response; }  static CassandraOperation getCassandraInstance(); static ElasticSearchService getESInstance(); @Override Response insert(Feed feed); @Override Response update(Feed feed); @Override List<Feed> getRecordsByProperties(Map<String, Object> properties); @Override Response search(SearchDTO searchDTO); @Override void delete(String id);  }
@Test public void testInsert() { Response res = feedService.insert(getFeed(false)); Assert.assertTrue( ((String) res.getResult().get(JsonKey.RESPONSE)).equalsIgnoreCase(JsonKey.SUCCESS)); }