use of cz.metacentrum.perun.audit.events.StringMessageEvent in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method getMessagesPage_ascendingOrder.
@Test
public void getMessagesPage_ascendingOrder() throws Exception {
System.out.println(CLASS_NAME + "getMessagesPage_ascendingOrder");
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test 1"));
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test 2"));
MessagesPageQuery query = new MessagesPageQuery(2, 0, SortingOrder.ASCENDING);
Paginated<AuditMessage> messages = perun.getAuditMessagesManager().getMessagesPage(sess, query);
assertThat(messages.getData().get(0).getId()).isLessThan(messages.getData().get(1).getId());
}
use of cz.metacentrum.perun.audit.events.StringMessageEvent in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method testGetFixedNumberOfMessages.
/**
* Check if method getMessages(sess) return right number of messages
*/
@Test
public void testGetFixedNumberOfMessages() throws Exception {
System.out.println(CLASS_NAME + "testGetFixedNumberOfMessages");
int count = AuditMessagesManager.COUNTOFMESSAGES;
for (int i = 0; i < count; i++) {
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test cislo: " + i));
}
List<AuditMessage> messages = perun.getAuditMessagesManager().getMessages(sess);
assertEquals("getMessage(sess) returns wrong count of messages", count, messages.size());
}
use of cz.metacentrum.perun.audit.events.StringMessageEvent in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method getMessagesPage_allEntries.
@Test
public void getMessagesPage_allEntries() throws Exception {
System.out.println(CLASS_NAME + "getMessagesPage_allEntries");
for (int i = 0; i < 5; i++) {
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test cislo: " + i));
}
MessagesPageQuery query = new MessagesPageQuery(5, 0, SortingOrder.DESCENDING);
Paginated<AuditMessage> messages = perun.getAuditMessagesManager().getMessagesPage(sess, query);
assertThat(messages.getData().size()).isEqualTo(5);
assertThat(messages.getData().stream().map(a -> a.getEvent().getMessage()).collect(Collectors.toList())).isEqualTo(List.of("Test cislo: 4", "Test cislo: 3", "Test cislo: 2", "Test cislo: 1", "Test cislo: 0"));
}
use of cz.metacentrum.perun.audit.events.StringMessageEvent in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method testGetVariableNumberOfMessages.
/**
* Check if method getMessages(sess, count) return right number of messages
*/
@Test
public void testGetVariableNumberOfMessages() throws Exception {
System.out.println(CLASS_NAME + "testGetVariableNumberOfMessages");
int count = 33;
for (int i = 0; i < count; i++) {
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test cislo: " + i));
}
List<AuditMessage> messages = perun.getAuditMessagesManager().getMessages(sess, count);
assertEquals("getMessage(sess, count) returns wrong count of messages", count, messages.size());
}
use of cz.metacentrum.perun.audit.events.StringMessageEvent in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method getMessagesPage_secondPage.
@Test
public void getMessagesPage_secondPage() throws Exception {
System.out.println(CLASS_NAME + "getMessagesPage_secondPage");
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test older"));
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test newer"));
MessagesPageQuery query = new MessagesPageQuery(1, 1, SortingOrder.DESCENDING);
Paginated<AuditMessage> messages = perun.getAuditMessagesManager().getMessagesPage(sess, query);
assertThat(messages.getData().size()).isEqualTo(1);
assertThat(messages.getData().get(0).getEvent().getMessage()).isEqualTo("Test older");
}
Aggregations