package com.gentics.mesh.etc;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Test;

import com.gentics.mesh.router.RouterStorage;

import io.vertx.core.http.CaseInsensitiveHeaders;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.ParsedHeaderValues;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RouteImpl;

public class RouterStorageTest {

	private RouterStorage storage = new RouterStorage(null, null, null, null);

	@Test
	public void testFailureHandler() throws Exception {
		RoutingContext rc = mock(RoutingContext.class);
		Route currentRoute = mock(RouteImpl.class);
		when(currentRoute.getPath()).thenReturn("/blub");
		when(rc.currentRoute()).thenReturn(currentRoute);
		ParsedHeaderValues headerValues = mock(ParsedHeaderValues.class);
		when(rc.parsedHeaders()).thenReturn(headerValues);
		HttpServerRequest request = mock(HttpServerRequest.class);
		when(request.query()).thenReturn("?blub");
		when(request.method()).thenReturn(HttpMethod.GET);
		when(request.uri()).thenReturn("");
		when(rc.request()).thenReturn(request);
		when(rc.normalisedPath()).thenReturn("/blub");
		when(rc.queryParams()).thenReturn(new CaseInsensitiveHeaders());
		storage.root().getRouter().handleFailure(rc);
	}
}

@@ -128,16 +128,90 @@
 t.Test;%0A
+import org.mockito.Mockito;%0A%0Aimport com.gentics.mesh.graphdb.spi.Database;
 %0Aimport 
@@ -578,143 +578,183 @@
 %7B%0A%0A%09
-private RouterStorage storage = new RouterStorage(null, null, null, null);%0A%0A%09@Test%0A%09public void testFailureHandler() throws Exception %7B
+@Test%0A%09public void testFailureHandler() throws Exception %7B%0A%09%09RouterStorage storage = new RouterStorage(null, null, null, () -%3E %7B%0A%09%09%09return Mockito.mock(Database.class);%0A%09%09%7D);%0A
 %0A%09%09R

Fix test