use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class MultiIndexDaoTest method removeCommentShouldRemoveCommentFromAlert.
@Test
public void removeCommentShouldRemoveCommentFromAlert() throws Exception {
Document latest = mock(Document.class);
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
when(dao1.removeCommentFromAlert(request, latest)).thenReturn(document1);
when(dao2.removeCommentFromAlert(request, latest)).thenReturn(document2);
Document expected = new Document(new HashMap<>(), "guid", "bro", 2L);
assertEquals(expected, multiIndexDao.removeCommentFromAlert(request, latest));
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class UpdateDaoTest method removeCommentShouldThrowExceptionOnEmptyComments.
@Test
public void removeCommentShouldThrowExceptionOnEmptyComments() throws Exception {
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
Document latest = new Document(new HashMap<>(), "guid", "bro", System.currentTimeMillis());
IOException e = assertThrows(IOException.class, () -> getUpdateDao().removeCommentFromAlert(request, latest));
assertEquals("Unable to remove comment. Document with guid guid has no comments.", e.getMessage());
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class UpdateDaoTest method addCommentShouldThrowExceptionOnMissingAlert.
@Test
public void addCommentShouldThrowExceptionOnMissingAlert() {
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid("guid");
IOException e = assertThrows(IOException.class, () -> getUpdateDao().addCommentToAlert(request, null));
assertEquals("Unable to add comment. Document with guid guid cannot be found.", e.getMessage());
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class UpdateIntegrationTest method buildAlertRequest.
private CommentAddRemoveRequest buildAlertRequest(String guid, String comment, String username, long timestamp) {
CommentAddRemoveRequest request = new CommentAddRemoveRequest();
request.setGuid(guid);
request.setComment(comment);
request.setUsername(username);
request.setTimestamp(timestamp);
request.setSensorType(SENSOR_NAME);
return request;
}
use of org.apache.metron.indexing.dao.update.CommentAddRemoveRequest in project metron by apache.
the class ElasticsearchMetaAlertDaoTest method testInvalidInit.
@Test
public void testInvalidInit() {
IndexDao dao = new IndexDao() {
@Override
public SearchResponse search(SearchRequest searchRequest) {
return null;
}
@Override
public GroupResponse group(GroupRequest groupRequest) {
return null;
}
@Override
public void init(AccessConfig config) {
}
@Override
public Document getLatest(String guid, String sensorType) {
return null;
}
@Override
public Iterable<Document> getAllLatest(List<GetRequest> getRequests) {
return null;
}
@Override
public Document update(Document update, Optional<String> index) {
return update;
}
@Override
public Map<Document, Optional<String>> batchUpdate(Map<Document, Optional<String>> updates) {
return updates;
}
@Override
public Map<String, FieldType> getColumnMetadata(List<String> indices) {
return null;
}
@Override
public Document addCommentToAlert(CommentAddRemoveRequest request) {
return null;
}
@Override
public Document removeCommentFromAlert(CommentAddRemoveRequest request) {
return null;
}
@Override
public Document addCommentToAlert(CommentAddRemoveRequest request, Document latest) {
return null;
}
@Override
public Document removeCommentFromAlert(CommentAddRemoveRequest request, Document latest) {
return null;
}
};
ElasticsearchMetaAlertDao metaAlertDao = new ElasticsearchMetaAlertDao();
assertThrows(IllegalArgumentException.class, () -> metaAlertDao.init(dao));
}
Aggregations