@Test public void testAdaptation() throws Exception { ServerInfo reference = ServerInfoResolvers.fromAwsInstanceTypes().resolve("m4.4xlarge").get(); ServerInfo adapted = ServerInfoResolvers.adapt( ServerInfoResolvers.fromAwsInstanceTypes(), cpus -> cpus - 2, memoryGB -> memoryGB - 1, diskGB -> diskGB - 10 ).resolve("m4.4xlarge").get(); assertThat(adapted.getCpus()).isEqualTo(reference.getCpus() - 2); assertThat(adapted.getMemoryGB()).isEqualTo(reference.getMemoryGB() - 1); assertThat(adapted.getStorageGB()).isEqualTo(reference.getStorageGB() - 10); }
@Override public Optional<ServerInfo> resolve(String serverType) { return Optional.ofNullable(serverInfoByName.get(serverType)); }
ServerInfoResolverAdapter implements ServerInfoResolver { @Override public Optional<ServerInfo> resolve(String serverType) { return Optional.ofNullable(serverInfoByName.get(serverType)); } }
ServerInfoResolverAdapter implements ServerInfoResolver { @Override public Optional<ServerInfo> resolve(String serverType) { return Optional.ofNullable(serverInfoByName.get(serverType)); } ServerInfoResolverAdapter(ServerInfoResolver delegate, Function<ServerInfo, ServerInfo> adapter); }
ServerInfoResolverAdapter implements ServerInfoResolver { @Override public Optional<ServerInfo> resolve(String serverType) { return Optional.ofNullable(serverInfoByName.get(serverType)); } ServerInfoResolverAdapter(ServerInfoResolver delegate, Function<ServerInfo, ServerInfo> adapter); @Override Optional<ServerInfo> resolve(String serverType); @Override List<ServerInfo> resolveAll(); }
ServerInfoResolverAdapter implements ServerInfoResolver { @Override public Optional<ServerInfo> resolve(String serverType) { return Optional.ofNullable(serverInfoByName.get(serverType)); } ServerInfoResolverAdapter(ServerInfoResolver delegate, Function<ServerInfo, ServerInfo> adapter); @Override Optional<ServerInfo> resolve(String serverType); @Override List<ServerInfo> resolveAll();  }