use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class MultiIndexDaoTest method addCommentShouldAddCommentToAlert.
@Test
public void addCommentShouldAddCommentToAlert() throws Exception {
Document latest = mock(Document.class);
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
when(dao1.addCommentToAlert(request, latest)).thenReturn(document1);
when(dao2.addCommentToAlert(request, latest)).thenReturn(document2);
Document expected = new Document(new HashMap<>(), "guid", "bro", 2L);
assertEquals(expected, multiIndexDao.addCommentToAlert(request, latest));
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class MultiIndexDaoTest method getLatestShouldReturnLatestAlert.
@Test
public void getLatestShouldReturnLatestAlert() throws Exception {
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
when(dao1.getLatest("guid", "bro")).thenReturn(document1);
when(dao2.getLatest("guid", "bro")).thenReturn(document2);
Document expected = new Document(new HashMap<>(), "guid", "bro", 2L);
assertEquals(expected, multiIndexDao.getLatest("guid", "bro"));
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class MultiIndexDaoTest method shouldThrowExceptionWithPartialFailureOnRemoveComment.
@Test
public void shouldThrowExceptionWithPartialFailureOnRemoveComment() throws Exception {
Document latest = mock(Document.class);
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
// dao2 will throw an exception
when(dao1.removeCommentFromAlert(request, latest)).thenReturn(document1);
when(dao2.removeCommentFromAlert(request, latest)).thenThrow(new IllegalStateException());
assertThrows(IOException.class, () -> multiIndexDao.removeCommentFromAlert(request, latest));
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class MultiIndexDaoTest method shouldThrowExceptionWithPartialFailureOnAddComment.
@Test
public void shouldThrowExceptionWithPartialFailureOnAddComment() throws Exception {
Document latest = mock(Document.class);
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
// dao2 will throw an exception
when(dao1.addCommentToAlert(request, latest)).thenReturn(document1);
when(dao2.addCommentToAlert(request, latest)).thenThrow(new IllegalStateException());
assertThrows(IOException.class, () -> multiIndexDao.addCommentToAlert(request, latest));
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class UpdateDaoTest method removeCommentShouldThrowExceptionOnMissingAlert.
@Test
public void removeCommentShouldThrowExceptionOnMissingAlert() {
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
IOException e = assertThrows(IOException.class, () -> getUpdateDao().removeCommentFromAlert(request, null));
assertEquals("Unable to remove comment. Document with guid guid cannot be found.", e.getMessage());
}
Aggregations