Search in sources :

Example 16 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class QueryParametersTest method parameterWithEmptyValue.

@Test
public void parameterWithEmptyValue() {
    QueryParameters fullParams = new QueryParameters(Collections.singletonMap("foo", Collections.singletonList("")));
    Assert.assertEquals("foo=", fullParams.getQueryString());
}
Also used : QueryParameters(com.vaadin.flow.router.QueryParameters) Test(org.junit.Test)

Example 17 with QueryParameters

use of com.vaadin.flow.router.QueryParameters in project flow by vaadin.

the class MockServletServiceSessionSetup method createRequest.

public VaadinRequest createRequest(MockServletServiceSessionSetup mocks, String path, String queryString) {
    QueryParameters queryParams = QueryParameters.fromString(queryString);
    Map<String, List<String>> params = queryParams.getParameters();
    HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
    return new VaadinServletRequest(httpServletRequest, mocks.getService()) {

        @Override
        public String getPathInfo() {
            return path;
        }

        @Override
        public String getServletPath() {
            return "";
        }

        @Override
        public ServletContext getServletContext() {
            return mocks.getServletContext();
        }

        @Override
        public String getParameter(String name) {
            if (!params.containsKey(name)) {
                return null;
            }
            return params.get(name).get(0);
        }

        @Override
        public StringBuffer getRequestURL() {
            return new StringBuffer("http://localhost:8888" + getPathInfo());
        }
    };
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ArrayList(java.util.ArrayList) List(java.util.List) QueryParameters(com.vaadin.flow.router.QueryParameters)

Aggregations

QueryParameters (com.vaadin.flow.router.QueryParameters)17 Test (org.junit.Test)15 Location (com.vaadin.flow.router.Location)7 List (java.util.List)4 Router (com.vaadin.flow.router.Router)2 MockVaadinSession (com.vaadin.flow.server.MockVaadinSession)2 VaadinResponse (com.vaadin.flow.server.VaadinResponse)2 MockUI (com.vaadin.tests.util.MockUI)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ExtendedClientDetails (com.vaadin.flow.component.page.ExtendedClientDetails)1 History (com.vaadin.flow.component.page.History)1 HistoryStateChangeEvent (com.vaadin.flow.component.page.History.HistoryStateChangeEvent)1 Element (com.vaadin.flow.dom.Element)1 Node (com.vaadin.flow.dom.Node)1 NodeVisitor (com.vaadin.flow.dom.NodeVisitor)1 AbstractTextElementStateProvider (com.vaadin.flow.dom.impl.AbstractTextElementStateProvider)1 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)1 StateNode (com.vaadin.flow.internal.StateNode)1