use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.
the class ErrorMessageTestCase method testAccessors.
@Test
public void testAccessors() {
ErrorMessage m = new ErrorMessage(37, "message", "detail", new Exception("hello"));
assertEquals(37, m.getCode());
assertEquals("message", m.getMessage());
assertEquals("detail", m.getDetailedMessage());
assertEquals("hello", m.getCause().getMessage());
}
use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.
the class ErrorMessageTestCase method testEquality.
@Test
public void testEquality() {
assertEquals(new ErrorMessage(37, "message", "detail", new Exception("hello")), new ErrorMessage(37, "message", "detail", new Exception("hello")));
assertEquals(new ErrorMessage("message", "detail", new Exception("hello")), new ErrorMessage("message", "detail", new Exception("hello")));
assertEquals(new ErrorMessage("message", new Exception("hello")), new ErrorMessage("message", new Exception("hello")));
assertEquals(new ErrorMessage("message"), new ErrorMessage("message"));
assertEquals(new ErrorMessage("message", new Exception()), new ErrorMessage("message"));
assertFalse(new ErrorMessage("message").equals(new ErrorMessage("message", "detail")));
assertFalse(new ErrorMessage(37, "message").equals(new ErrorMessage("message")));
assertFalse(new ErrorMessage(37, "message").equals(new ErrorMessage(38, "message")));
assertFalse(new ErrorMessage("message", "detail1").equals(new ErrorMessage("message", "detail2")));
assertFalse(new ErrorMessage("message1").equals(new ErrorMessage("message2")));
}
use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.
the class RequestTestCase method testCloning.
@Test
public void testCloning() {
Request request = new Request();
request.properties().set("a", "a1");
request.properties().set("b", "b1");
request.errors().add(new ErrorMessage("foo"));
request.errors().add(new ErrorMessage("bar"));
Request rcloned = request.clone();
rcloned.properties().set("c", "c1");
rcloned.errors().add(new ErrorMessage("baz"));
request.properties().set("d", "d1");
request.errors().add(new ErrorMessage("boz"));
assertEquals("a1", request.properties().get("a"));
assertEquals("a1", rcloned.properties().get("a"));
assertEquals("b1", request.properties().get("b"));
assertEquals("b1", rcloned.properties().get("b"));
assertEquals(null, request.properties().get("c"));
assertEquals("c1", rcloned.properties().get("c"));
assertEquals("d1", request.properties().get("d"));
assertEquals(null, rcloned.properties().get("d"));
assertEquals(3, request.errors().size());
assertEquals(1, rcloned.errors().size());
assertEquals("foo", request.errors().get(0).getMessage());
assertEquals("bar", request.errors().get(1).getMessage());
assertEquals("boz", request.errors().get(2).getMessage());
assertEquals("baz", rcloned.errors().get(0).getMessage());
}
use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.
the class AsynchronousSectionedRendererTest method testProcessingRenderingWithClonedErrorRequestContainingNewErrors.
@Test
public void testProcessingRenderingWithClonedErrorRequestContainingNewErrors() throws IOException, InterruptedException {
StringDataList dataList = createDataList();
// Add errors
dataList.request().errors().add(new ErrorMessage("m1", "d1"));
dataList.request().errors().add(new ErrorMessage("m2", "d2"));
// Cloning a request containing errors
dataList.add(new StringDataList(dataList.request().clone()));
// and adding new errors to it
dataList.asList().get(2).request().errors().add(new ErrorMessage("m3", "d3"));
assertThat(render(dataList), equalTo("{\"errors\":[" + "\"m1: d1\"," + "\"m2: d2\"" + "]," + "\"datalist\":[" + "{\"data\":\"l1\"}," + "{\"datalist\":[" + "{\"data\":\"l11\"}," + "{\"data\":\"l12\"}" + "]}," + "{\"errors\":[" + "\"m3: d3\"" + "]," + "\"datalist\":[]}" + "]}"));
}
use of com.yahoo.processing.request.ErrorMessage in project vespa by vespa-engine.
the class AsynchronousSectionedRendererTest method testProcessingRenderingWithErrors.
@Test
public void testProcessingRenderingWithErrors() throws IOException, InterruptedException {
StringDataList dataList = createDataList();
// Add errors
dataList.request().errors().add(new ErrorMessage("m1", "d1"));
dataList.request().errors().add(new ErrorMessage("m2", "d2"));
assertThat(render(dataList), equalTo("{\"errors\":[" + "\"m1: d1\"," + "\"m2: d2\"" + "]," + "\"datalist\":[" + "{\"data\":\"l1\"}," + "{\"datalist\":[" + "{\"data\":\"l11\"}," + "{\"data\":\"l12\"}" + "]}" + "]}"));
}
Aggregations