Search in sources :

Example 1 with RequestContext

use of com.eclipsesource.restfuse.RequestContext in project restfuse by eclipsesource.

the class RequestConfiguration_Test method testPathWithNonExistingSegments.

@Test(expected = IllegalStateException.class)
public void testPathWithNonExistingSegments() {
    Description method = mock(Description.class);
    HttpTest annotation = createAnnotation("/people/{invalid}/name");
    when(method.getAnnotation(HttpTest.class)).thenReturn(annotation);
    RequestConfiguration config = new RequestConfiguration("http://www.fake.com", method, new Object());
    RequestContext context = new RequestContext();
    context.addPathSegment("id", "12345");
    config.createRequest(context);
}
Also used : HttpTest(com.eclipsesource.restfuse.annotation.HttpTest) Description(org.junit.runner.Description) RequestContext(com.eclipsesource.restfuse.RequestContext) Test(org.junit.Test) HttpTest(com.eclipsesource.restfuse.annotation.HttpTest)

Example 2 with RequestContext

use of com.eclipsesource.restfuse.RequestContext in project restfuse by eclipsesource.

the class DynamicPathTest method getDestination.

private Destination getDestination() {
    Destination destination = new Destination(this, "http://search.maven.org/remotecontent?filepath=" + "com/restfuse/com.eclipsesource.restfuse/{version}/");
    RequestContext context = destination.getRequestContext();
    context.addPathSegment("file", "com.eclipsesource.restfuse-1.1.1").addPathSegment("version", "1.1.1");
    return destination;
}
Also used : Destination(com.eclipsesource.restfuse.Destination) RequestContext(com.eclipsesource.restfuse.RequestContext)

Example 3 with RequestContext

use of com.eclipsesource.restfuse.RequestContext in project restfuse by eclipsesource.

the class RequestConfiguration_Test method testPathWithSegments.

@Test
public void testPathWithSegments() {
    Description description = mock(Description.class);
    HttpTest annotation = createAnnotation("/people/{id}/{name}");
    when(description.getAnnotation(HttpTest.class)).thenReturn(annotation);
    RequestConfiguration config = new RequestConfiguration("http://www.fake.com", description, new Object());
    RequestContext context = new RequestContext();
    context.addPathSegment("id", "12345");
    context.addPathSegment("name", "name");
    InternalRequest request = config.createRequest(context);
    assertEquals("http://www.fake.com/people/12345/name", request.getUrl());
}
Also used : HttpTest(com.eclipsesource.restfuse.annotation.HttpTest) Description(org.junit.runner.Description) RequestContext(com.eclipsesource.restfuse.RequestContext) Test(org.junit.Test) HttpTest(com.eclipsesource.restfuse.annotation.HttpTest)

Aggregations

RequestContext (com.eclipsesource.restfuse.RequestContext)3 HttpTest (com.eclipsesource.restfuse.annotation.HttpTest)2 Test (org.junit.Test)2 Description (org.junit.runner.Description)2 Destination (com.eclipsesource.restfuse.Destination)1