public ContextMeta build() { return new ContextMeta(getTitle(), getRootURI(), getServices(), getDescription(), getContactName(), getContactURL(), getContactEmail(), getLicenseName(), getLicenseURL(), getVersion(), getHostAddress()); }
@Test public void testRequestHeaderWithParentHeaders() { ContextMetaBuilder contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.addService(Foo1.class); final ServiceMeta serviceMeta = contextMetaBuilder.getServices().get(0); final Map<String, ServiceMethodMeta> serviceMethodMetaMap = Maps.toMap("name", serviceMeta.getMethods()); final ServiceMethodMeta serviceMethodMeta = serviceMethodMetaMap.get("methodWithHeaders"); final RequestMeta requestMeta = serviceMethodMeta.getRequestEndpoints().get(0); assertEquals("/headers", requestMeta.getRequestURI()); assertTrue(requestMeta.hasResponseHeaders()); MultiMap<String, String> headers = requestMeta.getResponseHeaders(); assertEquals(5, headers.size()); assertEquals("BAR", headers.getFirst("FOO")); assertEquals("1.BAR", headers.getFirst("1.FOO")); assertEquals("2.BAR2", headers.getFirst("2.FOO2")); final List<String> controls = (List<String>) headers.getAll(HttpHeaders.CACHE_CONTROL); assertEquals("max-age=0", controls.get(0)); assertEquals("no-cache, no-store", controls.get(1)); }
@Test public void testBuild() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService(service("myService", "/myservice", method( "hello", getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ) ) )); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Test public void testBuildNestedBuilder() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod(method("hello", getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ) )) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Test public void testBuildNestedBuilder2() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod( serviceMethodMetaBuilder().setName("hello") .addRequestEndpoint(getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) )).build() ) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Test public void testBuildNestedBuilder3() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod( serviceMethodMetaBuilder().setName("hello") .addRequestEndpoint( requestMetaBuilder().setRequestURI("/callme/").addParameters( stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ).build() ).build() ) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
public ContextMeta build() { return new ContextMeta(getTitle(), getRootURI(), getServices(), getDescription(), getContactName(), getContactURL(), getContactEmail(), getLicenseName(), getLicenseURL(), getVersion(), getHostAddress()); }
public ContextMeta build() { return new ContextMeta(getTitle(), getRootURI(), getServices(), getDescription(), getContactName(), getContactURL(), getContactEmail(), getLicenseName(), getLicenseURL(), getVersion(), getHostAddress()); }