@Test public void migrate() throws Exception { String yaml = Resources.toString(ConfigMigrationStep005to006Test.class.getResource("migrate5to6.yaml"), Charset.defaultCharset()); Map<String, Object> map = Jackson.YAML_MAPPER.readValue(yaml, ConfigReaderWriter.MAP_TYPE_REFERENCE); Map<String, Object> migrated = testee.migrate(map); String newYaml = Jackson.YAML_MAPPER.writeValueAsString(migrated); BaseConfig baseConfig = Jackson.YAML_MAPPER.readValue(newYaml, BaseConfig.class); assertThat(baseConfig.getCategoriesConfig().getCategories().get(0).getNewznabCategories().get(0).get(0)).isEqualTo(1000); assertThat(baseConfig.getCategoriesConfig().getCategories().get(1).getNewznabCategories().get(0).get(0)).isEqualTo(3000); assertThat(baseConfig.getCategoriesConfig().getCategories().get(1).getNewznabCategories().get(1).get(0)).isEqualTo(3030); }
@Override public Map<String, Object> migrate(Map<String, Object> toMigrate) { Map<String, Object> categoriesConfig = getFromMap(toMigrate, "categoriesConfig"); List<Map<String, Object>> categories = getListFromMap(categoriesConfig, "categories"); for (Map<String, Object> category : categories) { List<Integer> existingNumbers = (List<Integer>) category.get("newznabCategories"); category.put("newznabCategories", existingNumbers.stream().map(Object::toString).collect(Collectors.toList())); } return toMigrate; }
ConfigMigrationStep005to006 implements ConfigMigrationStep { @Override public Map<String, Object> migrate(Map<String, Object> toMigrate) { Map<String, Object> categoriesConfig = getFromMap(toMigrate, "categoriesConfig"); List<Map<String, Object>> categories = getListFromMap(categoriesConfig, "categories"); for (Map<String, Object> category : categories) { List<Integer> existingNumbers = (List<Integer>) category.get("newznabCategories"); category.put("newznabCategories", existingNumbers.stream().map(Object::toString).collect(Collectors.toList())); } return toMigrate; } }
ConfigMigrationStep005to006 implements ConfigMigrationStep { @Override public Map<String, Object> migrate(Map<String, Object> toMigrate) { Map<String, Object> categoriesConfig = getFromMap(toMigrate, "categoriesConfig"); List<Map<String, Object>> categories = getListFromMap(categoriesConfig, "categories"); for (Map<String, Object> category : categories) { List<Integer> existingNumbers = (List<Integer>) category.get("newznabCategories"); category.put("newznabCategories", existingNumbers.stream().map(Object::toString).collect(Collectors.toList())); } return toMigrate; }  }
ConfigMigrationStep005to006 implements ConfigMigrationStep { @Override public Map<String, Object> migrate(Map<String, Object> toMigrate) { Map<String, Object> categoriesConfig = getFromMap(toMigrate, "categoriesConfig"); List<Map<String, Object>> categories = getListFromMap(categoriesConfig, "categories"); for (Map<String, Object> category : categories) { List<Integer> existingNumbers = (List<Integer>) category.get("newznabCategories"); category.put("newznabCategories", existingNumbers.stream().map(Object::toString).collect(Collectors.toList())); } return toMigrate; }  @Override int forVersion(); @Override Map<String, Object> migrate(Map<String, Object> toMigrate); }
ConfigMigrationStep005to006 implements ConfigMigrationStep { @Override public Map<String, Object> migrate(Map<String, Object> toMigrate) { Map<String, Object> categoriesConfig = getFromMap(toMigrate, "categoriesConfig"); List<Map<String, Object>> categories = getListFromMap(categoriesConfig, "categories"); for (Map<String, Object> category : categories) { List<Integer> existingNumbers = (List<Integer>) category.get("newznabCategories"); category.put("newznabCategories", existingNumbers.stream().map(Object::toString).collect(Collectors.toList())); } return toMigrate; }  @Override int forVersion(); @Override Map<String, Object> migrate(Map<String, Object> toMigrate);  }