List of usage examples for org.springframework.web.method HandlerMethod HandlerMethod
private HandlerMethod(HandlerMethod handlerMethod, Object handler)
From source file:capital.scalable.restdocs.misc.MethodAndPathSnippetTest.java
@Test public void simpleRequest() throws Exception { HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "testMethod"); setField(snippet, "expectedType", "method-path"); this.snippet.withContents(equalTo("`POST /test`")); new MethodAndPathSnippet().document(operationBuilder.attribute(HandlerMethod.class.getName(), handlerMethod) .attribute(REQUEST_PATTERN, "/test").request("http://localhost/test").method("POST").build()); }
From source file:org.terasoluna.gfw.web.token.transaction.TransactionTokenInfoStoreTest.java
@Test public void testCreateTransactionTokenInfo01() throws Exception { HandlerMethod handlerMethod = new HandlerMethod(new TransactionTokenSampleController(), TransactionTokenSampleController.class.getDeclaredMethod("fourth", SampleForm.class, Model.class)); TransactionTokenInfo tokenInfo = store.createTransactionTokenInfo(handlerMethod); assertNotNull(tokenInfo);/* www . j a va 2 s . c o m*/ }
From source file:capital.scalable.restdocs.misc.DescriptionSnippetTest.java
@Test public void description() throws Exception { HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "testDescription"); JavadocReader javadocReader = mock(JavadocReader.class); when(javadocReader.resolveMethodComment(TestResource.class, "testDescription")) .thenReturn("Sample method comment<br>\n with newline\n <p>\n and one paragraph\n"); setField(snippet, "expectedType", "description"); this.snippet.withContents(equalTo("Sample method comment" + lineBreak() + "with newline" + lineBreak() + lineBreak() + "and one paragraph")); new DescriptionSnippet().document(operationBuilder.attribute(HandlerMethod.class.getName(), handlerMethod) .attribute(JavadocReader.class.getName(), javadocReader).request("http://localhost/test").build()); }
From source file:org.terasoluna.gfw.web.token.transaction.TransactionTokenInfoStoreTest.java
@Test public void testCreateTransactionTokenInfo02() throws Exception { HandlerMethod handlerMethod = new HandlerMethod(new TransactionTokenSampleController(), TransactionTokenSampleController.class.getDeclaredMethod("first", SampleForm.class, Model.class)); TransactionTokenInfo tokenInfo = store.createTransactionTokenInfo(handlerMethod); assertNotNull(tokenInfo);/* w ww.j a va2 s . co m*/ }
From source file:de.codecentric.boot.admin.web.PrefixHandlerMappingTest.java
@Test public void withoutPrefix() throws Exception { TestController controller = new TestController(); PrefixHandlerMapping mapping = new PrefixHandlerMapping(controller); mapping.setApplicationContext(this.context); mapping.afterPropertiesSet();// ww w .j av a 2 s .c om assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/test")).getHandler(), equalTo((Object) new HandlerMethod(controller, this.method))); assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/noop")), nullValue()); }
From source file:capital.scalable.restdocs.misc.SectionSnippetTest.java
@Test public void noSnippets() throws Exception { HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "getItemById"); setField(snippet, "expectedType", "section"); this.snippet.withContents(equalTo("[[resources-noSnippets]]\n" + "=== Get Item By Id\n\n" + "include::{snippets}/noSnippets/method-path.adoc[]\n\n" + "include::{snippets}/noSnippets/description.adoc[]\n")); new SectionBuilder().snippetNames().build() .document(operationBuilder.attribute(HandlerMethod.class.getName(), handlerMethod) .attribute(ATTRIBUTE_NAME_DEFAULT_SNIPPETS, new ArrayList<>()) .request("http://localhost/items/1").build()); }
From source file:springfox.documentation.spring.data.rest.EntitySearchRequestTemplate.java
Collection<? extends RequestHandler> operations() { List<RequestHandler> requestHandlers = newArrayList(); boolean collectionHandlerAdded = false; for (ResourceMetadata resource : mappings) { for (MethodResourceMapping searchResource : resource.getSearchResourceMappings()) { EntitySearchRequestHandler handler = new EntitySearchRequestHandler(resolver, requestMapping, new HandlerMethod(searchResource.getMethod().getClass(), searchResource.getMethod()), searchResource, resource); if (handler.resourceType() == ResourceType.ITEM || !collectionHandlerAdded) { requestHandlers.add(handler); if (!collectionHandlerAdded) { collectionHandlerAdded = (handler.resourceType() == ResourceType.COLLECTION); }/*from www. j a v a 2 s . co m*/ } } } return requestHandlers; }
From source file:com.microsoft.applicationinsights.web.spring.RequestNameHandlerInterceptorAdapterTests.java
@Before public void testInitialize() throws NoSuchMethodException { handlerMethod = new HandlerMethod(this, DEFAULT_ACTION_NAME); RequestTelemetryContext context = new RequestTelemetryContext(DateTimeUtils.getDateTimeNow().getTime()); ThreadContext.setRequestTelemetryContext(context); }
From source file:capital.scalable.restdocs.payload.JacksonResponseFieldSnippetTest.java
@Test public void simpleResponse() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker() .withFieldVisibility(JsonAutoDetect.Visibility.ANY)); HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "getItem"); JavadocReader javadocReader = mock(JavadocReader.class); when(javadocReader.resolveFieldComment(Item.class, "field1")).thenReturn("A string"); when(javadocReader.resolveFieldComment(Item.class, "field2")).thenReturn("A decimal"); ConstraintReader constraintReader = mock(ConstraintReader.class); when(constraintReader.isMandatory(NotBlank.class)).thenReturn(true); when(constraintReader.getOptionalMessages(Item.class, "field1")).thenReturn(singletonList("false")); when(constraintReader.getConstraintMessages(Item.class, "field2")) .thenReturn(singletonList("A constraint")); this.snippet.expectResponseFields() .withContents(tableWithPrefix("\n", tableWithHeader("Path", "Type", "Optional", "Description") .row("field1", "String", "false", "A string.") .row("field2", "Decimal", "true", "A decimal." + lineBreak() + "A constraint."))); new JacksonResponseFieldSnippet().document(operationBuilder .attribute(HandlerMethod.class.getName(), handlerMethod) .attribute(ObjectMapper.class.getName(), mapper) .attribute(JavadocReader.class.getName(), javadocReader) .attribute(ConstraintReader.class.getName(), constraintReader).request("http://localhost").build()); }
From source file:de.codecentric.boot.admin.web.PrefixHandlerMappingTest.java
@Test public void withPrefix() throws Exception { TestController controller = new TestController(); PrefixHandlerMapping mapping = new PrefixHandlerMapping(controller); mapping.setApplicationContext(this.context); mapping.setPrefix("/pre"); mapping.afterPropertiesSet();/*from www.j av a2 s .co m*/ assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/pre/test")).getHandler(), equalTo((Object) new HandlerMethod(controller, this.method))); assertThat(mapping.getHandler(new MockHttpServletRequest("GET", "/pre/noop")), nullValue()); }