Search in sources :

Example 1 with HttpTest

use of com.eclipsesource.restfuse.annotation.HttpTest 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 HttpTest

use of com.eclipsesource.restfuse.annotation.HttpTest in project restfuse by eclipsesource.

the class HttpTestStatement_Test method testRemovesProxyProperties.

@Test
public void testRemovesProxyProperties() throws Throwable {
    Statement base = mock(Statement.class);
    Description description = mock(Description.class);
    HttpTest annotation = createAnnotation();
    when(description.getAnnotation(HttpTest.class)).thenReturn(annotation);
    Object target = new Object();
    HttpTestStatement statement = new HttpTestStatement(base, description, target, "http://localhost", "http://proxy.com", 8080, null);
    statement.evaluate();
    assertNull(System.getProperty(HttpTestStatement.HTTP_PROXY_HOST));
    assertNull(System.getProperty(HttpTestStatement.HTTP_PROXY_PORT));
}
Also used : HttpTest(com.eclipsesource.restfuse.annotation.HttpTest) Description(org.junit.runner.Description) Statement(org.junit.runners.model.Statement) CallbackStatement(com.eclipsesource.restfuse.internal.callback.CallbackStatement) Test(org.junit.Test) HttpTest(com.eclipsesource.restfuse.annotation.HttpTest)

Example 3 with HttpTest

use of com.eclipsesource.restfuse.annotation.HttpTest 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)

Example 4 with HttpTest

use of com.eclipsesource.restfuse.annotation.HttpTest in project restfuse by eclipsesource.

the class RequestConfiguration method createRequest.

public InternalRequest createRequest(RequestContext context) {
    HttpTest call = description.getAnnotation(HttpTest.class);
    String rawPath = combineUrlAndPath(baseUrl, call.path());
    InternalRequest request = new InternalRequest(substituePathSegments(rawPath, context));
    addAuthentication(call, request);
    addContentType(call, request);
    addHeader(call, request, context);
    addBody(call, request);
    return request;
}
Also used : HttpTest(com.eclipsesource.restfuse.annotation.HttpTest)

Example 5 with HttpTest

use of com.eclipsesource.restfuse.annotation.HttpTest in project restfuse by eclipsesource.

the class HttpOrderComparator method compare.

@Override
public int compare(FrameworkMethod method1, FrameworkMethod method2) {
    HttpTest annotation1 = method1.getAnnotation(HttpTest.class);
    HttpTest annotation2 = method2.getAnnotation(HttpTest.class);
    if (annotation1 != null && annotation2 != null) {
        return Integer.valueOf(annotation1.order()).compareTo(Integer.valueOf(annotation2.order()));
    }
    return 0;
}
Also used : HttpTest(com.eclipsesource.restfuse.annotation.HttpTest)

Aggregations

HttpTest (com.eclipsesource.restfuse.annotation.HttpTest)5 Test (org.junit.Test)3 Description (org.junit.runner.Description)3 RequestContext (com.eclipsesource.restfuse.RequestContext)2 CallbackStatement (com.eclipsesource.restfuse.internal.callback.CallbackStatement)1 Statement (org.junit.runners.model.Statement)1