@DataProvider public List<Record> getQuerySchemas() throws Exception { Map<String, String> querySchemaMap = doUserQuerySchemas(); List<Record> querySchemas = new ArrayList<Record>(); querySchemas.add(new Record()); for (Map.Entry<String, String> entry : querySchemaMap.entrySet()) { Record record = new Record(); record.put("name", entry.getKey()); record.put("criteria", entry.getValue()); querySchemas.add(record); } return querySchemas; }
@DataResolver public void saveQuerySchemas(List<Record> querySchemas) { Map<String, String> querySchemaMap = doUserQuerySchemas(); for (Record querySchema : EntityUtils.getIterable(querySchemas, FilterType.DELETED, Record.class)) { querySchemaMap.remove(querySchema.getString("name")); } for (Record querySchema : EntityUtils.getIterable(querySchemas, FilterType.MODIFIED, Record.class)) { querySchemaMap.put(querySchema.getString("name"), querySchema.getString("criteria")); } for (Record querySchema : EntityUtils.getIterable(querySchemas, FilterType.NEW, Record.class)) { querySchemaMap.put(querySchema.getString("name"), querySchema.getString("criteria")); } }