Defaulting { static RiptideProperties withDefaults(final RiptideProperties base) { return merge(base, merge(base.getDefaults())); } private  Defaulting();   }
@Test void shouldRaiseProvidedDefaultConnectionsMaxTotalToConnectionsMaxPerRoute() { final RiptideProperties properties = new RiptideProperties(); properties.getDefaults().getConnections().setMaxPerRoute(50); properties.getDefaults().getConnections().setMaxTotal(25); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getDefaults().getConnections().getMaxTotal(), is(50)); }
@Test void shouldNotLowerProvidedDefaultConnectionMaxTotalToConnectionsMaxPerRoute() { final RiptideProperties properties = new RiptideProperties(); properties.getDefaults().getConnections().setMaxTotal(75); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getDefaults().getConnections().getMaxTotal(), is(75)); }
@Test void shouldOverrideUnprovidedDefaultThreadsMaxSizeToConnectionsMaxTotal() { final RiptideProperties properties = new RiptideProperties(); properties.getDefaults().getConnections().setMaxTotal(50); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getDefaults().getThreads().getMaxSize(), is(50)); }
@Test void shouldNotOverwriteProvidedDefaultThreadsMaxSizeWithConnectionsMaxTotal() { final RiptideProperties properties = new RiptideProperties(); final Defaults defaults = new Defaults(); defaults.setThreads(new Threads(true, null, 10, null, null)); properties.setDefaults(defaults); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getDefaults().getThreads().getMaxSize(), is(10)); }
@Test void shouldNotRaiseProvidedClientConnectionsMaxTotalToDefaultConnectionsMaxTotal() { final RiptideProperties properties = new RiptideProperties(); properties.getDefaults().getConnections().setMaxTotal(100); final Connections connections = new Connections(); connections.setMaxTotal(50); final Client client = new Client(); client.setConnections(connections); properties.getClients().put("example", client); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getClients().get("example").getConnections().getMaxTotal(), is(50)); }
@Test void shouldNotLowerProvidedClientConnectionsMaxTotalToDefaultConnectionsMaxTotal() { final RiptideProperties properties = new RiptideProperties(); properties.getDefaults().getConnections().setMaxTotal(50); final Connections connections = new Connections(); connections.setMaxTotal(100); final Client client = new Client(); client.setConnections(connections); properties.getClients().put("example", client); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getClients().get("example").getConnections().getMaxTotal(), is(100)); }
@Test void shouldOverwriteUnprovidedClientConnectionsMaxTotalToDefaultConnectionsMaxTotal() { final RiptideProperties properties = new RiptideProperties(); properties.getDefaults().getConnections().setMaxTotal(50); properties.getClients().put("example", new Client()); final RiptideProperties actual = Defaulting.withDefaults(properties); assertThat(actual.getClients().get("example").getConnections().getMaxTotal(), is(50)); }