### Question:
RemoveUnusedDefinitions implements Consumer<Swagger> { @Override public void accept(Swagger swagger) { int initial = swagger.getDefinitions().size(); Pruner pruner = new Pruner(buildHierarchy(swagger)); while(pruner.hasPruneable()) { Stream<String> prune = pruner.prune(); Map<String, Model> defs = swagger.getDefinitions(); prune.forEach(type -> { log.info("Removing unused type {}", type); defs.remove(type); }); swagger.setDefinitions(defs); } int afterPruning = swagger.getDefinitions().size(); log.debug("Pruned {} of {} definitions.", initial-afterPruning, initial); }  @Override void accept(Swagger swagger);  }### Answer:
@Test public void noChange() { int initial = swagger.getDefinitions().size(); new RemoveUnusedDefinitions().accept(swagger); assertEquals(initial, swagger.getDefinitions().size()); }
@Test public void noChangeInClasses() { int initial = swagger.getDefinitions().size(); Map<String, Path> paths = swagger.getPaths(); paths.remove("/b/propE/propF"); swagger.setPaths(paths); new RemoveUnusedDefinitions().accept(swagger); assertEquals(initial, swagger.getDefinitions().size()); }
@Test public void removingC() { int initial = swagger.getDefinitions().size(); Map<String, Path> paths = swagger.getPaths().entrySet().stream() .filter(p -> !p.getKey().startsWith("/c")).collect(toMap()); swagger.setPaths(paths); new RemoveUnusedDefinitions().accept(swagger); assertEquals(initial - 2, swagger.getDefinitions().size()); }