### Question:
ServerConfigResolver implements Resolver<Set<ServerEndpointProperties>, Set<ServerConfig>> { @Override public Set<ServerConfig> resolve(Set<ServerEndpointProperties> serverEndpointProperties) { return serverEndpointProperties .stream() .map(this::resolveServerConfig) .collect(toSet()); } ServerConfigResolver(ServerRSocketFactory serverRSocketFactory,
                              List<ServerHandlersProvider<?>> handlerProviders,
                              List<R2DataCodec> dataCodecs,
                              List<R2ServerTransport> transports,
                              List<RequestersProvider> requesterProviders); @Override Set<ServerConfig> resolve(Set<ServerEndpointProperties> serverEndpointProperties);  }### Answer:
@Test public void resolveNoAPi() { ServerEndpointProperties props = validProps(); props.setResponders(Collections.emptyList()); Set<ServerConfig> resolved = resolver.resolve(Collections.singleton(props)); assertThat(resolved) .isNotNull() .hasSize(1); ServerApiHandlersFactory handlers = resolved .iterator() .next() .handlers(); assertThat(handlers).isNotNull(); ConnectionContext ctx = new ConnectionContext( new Metadata.Builder().build()); MockRequesterFactory requesterFactory = new MockRequesterFactory(); Collection<Object> actualHandlers = handlers .apply(ctx, requesterFactory); assertThat(actualHandlers).isNotNull().hasSize(0); }
@Test(expected = IllegalArgumentException.class) public void resolveMissingTransport() { ServerEndpointProperties props = validProps(); props.setTransport("absent"); resolver.resolve(Collections.singleton(props)); }
@Test(expected = IllegalArgumentException.class) public void resolveMissingCodec() { ServerEndpointProperties props = validProps(); props.setCodecs(Collections.singletonList("absent")); resolver.resolve(Collections.singleton(props)); }
@Test public void resolveAll() { Set<ServerConfig> resolved = resolver .resolve(Collections.singleton(validProps())); assertThat(resolved) .isNotNull() .hasSize(1); ServerConfig serverConfig = resolved.iterator().next(); assertThat(serverConfig.transport()) .isNotNull() .isExactlyInstanceOf(TcpServerTransport.class); List<DataCodec> codecs = serverConfig.codecs(); assertThat(codecs) .isNotNull() .hasSize(1); assertThat(codecs.get(0)).isExactlyInstanceOf(JacksonJsonDataCodec.class); assertThat(serverConfig.rSocketFactory()).isNotNull(); ServerApiHandlersFactory handlers = serverConfig.handlers(); assertThat(handlers).isNotNull(); ConnectionContext ctx = new ConnectionContext( new Metadata.Builder().build()); MockRequesterFactory requesterFactory = new MockRequesterFactory(); Collection<Object> actualHandlers = handlers .apply(ctx, requesterFactory); assertThat(actualHandlers).isNotNull().hasSize(1); }