@Test public void get_data_when_empty_returns_empty_collection() { assertTrue("collection should be empty", saver.getData().isEmpty()); }
List<KVCategory> getData() { final List<KVCategory> categories = new ArrayList<>(); synchronized (items) { for (Map.Entry<String, Map<String, String>> categoryEntry : items.entrySet()) { final String categoryName = categoryEntry.getKey(); final List<KVEntry> entries = new ArrayList<>(); for (Map.Entry<String, String> keyValEntry : categoryEntry.getValue().entrySet()) { final String key = keyValEntry.getKey(); final String value = keyValEntry.getValue(); entries.add(new KVEntry(key, value)); } categories.add(new KVCategory(categoryName, entries)); } } return categories; }
KVSaver extends Observable implements Saver { List<KVCategory> getData() { final List<KVCategory> categories = new ArrayList<>(); synchronized (items) { for (Map.Entry<String, Map<String, String>> categoryEntry : items.entrySet()) { final String categoryName = categoryEntry.getKey(); final List<KVEntry> entries = new ArrayList<>(); for (Map.Entry<String, String> keyValEntry : categoryEntry.getValue().entrySet()) { final String key = keyValEntry.getKey(); final String value = keyValEntry.getValue(); entries.add(new KVEntry(key, value)); } categories.add(new KVCategory(categoryName, entries)); } } return categories; } }
KVSaver extends Observable implements Saver { List<KVCategory> getData() { final List<KVCategory> categories = new ArrayList<>(); synchronized (items) { for (Map.Entry<String, Map<String, String>> categoryEntry : items.entrySet()) { final String categoryName = categoryEntry.getKey(); final List<KVEntry> entries = new ArrayList<>(); for (Map.Entry<String, String> keyValEntry : categoryEntry.getValue().entrySet()) { final String key = keyValEntry.getKey(); final String value = keyValEntry.getValue(); entries.add(new KVEntry(key, value)); } categories.add(new KVCategory(categoryName, entries)); } } return categories; }  }
KVSaver extends Observable implements Saver { List<KVCategory> getData() { final List<KVCategory> categories = new ArrayList<>(); synchronized (items) { for (Map.Entry<String, Map<String, String>> categoryEntry : items.entrySet()) { final String categoryName = categoryEntry.getKey(); final List<KVEntry> entries = new ArrayList<>(); for (Map.Entry<String, String> keyValEntry : categoryEntry.getValue().entrySet()) { final String key = keyValEntry.getKey(); final String value = keyValEntry.getValue(); entries.add(new KVEntry(key, value)); } categories.add(new KVCategory(categoryName, entries)); } } return categories; }  @Override void save(String category, String key, String value); @Override void remove(String category, String key); @Override void remove(String category); }
KVSaver extends Observable implements Saver { List<KVCategory> getData() { final List<KVCategory> categories = new ArrayList<>(); synchronized (items) { for (Map.Entry<String, Map<String, String>> categoryEntry : items.entrySet()) { final String categoryName = categoryEntry.getKey(); final List<KVEntry> entries = new ArrayList<>(); for (Map.Entry<String, String> keyValEntry : categoryEntry.getValue().entrySet()) { final String key = keyValEntry.getKey(); final String value = keyValEntry.getValue(); entries.add(new KVEntry(key, value)); } categories.add(new KVCategory(categoryName, entries)); } } return categories; }  @Override void save(String category, String key, String value); @Override void remove(String category, String key); @Override void remove(String category);  }