Search in sources :

Example 6 with ErrorMessage

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());
}
Also used : ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Example 7 with ErrorMessage

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")));
}
Also used : ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Example 8 with ErrorMessage

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());
}
Also used : Request(com.yahoo.processing.Request) ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Example 9 with ErrorMessage

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\":[]}" + "]}"));
}
Also used : ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Example 10 with ErrorMessage

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\"}" + "]}" + "]}"));
}
Also used : ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Aggregations

ErrorMessage (com.yahoo.processing.request.ErrorMessage)19 Test (org.junit.Test)13 Chain (com.yahoo.component.chain.Chain)3 Processor (com.yahoo.processing.Processor)3 Request (com.yahoo.processing.Request)2 Query (com.yahoo.search.Query)2 Result (com.yahoo.search.Result)2 XMLWriter (com.yahoo.text.XMLWriter)2 Iterator (java.util.Iterator)2 Response (com.yahoo.jdisc.Response)1 AsynchronousSectionedRenderer (com.yahoo.processing.rendering.AsynchronousSectionedRenderer)1 ProcessingRenderer (com.yahoo.processing.rendering.ProcessingRenderer)1 Renderer (com.yahoo.processing.rendering.Renderer)1 IOException (java.io.IOException)1 IdentityHashMap (java.util.IdentityHashMap)1