Search in sources :

Example 6 with CommentAddRemoveRequest

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));
}
Also used : CommentAddRemoveRequest(org.apache.metron.indexing.dao.update.CommentAddRemoveRequest) Document(org.apache.metron.indexing.dao.update.Document) Test(org.junit.jupiter.api.Test)

Example 7 with CommentAddRemoveRequest

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"));
}
Also used : CommentAddRemoveRequest(org.apache.metron.indexing.dao.update.CommentAddRemoveRequest) Document(org.apache.metron.indexing.dao.update.Document) Test(org.junit.jupiter.api.Test)

Example 8 with CommentAddRemoveRequest

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));
}
Also used : CommentAddRemoveRequest(org.apache.metron.indexing.dao.update.CommentAddRemoveRequest) Document(org.apache.metron.indexing.dao.update.Document) Test(org.junit.jupiter.api.Test)

Example 9 with CommentAddRemoveRequest

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));
}
Also used : CommentAddRemoveRequest(org.apache.metron.indexing.dao.update.CommentAddRemoveRequest) Document(org.apache.metron.indexing.dao.update.Document) Test(org.junit.jupiter.api.Test)

Example 10 with CommentAddRemoveRequest

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());
}
Also used : CommentAddRemoveRequest(org.apache.metron.indexing.dao.update.CommentAddRemoveRequest) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Aggregations

CommentAddRemoveRequest (org.apache.metron.indexing.dao.update.CommentAddRemoveRequest)12 Test (org.junit.jupiter.api.Test)11 Document (org.apache.metron.indexing.dao.update.Document)7 IOException (java.io.IOException)3 SearchIntegrationTest (org.apache.metron.indexing.dao.SearchIntegrationTest)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ResultActions (org.springframework.test.web.servlet.ResultActions)2 AccessConfig (org.apache.metron.indexing.dao.AccessConfig)1 IndexDao (org.apache.metron.indexing.dao.IndexDao)1 MultiIndexDao (org.apache.metron.indexing.dao.MultiIndexDao)1