// Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java
// public class SimpleHttpRequest implements HttpRequest {
// 
//     private final Request request;
//     
//     private final Session session;
//     
//     private final Route route;
//     
//     private final UnmarshallerProvider unmarshallerProvider;
//     
//     public SimpleHttpRequest(Request request, Session session, Route route, 
//             UnmarshallerProvider unmarshallerProvider) {
//         
//         this.request = request;
//         this.session = session;
//         this.route = route;
//         this.unmarshallerProvider = unmarshallerProvider;
//     }
//     
//     public String getPath() {
//         
//         return request.getPath().getPath();
//     }
//     
//     public String getUndecodedPath() {
//         
//         return RequestUtils.getUndecodedPath(request);
//     }
// 
//     public Set<String> getRequestParameterNames() {
//         
//         return request.getQuery().keySet();
//     }
// 
//     public String getRequestParameter(String name) {
//         
//         return request.getParameter(name);
//     }
//     
//     public String getPathParameter(String name) {
//         
//         return getRoute().getNamedParameter(name, getPath());
//     }
//     
//     public List<String> getHeaderNames() {
//         
//         return request.getNames();
//     }
//     
//     public String getHeaderValue(String name) {
//         
//         return request.getValue(name);
//     }
//     
//     public String getBody() {
//         
//         try {
//             return new String(RequestUtils.readBody(getBodyAsStream()));
//         } catch (IOException e) {
//             throw new RuntimeException("error getting body", e);
//         }
//     }
//     
//     public InputStream getBodyAsStream() throws IOException {
//         
//         return request.getInputStream();
//     }
//     
//     public <T> T getBody(Class<T> type) {
//         
//         Unmarshaller unmarshaller = unmarshallerProvider.getUnmarshaller(getContentType());
//         if (unmarshaller == null) {
//             throw new RuntimeException("cannot unmarshall body as type " + 
//                     type.getName() + ", as no unmarshaller is available for" +
//                     		"content-type: " + getContentType());
//         }
//         try {
//             return unmarshaller.unmarshal(getBodyAsStream(), type);
//         } catch (Exception e) {
//             throw new RuntimeException("error unmarshalling", e);
//         }
//     }
//     
//     public long getContentLength() {
//         
//         return request.getContentLength();
//     }
//     
//     public String getContentType() {
//         
//         return request.getContentType().getType();
//     }
//     
//     public String getMethod() {
//         
//         return request.getMethod();
//     }
//     
//     public long getTime() {
//         
//         return request.getRequestTime();
//     }
//     
//     public String getQuery() {
//         
//         return request.getQuery().toString();
//     }
//     
//     public int getMajor() {
//         
//         return request.getMajor();
//     }
//     
//     public int getMinor() {
//         
//         return request.getMinor();
//     }
//     
//     public String getTarget() {
//         
//         return request.getTarget();
//     }
//     
//     public Session getSession() {
//         
//         return session;
//     }
//     
//     public Route getRoute() {
//         
//         return route;
//     }
// }


import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.bigtesting.fixd.request.impl.SimpleHttpRequest;
import org.bigtesting.routd.Route;
import org.junit.Test;
import org.simpleframework.http.Path;
import org.simpleframework.http.Request;
/*
 * Copyright (C) 2015 BigTesting.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.bigtesting.fixd.tests;



/**
 * 
 * @author Luis Antunes
 */
public class TestSimpleHttpRequest {

    @Test
    public void getPathParameter() {
        
        Request request = mock(Request.class);
        Path path = mock(Path.class);
        when(path.getPath()).thenReturn("/first-name/John/last-name/Doe");
        when(request.getPath()).thenReturn(path);
        
        Route route = new Route("/first-name/:firstName/last-name/:lastName");
        
// Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java
// public class SimpleHttpRequest implements HttpRequest {
// 
//     private final Request request;
//     
//     private final Session session;
//     
//     private final Route route;
//     
//     private final UnmarshallerProvider unmarshallerProvider;
//     
//     public SimpleHttpRequest(Request request, Session session, Route route, 
//             UnmarshallerProvider unmarshallerProvider) {
//         
//         this.request = request;
//         this.session = session;
//         this.route = route;
//         this.unmarshallerProvider = unmarshallerProvider;
//     }
//     
//     public String getPath() {
//         
//         return request.getPath().getPath();
//     }
//     
//     public String getUndecodedPath() {
//         
//         return RequestUtils.getUndecodedPath(request);
//     }
// 
//     public Set<String> getRequestParameterNames() {
//         
//         return request.getQuery().keySet();
//     }
// 
//     public String getRequestParameter(String name) {
//         
//         return request.getParameter(name);
//     }
//     
//     public String getPathParameter(String name) {
//         
//         return getRoute().getNamedParameter(name, getPath());
//     }
//     
//     public List<String> getHeaderNames() {
//         
//         return request.getNames();
//     }
//     
//     public String getHeaderValue(String name) {
//         
//         return request.getValue(name);
//     }
//     
//     public String getBody() {
//         
//         try {
//             return new String(RequestUtils.readBody(getBodyAsStream()));
//         } catch (IOException e) {
//             throw new RuntimeException("error getting body", e);
//         }
//     }
//     
//     public InputStream getBodyAsStream() throws IOException {
//         
//         return request.getInputStream();
//     }
//     
//     public <T> T getBody(Class<T> type) {
//         
//         Unmarshaller unmarshaller = unmarshallerProvider.getUnmarshaller(getContentType());
//         if (unmarshaller == null) {
//             throw new RuntimeException("cannot unmarshall body as type " + 
//                     type.getName() + ", as no unmarshaller is available for" +
//                     		"content-type: " + getContentType());
//         }
//         try {
//             return unmarshaller.unmarshal(getBodyAsStream(), type);
//         } catch (Exception e) {
//             throw new RuntimeException("error unmarshalling", e);
//         }
//     }
//     
//     public long getContentLength() {
//         
//         return request.getContentLength();
//     }
//     
//     public String getContentType() {
//         
//         return request.getContentType().getType();
//     }
//     
//     public String getMethod() {
//         
//         return request.getMethod();
//     }
//     
//     public long getTime() {
//         
//         return request.getRequestTime();
//     }
//     
//     public String getQuery() {
//         
//         return request.getQuery().toString();
//     }
//     
//     public int getMajor() {
//         
//         return request.getMajor();
//     }
//     
//     public int getMinor() {
//         
//         return request.getMinor();
//     }
//     
//     public String getTarget() {
//         
//         return request.getTarget();
//     }
//     
//     public Session getSession() {
//         
//         return session;
//     }
//     
//     public Route getRoute() {
//         
//         return route;
//     }
// }


// Path: src/test/java/org/bigtesting/fixd/tests/TestSimpleHttpRequest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.bigtesting.fixd.request.impl.SimpleHttpRequest;
import org.bigtesting.routd.Route;
import org.junit.Test;
import org.simpleframework.http.Path;
import org.simpleframework.http.Request;

/*
 * Copyright (C) 2015 BigTesting.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.bigtesting.fixd.tests;



/**
 * 
 * @author Luis Antunes
 */
public class TestSimpleHttpRequest {

    @Test
    public void getPathParameter() {
        
        Request request = mock(Request.class);
        Path path = mock(Path.class);
        when(path.getPath()).thenReturn("/first-name/John/last-name/Doe");
        when(request.getPath()).thenReturn(path);
        
        Route route = new Route("/first-name/:firstName/last-name/:lastName");
        
        SimpleHttpRequest req = new SimpleHttpRequest(request, null, route, null);