BadgeClassExtensionServiceImpl implements BadgeClassExtensionService { @Override public List<BadgeClassExtension> search( List<String> issuerList, List<String> badgeList, String rootOrgId, String type, String subtype, List<String> roles) { Map<String, Object> propertyMap = new HashMap<>(); if (rootOrgId != null) { propertyMap.put(JsonKey.ROOT_ORG_ID, rootOrgId); } if (type != null) { propertyMap.put(JsonKey.TYPE, type); } if (subtype != null) { propertyMap.put(JsonKey.SUBTYPE, subtype); } Response response = cassandraOperation.getRecordsByProperties( Util.KEY_SPACE_NAME, BADGE_CLASS_EXT_TABLE_NAME, propertyMap); List<Map<String, Object>> badgeClassExtList = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE); return badgeClassExtList .stream() .map(badgeClassExtMap -> new BadgeClassExtension(badgeClassExtMap)) .filter( badgeClassExt -> roles == null || CollectionUtils.isEmpty(badgeClassExt.getRoles()) || !Collections.disjoint(roles, badgeClassExt.getRoles())) .filter( badgeClassExt -> CollectionUtils.isEmpty(issuerList) || issuerList.contains(badgeClassExt.getIssuerId())) .filter( badgeClassExt -> CollectionUtils.isEmpty(badgeList) || badgeList.contains(badgeClassExt.getBadgeId())) .collect(Collectors.toList()); } BadgeClassExtensionServiceImpl();  BadgeClassExtensionServiceImpl(CassandraOperation cassandraOperation); @Override void save(BadgeClassExtension badgeClassExtension); @Override List<BadgeClassExtension> search(
      List<String> issuerList,
      List<String> badgeList,
      String rootOrgId,
      String type,
      String subtype,
      List<String> roles); @Override BadgeClassExtension get(String badgeId); @Override void delete(String badgeId); static final String BADGE_CLASS_EXT_TABLE_NAME; }
@Test public void testSearchSuccessEmpty() { Response response = new Response(); response.put(JsonKey.RESPONSE, new ArrayList<Map<String, Object>>()); PowerMockito.when( mockDBService.getRecordsByProperties(Mockito.any(), Mockito.any(), Mockito.anyMap())) .thenReturn(response); List<BadgeClassExtension> badgeClassExtList = badgeClassExtensionServiceImpl.search( new ArrayList<>(), new ArrayList<>(), VALUE_ROOT_ORG_ID, VALUE_TYPE, VALUE_SUBTYPE, VALUE_ROLES_LIST); Assert.assertTrue(null != badgeClassExtList); Assert.assertEquals(0, badgeClassExtList.size()); }