Search in sources :

Example 86 with MultiMap

use of io.vertx.core.MultiMap in project java-chassis by ServiceComb.

the class TestVertxToServletMockRequest method testGetParameterValues.

@Test
public void testGetParameterValues() {
    boolean validAssert = true;
    try {
        HttpServerRequest httpServerRequest = Mockito.mock(HttpServerRequest.class);
        Deencapsulation.setField(instance, "vertxRequest", httpServerRequest);
        MultiMap multiMap = Mockito.mock(MultiMap.class);
        Mockito.when(httpServerRequest.params()).thenReturn(multiMap);
        List<String> stringList = new ArrayList<String>();
        stringList.add("sters");
        Mockito.when(multiMap.getAll("key")).thenReturn(stringList);
        Assert.assertNotNull(instance.getParameterValues("param"));
    } catch (Exception e) {
        Assert.assertNotNull(e);
        validAssert = false;
    } catch (Error e) {
        Assert.assertNotNull(e);
        validAssert = false;
    }
    Assert.assertTrue(validAssert);
}
Also used : MultiMap(io.vertx.core.MultiMap) HttpServerRequest(io.vertx.core.http.HttpServerRequest) ArrayList(java.util.ArrayList) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 87 with MultiMap

use of io.vertx.core.MultiMap in project java-chassis by ServiceComb.

the class TestVertxToServletMockRequest method testGetParameterMap.

@Test
public void testGetParameterMap() {
    boolean validAssert = true;
    try {
        init();
        @SuppressWarnings("unused") Map<String, String[]> paramMap = new HashMap<>();
        HttpServerRequest httpServerRequest = Mockito.mock(HttpServerRequest.class);
        Deencapsulation.setField(instance, "vertxRequest", httpServerRequest);
        MultiMap multiMap = Mockito.mock(MultiMap.class);
        Mockito.when(httpServerRequest.params()).thenReturn(multiMap);
        Set<String> stringSet = new HashSet<String>();
        stringSet.add("sters");
        Mockito.when(multiMap.names()).thenReturn(stringSet);
        Assert.assertNotNull(instance.getParameterMap());
    } catch (Exception e) {
        Assert.assertNotNull(e);
        validAssert = false;
    } catch (Error e) {
        Assert.assertNotNull(e);
        validAssert = false;
    }
    Assert.assertTrue(validAssert);
}
Also used : MultiMap(io.vertx.core.MultiMap) HashMap(java.util.HashMap) HttpServerRequest(io.vertx.core.http.HttpServerRequest) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MultiMap (io.vertx.core.MultiMap)87 Test (org.junit.Test)75 CaseInsensitiveHeaders (io.vertx.core.http.CaseInsensitiveHeaders)61 HashMap (java.util.HashMap)21 ArrayList (java.util.ArrayList)19 Map (java.util.Map)12 Buffer (io.vertx.core.buffer.Buffer)9 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)8 VertxException (io.vertx.core.VertxException)8 HttpClientRequest (io.vertx.core.http.HttpClientRequest)8 HttpMethod (io.vertx.core.http.HttpMethod)8 HeadersAdaptor (io.vertx.core.http.impl.HeadersAdaptor)8 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)7 InternalLoggerFactory (io.netty.util.internal.logging.InternalLoggerFactory)7 Nullable (io.vertx.codegen.annotations.Nullable)7 AbstractVerticle (io.vertx.core.AbstractVerticle)7 AsyncResult (io.vertx.core.AsyncResult)7 Context (io.vertx.core.Context)7 DeploymentOptions (io.vertx.core.DeploymentOptions)7 Future (io.vertx.core.Future)7