### Question:
ServicePortFunctionProcessor extends ServiceRegistryFunctionProcessorBase<ServicePortFunctionDescriptor> implements UrlRewriteFunctionProcessor<ServicePortFunctionDescriptor> { @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 ); Port port = template.getPort(); if( port != null ) { parameter = port.getFirstValue().getPattern(); } } results.add( parameter ); } } return results; }  @Override String name(); @Override List<String> resolve( UrlRewriteContext context, List<String> parameters );  }### Answer:
@Test public void testResolve() throws Exception { ServicePortFunctionProcessor func = new ServicePortFunctionProcessor(); func.initialize( env, desc ); assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "777" ) ); assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) ); assertThat( func.resolve( ctx, null ), nullValue() ); func.destroy(); }