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);
}
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));
}
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());
}
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;
}
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;
}
Aggregations