use of de.ids_mannheim.korap.response.Messages in project Krill by KorAP.
the class TestMessage method CheckIterability.
@Test
public void CheckIterability() {
Messages km = new Messages();
km.add(612, "Foo");
km.add(613, "Bar", "Instanz");
km.add(614, "Test");
String test = "";
for (Message msg : km) test += msg.getCode();
assertEquals(test, "612613614");
}
use of de.ids_mannheim.korap.response.Messages in project Krill by KorAP.
the class TestMessage method StringMessageParameters.
@Test
public void StringMessageParameters() {
Messages km = new Messages();
km.add(612, "Foo");
assertEquals("[[612,\"Foo\"]]", km.toJsonString());
km.add(613, "Bar", "Instanz");
assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"]]", km.toJsonString());
km.add(614, "Test");
assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"],[614,\"Test\"]]", km.toJsonString());
}
use of de.ids_mannheim.korap.response.Messages in project Krill by KorAP.
the class TestNotifications method testNotificationWarnings.
@Test
public void testNotificationWarnings() throws IOException {
Notifications notes = new Notifications();
assertFalse(notes.hasWarnings());
assertFalse(notes.hasMessages());
assertFalse(notes.hasErrors());
notes.addWarning(613, "Foo");
notes.addWarning(614, "Bar", "Spiel");
assertEquals("{\"warnings\":[[613,\"Foo\"],[614,\"Bar\"," + "\"Spiel\"]]}", notes.toJsonString());
assertTrue(notes.hasWarnings());
assertFalse(notes.hasMessages());
assertFalse(notes.hasErrors());
notes.addError(412, "Test");
assertTrue(notes.hasWarnings());
assertFalse(notes.hasMessages());
assertTrue(notes.hasErrors());
JsonNode noteJson = mapper.readTree(notes.toJsonString());
// {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],"errors":[[412,"Test"]]}
assertEquals(613, noteJson.at("/warnings/0/0").asInt());
assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
assertEquals(614, noteJson.at("/warnings/1/0").asInt());
assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
assertEquals("Spiel", noteJson.at("/warnings/1/2").asText());
assertEquals(412, noteJson.at("/errors/0/0").asInt());
assertEquals("Test", noteJson.at("/errors/0/1").asText());
notes.addMessage(567, "Probe", "huhu", "hihi");
assertTrue(notes.hasWarnings());
assertTrue(notes.hasMessages());
assertTrue(notes.hasErrors());
noteJson = mapper.readTree(notes.toJsonString());
// {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],
// "errors":[[412,"Test"]]}
assertEquals(613, noteJson.at("/warnings/0/0").asInt());
assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
assertEquals(614, noteJson.at("/warnings/1/0").asInt());
assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
assertEquals("Spiel", noteJson.at("/warnings/1/2").asText());
assertEquals(412, noteJson.at("/errors/0/0").asInt());
assertEquals("Test", noteJson.at("/errors/0/1").asText());
assertEquals(567, noteJson.at("/messages/0/0").asInt());
assertEquals("Probe", noteJson.at("/messages/0/1").asText());
assertEquals("huhu", noteJson.at("/messages/0/2").asText());
assertEquals("hihi", noteJson.at("/messages/0/3").asText());
// Todo: Check how to check for missing node
Messages msgs = notes.getWarnings();
assertEquals("[[613,\"Foo\"],[614,\"Bar\",\"Spiel\"]]", msgs.toJsonString());
}
use of de.ids_mannheim.korap.response.Messages in project Krill by KorAP.
the class TestMessage method StringMessage.
@Test
public void StringMessage() {
Messages km = new Messages();
assertEquals("[]", km.toJsonString());
}
use of de.ids_mannheim.korap.response.Messages in project Krill by KorAP.
the class TestMessage method StringMessageSet.
@Test
public void StringMessageSet() {
Messages km = new Messages();
km.add(612, "Foo");
assertEquals("[[612,\"Foo\"]]", km.toJsonString());
km.add(613, "Bar");
assertEquals("[[612,\"Foo\"],[613,\"Bar\"]]", km.toJsonString());
}
Aggregations