CategoryMapper { public List<Category> fromNetwork(List<CategoryResponse.Tag> tags) { List<Category> categories = new ArrayList<>(tags.size()); for (CategoryResponse.Tag tag : tags) { categories.add(new Category(tag.getId(), tag.getName(), tag.getUrl(), tag.getProducts())); } Collections.sort(categories, (first, second) -> first.getName().compareTo(second.getName())); return categories; } @Inject  CategoryMapper(); List<Category> fromNetwork(List<CategoryResponse.Tag> tags);  }
@Test public void fromNetworkFullResponseCategoryList() throws IOException { ObjectMapper mapper = new ObjectMapper(); CategoryResponse response = mapper.readValue(FileTestUtils .readTextFileFromResources("mock_categories.json", this.getClass().getClassLoader()), CategoryResponse.class); List<Category> categories = new CategoryMapper().fromNetwork(response.getTags()); assertThat(response.getTags()).hasSize(categories.size()); }