@Test public void testMerge() throws Exception { Query q1 = Query.builder() .setObj("obj:key=val") .addAttr("foo") .addAttr("bar") .addKey("key1") .addKey("key2") .setResultAlias("alias") .build(); Query q2 = Query.builder() .setObj("obj:key=val") .addAttr("foo") .addAttr("bar") .addKey("key1") .addKey("key2") .setResultAlias("alias") .build(); Query q3 = Query.builder() .setObj("obj3:key=val") .addAttr("foo") .addAttr("bar") .addKey("key1") .addKey("key2") .setResultAlias("alias") .build(); Server s1 = Server.builder() .setAlias("alias") .setHost("host") .setPort("8004") .setPool(createPool()) .setCronExpression("cron") .setNumQueryThreads(123) .setPassword("pass") .setUsername("user") .addQuery(q1) .addQuery(q2) .build(); Server s2 = Server.builder() .setAlias("alias") .setHost("host") .setPort("8004") .setPool(createPool()) .setCronExpression("cron") .setNumQueryThreads(123) .setPassword("pass") .setUsername("user") .addQuery(q1) .addQuery(q2) .build(); Server s3 = Server.builder() .setAlias("alias") .setHost("host3") .setPort("8004") .setPool(createPool()) .setCronExpression("cron") .setNumQueryThreads(123) .setPassword("pass") .setUsername("user") .addQuery(q1) .addQuery(q2) .addQuery(q3) .build(); List<Server> existing = new ArrayList<Server>(); existing.add(s1); List<Server> adding = new ArrayList<Server>(); adding.add(s2); existing = configurationParser.mergeServerLists(existing, adding); assertThat(existing).hasSize(1); assertThat(existing.get(0).getQueries()).hasSize(1); adding.add(s3); existing = configurationParser.mergeServerLists(existing, adding); assertThat(existing).hasSize(2); assertThat(existing.get(0).getQueries()).hasSize(1); assertThat(existing.get(1).getQueries()).hasSize(2); }
private Server merge(Server firstServer, Server secondServer) { return Server.builder(firstServer) .addQueries(secondServer.getQueries()) .build(); }
ConfigurationParser { private Server merge(Server firstServer, Server secondServer) { return Server.builder(firstServer) .addQueries(secondServer.getQueries()) .build(); } }
ConfigurationParser { private Server merge(Server firstServer, Server secondServer) { return Server.builder(firstServer) .addQueries(secondServer.getQueries()) .build(); } @Inject  ConfigurationParser(ProcessConfigUtils processConfigUtils); }
ConfigurationParser { private Server merge(Server firstServer, Server secondServer) { return Server.builder(firstServer) .addQueries(secondServer.getQueries()) .build(); } @Inject  ConfigurationParser(ProcessConfigUtils processConfigUtils); ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError); }
ConfigurationParser { private Server merge(Server firstServer, Server secondServer) { return Server.builder(firstServer) .addQueries(secondServer.getQueries()) .build(); } @Inject  ConfigurationParser(ProcessConfigUtils processConfigUtils); ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError);  }