### Question:
Util { public static boolean isValidAssetGroup(String ag) { List<Map<String, Object>> agList = assetService.getAllAssetGroups(); return agList.stream().filter(obj -> ag.equals(obj.get("name"))).count() > 0 ? true : false; }  @Autowired(required = true) void setassetService(AssetService assetService); static boolean isValidTargetType(String ag, String type); static boolean isValidAssetGroup(String ag); static int getUtilisationScore(double cpuUtilisation); static String encodeUrl(String toBeEncoded);  }### Answer:
@Test public void testisValidAssetGroup() throws Exception { List<Map<String, Object>> tTypeList = new ArrayList<>(); Map<String, Object> tTypeMap = new HashMap<>(); tTypeMap.put("name", "aws-all"); tTypeList.add(tTypeMap); when(service.getAllAssetGroups()).thenReturn(tTypeList); new Util().setassetService(service); boolean valid = Util.isValidAssetGroup("aws-all"); assertTrue(valid); }