use of com.lonepulse.robozombie.model.User in project RoboZombie by sahan.
the class RequestParamEndpointTest method testQueryParamsBatchElementFail.
/**
* <p>Test for a {@link Request} having illegal batch {@link QueryParams} elements.</p>
*
* @since 1.3.0
*/
@Test
public final void testQueryParamsBatchElementFail() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/queryparamsbatchelementfail";
Map<String, User> params = new HashMap<String, User>();
params.put("subject", new User(1, "Kurt", "Wagner", 32, false));
stubFor(get(urlMatching(subpath)).willReturn(aResponse().withStatus(200)));
expectedException.expect(Is.isA(InvocationException.class));
requestEndpoint.queryParamsBatchElementFail(params);
}
use of com.lonepulse.robozombie.model.User in project RoboZombie by sahan.
the class RequestParamEndpointTest method testFormParamsBatchElementFail.
/**
* <p>Test for a {@link Request} having illegal batch {@link FormParams} elements.</p>
*
* @since 1.3.0
*/
@Test
public final void testFormParamsBatchElementFail() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/formparamsbatchelementfail";
Map<String, User> params = new HashMap<String, User>();
params.put("subject", new User(1, "Kurt", "Wagner", 32, false));
stubFor(post(urlMatching(subpath)).willReturn(aResponse().withStatus(200)));
expectedException.expect(Is.isA(InvocationException.class));
requestEndpoint.formParamsBatchElementFail(params);
}
use of com.lonepulse.robozombie.model.User in project RoboZombie by sahan.
the class ResponseEndpointTest method testNoDeserializer.
/**
* <p>Test for a request which expects the raw {@link HttpEntity}.</p>
*
* @since 1.3.0
*/
@Test
public final void testNoDeserializer() {
String subpath = "/nodeserializer";
String url = "http://0.0.0.0:8080" + subpath;
String body = new Gson().toJson(new User(1, "Cain", "Marko", 37, false));
Robolectric.addHttpResponseRule(HttpGet.METHOD_NAME, url, new TestHttpResponse(200, body));
expectedException.expect(Is.isA(InvocationException.class));
responseEndpoint.noDeserializer();
}
use of com.lonepulse.robozombie.model.User in project RoboZombie by sahan.
the class SerializerEndpointTest method testSerializeXml.
/**
* <p>Test for {@link Serializers#XML}.</p>
*
* @since 1.3.0
*/
@Test
public final void testSerializeXml() throws Exception {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/xml";
User user = new User(1, "Shiro", "Wretched-Egg", 17, true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Persister().write(user, baos);
stubFor(put(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200)));
serializerEndpoint.serializeXml(user);
verify(putRequestedFor(urlEqualTo(subpath)).withRequestBody(equalTo(baos.toString())));
}
use of com.lonepulse.robozombie.model.User in project RoboZombie by sahan.
the class SerializerEndpointTest method testSerializeJson.
/**
* <p>Test for {@link Serializers#JSON}.</p>
*
* @since 1.3.0
*/
@Test
public final void testSerializeJson() throws ParseException, IOException {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/json";
User user = new User(1, "Tenzen", "Yakushiji", 300, true);
stubFor(put(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200)));
serializerEndpoint.serializeJson(user);
verify(putRequestedFor(urlEqualTo(subpath)).withRequestBody(equalTo(new Gson().toJson(user))));
}
Aggregations