Defaulting { private static Defaults merge(final Defaults defaults) { final Connections connections = merge( new Connections(null, null, null, null, null, max( defaults.getConnections().getMaxTotal(), defaults.getConnections().getMaxPerRoute()), null), defaults.getConnections()); return new Defaults( defaults.getUrlResolution(), connections, merge(defaults.getThreads(), new Threads(connections.getMaxTotal())), defaults.getAuth(), defaults.getOauth(), defaults.getTransientFaultDetection(), defaults.getStackTracePreservation(), defaults.getMetrics(), defaults.getLogging(), defaults.getRetry(), defaults.getCircuitBreaker(), defaults.getBackupRequest(), defaults.getTimeouts(), defaults.getRequestCompression(), defaults.getCertificatePinning(), defaults.getCaching(), defaults.getTracing(), defaults.getChaos(), defaults.getSoap() ); } private  Defaulting();   }
@Test void shouldMergeCaching() { final Caching actual = Defaulting.merge( new Caching(false, true, null, 4096, 100, new Heuristic(Boolean.FALSE, 0.1f, null)), new Caching(true, false, Paths.get("/var/cache/http"), 8192, 1000, new Heuristic(true, 0.25f, TimeSpan.of(1, HOURS)))); assertThat(actual.getEnabled(), is(false)); assertThat(actual.getShared(), is(true)); assertThat(actual.getDirectory(), is(Paths.get("/var/cache/http"))); assertThat(actual.getMaxObjectSize(), is(4096)); assertThat(actual.getMaxCacheEntries(), is(100)); assertThat(actual.getHeuristic().getEnabled(), is(false)); assertThat(actual.getHeuristic().getCoefficient(), is(0.1f)); assertThat(actual.getHeuristic().getDefaultLifeTime(), hasToString("1 hours")); }