### Question:
ServiceMappedHostFunctionProcessor extends ServiceRegistryFunctionProcessorBase<ServiceMappedHostFunctionDescriptor> implements UrlRewriteFunctionProcessor<ServiceMappedHostFunctionDescriptor> { @Override public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception { List<String> results = null; if( parameters != null ) { results = new ArrayList<>( parameters.size() ); for( String parameter : parameters ) { String url = lookupServiceUrl( parameter ); if( url != null ) { Template template = Parser.parseLiteral( url ); Host host = template.getHost(); if( host != null ) { String hostStr = host.getFirstValue().getPattern(); if( hostmap != null ) { switch( context.getDirection() ) { case IN: parameter = hostmap.resolveInboundHostName( hostStr ); break; case OUT: parameter = hostmap.resolveOutboundHostName( hostStr ); break; } } else { parameter = hostStr; } } } results.add( parameter ); } } return results; }  @Override String name(); @Override void initialize( UrlRewriteEnvironment environment, ServiceMappedHostFunctionDescriptor descriptor ); @Override List<String> resolve( UrlRewriteContext context, List<String> parameters );  }### Answer:
@Test public void testResolve() throws Exception { ServiceMappedHostFunctionProcessor func = new ServiceMappedHostFunctionProcessor(); func.initialize( env, desc ); assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-internal-host" ) ); assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) ); assertThat( func.resolve( ctx, null ), nullValue() ); func.destroy(); }