@Test public void testMergeWithOverlap() { DependencyGraph graph = DependencyGraphFactory.createGraph(); GraphReaderWriter.merge(graph, "src/test/resources/graphs/testGraph1.json"); assertThat(graph.getAllNodes()).hasSize(5); assertThat(graph.getNode("v1").getProperty("list-key-1")).isEqualTo(Lists.newArrayList("a", "b", "c")); assertThat(graph.getNode("v1").getProperty("KEY")).isEqualTo(5); DependencyGraph graph3 = DependencyGraphFactory.createGraph(); GraphReaderWriter.merge(graph3, "src/test/resources/graphs/testGraph3.json"); assertThat(graph3.getAllNodes()).hasSize(2); assertThat(graph3.getNode("v1")).isNotNull(); assertThat(graph3.getNode("v1").getProperty("list-key-1")).isEqualTo(Lists.newArrayList("c", "d")); assertThat(graph3.getNode("v6")).isNotNull(); assertThat(graph3.getNode("v1").getProperty("KEY")).isEqualTo(6); GraphReaderWriter.merge(graph, "src/test/resources/graphs/testGraph3.json"); assertThat(graph.getAllNodes()).hasSize(6); assertThat(graph.getNode("v1").getProperty("list-key-1")).isEqualTo(Lists.newArrayList("a", "b", "c", "d")); assertThat(graph.getNode("v1").getProperty("KEY")).isEqualTo(Lists.newArrayList(5, 6)); }
public static DependencyGraph merge(DependencyGraph targetGraph, String filename) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); IOGraph ioGraph; try { ioGraph = mapper.readValue(new File(filename), IOGraph.class); } catch (IOException e) { throw new IllegalStateException("Error reading from file: " + FileNameUtil.getCanonicalPath(filename), e); } return IO_GRAPH_MAPPER.mergeDependencyGraph(targetGraph, ioGraph); }
GraphReaderWriter { public static DependencyGraph merge(DependencyGraph targetGraph, String filename) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); IOGraph ioGraph; try { ioGraph = mapper.readValue(new File(filename), IOGraph.class); } catch (IOException e) { throw new IllegalStateException("Error reading from file: " + FileNameUtil.getCanonicalPath(filename), e); } return IO_GRAPH_MAPPER.mergeDependencyGraph(targetGraph, ioGraph); } }
GraphReaderWriter { public static DependencyGraph merge(DependencyGraph targetGraph, String filename) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); IOGraph ioGraph; try { ioGraph = mapper.readValue(new File(filename), IOGraph.class); } catch (IOException e) { throw new IllegalStateException("Error reading from file: " + FileNameUtil.getCanonicalPath(filename), e); } return IO_GRAPH_MAPPER.mergeDependencyGraph(targetGraph, ioGraph); } private  GraphReaderWriter(); }
GraphReaderWriter { public static DependencyGraph merge(DependencyGraph targetGraph, String filename) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); IOGraph ioGraph; try { ioGraph = mapper.readValue(new File(filename), IOGraph.class); } catch (IOException e) { throw new IllegalStateException("Error reading from file: " + FileNameUtil.getCanonicalPath(filename), e); } return IO_GRAPH_MAPPER.mergeDependencyGraph(targetGraph, ioGraph); } private  GraphReaderWriter(); static void write(DependencyGraph dependencyGraph, String filename); static DependencyGraph read(String filename); static DependencyGraph merge(DependencyGraph targetGraph, String filename); }
GraphReaderWriter { public static DependencyGraph merge(DependencyGraph targetGraph, String filename) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); IOGraph ioGraph; try { ioGraph = mapper.readValue(new File(filename), IOGraph.class); } catch (IOException e) { throw new IllegalStateException("Error reading from file: " + FileNameUtil.getCanonicalPath(filename), e); } return IO_GRAPH_MAPPER.mergeDependencyGraph(targetGraph, ioGraph); } private  GraphReaderWriter(); static void write(DependencyGraph dependencyGraph, String filename); static DependencyGraph read(String filename); static DependencyGraph merge(DependencyGraph targetGraph, String filename);  }