Search in sources :

Example 1 with MessagesPageQuery

use of cz.metacentrum.perun.core.api.MessagesPageQuery 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());
}
Also used : AuditMessage(cz.metacentrum.perun.core.api.AuditMessage) StringMessageEvent(cz.metacentrum.perun.audit.events.StringMessageEvent) MessagesPageQuery(cz.metacentrum.perun.core.api.MessagesPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 2 with MessagesPageQuery

use of cz.metacentrum.perun.core.api.MessagesPageQuery 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"));
}
Also used : StringMessageEvent(cz.metacentrum.perun.audit.events.StringMessageEvent) MessagesPageQuery(cz.metacentrum.perun.core.api.MessagesPageQuery) Facility(cz.metacentrum.perun.core.api.Facility) WrongRangeOfCountException(cz.metacentrum.perun.core.api.exceptions.WrongRangeOfCountException) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) AuditMessage(cz.metacentrum.perun.core.api.AuditMessage) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AuditMessagesManagerImpl(cz.metacentrum.perun.core.impl.AuditMessagesManagerImpl) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) Paginated(cz.metacentrum.perun.core.api.Paginated) Test(org.junit.Test) AuditMessagesManager(cz.metacentrum.perun.core.api.AuditMessagesManager) EnrichedSponsorship(cz.metacentrum.perun.core.api.EnrichedSponsorship) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) SponsorshipExpired(cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpired) Collectors(java.util.stream.Collectors) List(java.util.List) SponsorshipEstablished(cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipEstablished) LocalDate(java.time.LocalDate) SortingOrder(cz.metacentrum.perun.core.api.SortingOrder) FacilityCreated(cz.metacentrum.perun.audit.events.FacilityManagerEvents.FacilityCreated) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) AuditMessage(cz.metacentrum.perun.core.api.AuditMessage) StringMessageEvent(cz.metacentrum.perun.audit.events.StringMessageEvent) MessagesPageQuery(cz.metacentrum.perun.core.api.MessagesPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 3 with MessagesPageQuery

use of cz.metacentrum.perun.core.api.MessagesPageQuery 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");
}
Also used : AuditMessage(cz.metacentrum.perun.core.api.AuditMessage) StringMessageEvent(cz.metacentrum.perun.audit.events.StringMessageEvent) MessagesPageQuery(cz.metacentrum.perun.core.api.MessagesPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 4 with MessagesPageQuery

use of cz.metacentrum.perun.core.api.MessagesPageQuery in project perun by CESNET.

the class AuditMessagesManagerEntryIntegrationTest method getMessagesPage_oneOfMany.

@Test
public void getMessagesPage_oneOfMany() throws Exception {
    System.out.println(CLASS_NAME + "getMessagesPage_oneOfMany");
    perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test older"));
    perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test newer"));
    MessagesPageQuery query = new MessagesPageQuery(1, 0, 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 newer");
}
Also used : AuditMessage(cz.metacentrum.perun.core.api.AuditMessage) StringMessageEvent(cz.metacentrum.perun.audit.events.StringMessageEvent) MessagesPageQuery(cz.metacentrum.perun.core.api.MessagesPageQuery) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

StringMessageEvent (cz.metacentrum.perun.audit.events.StringMessageEvent)4 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)4 AuditMessage (cz.metacentrum.perun.core.api.AuditMessage)4 MessagesPageQuery (cz.metacentrum.perun.core.api.MessagesPageQuery)4 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)1 SponsorshipExpired (cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpired)1 FacilityCreated (cz.metacentrum.perun.audit.events.FacilityManagerEvents.FacilityCreated)1 SponsorshipEstablished (cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipEstablished)1 AuditMessagesManager (cz.metacentrum.perun.core.api.AuditMessagesManager)1 EnrichedSponsorship (cz.metacentrum.perun.core.api.EnrichedSponsorship)1 Facility (cz.metacentrum.perun.core.api.Facility)1 Paginated (cz.metacentrum.perun.core.api.Paginated)1 SortingOrder (cz.metacentrum.perun.core.api.SortingOrder)1 WrongRangeOfCountException (cz.metacentrum.perun.core.api.exceptions.WrongRangeOfCountException)1 AuditMessagesManagerImpl (cz.metacentrum.perun.core.impl.AuditMessagesManagerImpl)1 LocalDate (java.time.LocalDate)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1