Search in sources :

Example 36 with Event

use of com.enonic.xp.event.Event in project xp by enonic.

the class RepositoryEventListenerTest method node_restored_event.

@Test
public void node_restored_event() throws Exception {
    final Event localEvent = RepositoryEvents.restored();
    repositoryEventListener.onEvent(Event.create(localEvent).localOrigin(false).build());
    Mockito.verify(storageService, Mockito.times(1)).invalidate();
    Mockito.verify(repositoryService, Mockito.times(1)).invalidateAll();
}
Also used : Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Example 37 with Event

use of com.enonic.xp.event.Event in project xp by enonic.

the class TaskEventsTest method removed.

@Test
public void removed() {
    TaskInfo taskInfo = TaskInfo.create().id(TaskId.from("task1")).name("name1").description("Task1 description").application(ApplicationKey.from("com.enonic.myapp")).user(PrincipalKey.from("user:store:me")).startTime(Instant.parse("2017-10-01T09:00:00Z")).state(TaskState.FINISHED).build();
    final Event event = TaskEvents.removed(taskInfo);
    assertEquals(TaskEvents.TASK_REMOVED_EVENT, event.getType());
    assertEquals("task1", event.getValueAs(String.class, "id").get());
    assertEquals("name1", event.getValueAs(String.class, "name").get());
    assertEquals("Task1 description", event.getValueAs(String.class, "description").get());
    assertEquals("FINISHED", event.getValueAs(String.class, "state").get());
    assertEquals("com.enonic.myapp", event.getValueAs(String.class, "application").get());
    assertEquals("user:store:me", event.getValueAs(String.class, "user").get());
    assertEquals("2017-10-01T09:00:00Z", event.getValueAs(String.class, "startTime").get());
}
Also used : TaskInfo(com.enonic.xp.task.TaskInfo) Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Example 38 with Event

use of com.enonic.xp.event.Event in project xp by enonic.

the class TaskEventsTest method submitted.

@Test
public void submitted() {
    TaskInfo taskInfo = TaskInfo.create().id(TaskId.from("task1")).name("name1").description("Task1 description").application(ApplicationKey.from("com.enonic.myapp")).user(PrincipalKey.from("user:store:me")).startTime(Instant.parse("2017-10-01T09:00:00Z")).progress(TaskProgress.create().current(2).total(42).info("Processing").build()).build();
    final Event event = TaskEvents.submitted(taskInfo);
    assertEquals(TaskEvents.TASK_SUBMITTED_EVENT, event.getType());
    assertEquals("task1", event.getValueAs(String.class, "id").get());
    assertEquals("name1", event.getValueAs(String.class, "name").get());
    assertEquals("Task1 description", event.getValueAs(String.class, "description").get());
    assertEquals("WAITING", event.getValueAs(String.class, "state").get());
    assertEquals("com.enonic.myapp", event.getValueAs(String.class, "application").get());
    assertEquals("user:store:me", event.getValueAs(String.class, "user").get());
    assertEquals("2017-10-01T09:00:00Z", event.getValueAs(String.class, "startTime").get());
    Map<?, ?> progress = event.getValueAs(Map.class, "progress").get();
    assertEquals(2, progress.get("current"));
    assertEquals(42, progress.get("total"));
    assertEquals("Processing", progress.get("info"));
}
Also used : TaskInfo(com.enonic.xp.task.TaskInfo) Event(com.enonic.xp.event.Event) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 39 with Event

use of com.enonic.xp.event.Event in project xp by enonic.

the class TaskEventsTest method failed.

@Test
public void failed() {
    TaskInfo taskInfo = TaskInfo.create().id(TaskId.from("task1")).name("name1").description("Task1 description").application(ApplicationKey.from("com.enonic.myapp")).user(PrincipalKey.from("user:store:me")).startTime(Instant.parse("2017-10-01T09:00:00Z")).state(TaskState.FAILED).build();
    final Event event = TaskEvents.failed(taskInfo);
    assertEquals(TaskEvents.TASK_FAILED_EVENT, event.getType());
    assertEquals("task1", event.getValueAs(String.class, "id").get());
    assertEquals("name1", event.getValueAs(String.class, "name").get());
    assertEquals("Task1 description", event.getValueAs(String.class, "description").get());
    assertEquals("FAILED", event.getValueAs(String.class, "state").get());
    assertEquals("com.enonic.myapp", event.getValueAs(String.class, "application").get());
    assertEquals("user:store:me", event.getValueAs(String.class, "user").get());
    assertEquals("2017-10-01T09:00:00Z", event.getValueAs(String.class, "startTime").get());
}
Also used : TaskInfo(com.enonic.xp.task.TaskInfo) Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Example 40 with Event

use of com.enonic.xp.event.Event in project xp by enonic.

the class TaskEventsTest method checkNull.

@Test
public void checkNull() {
    final Event event = TaskEvents.submitted(null);
    assertNull(event);
}
Also used : Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Aggregations

Event (com.enonic.xp.event.Event)48 Test (org.junit.jupiter.api.Test)46 Node (com.enonic.xp.node.Node)12 NodeId (com.enonic.xp.node.NodeId)7 NodePath (com.enonic.xp.node.NodePath)7 InternalContext (com.enonic.xp.repo.impl.InternalContext)7 EventListener (com.enonic.xp.event.EventListener)6 TaskInfo (com.enonic.xp.task.TaskInfo)6 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)3 ScriptEventListener (com.enonic.xp.script.event.ScriptEventListener)3 Branch (com.enonic.xp.branch.Branch)2 PushNodeEntries (com.enonic.xp.node.PushNodeEntries)2 NodeMovedParams (com.enonic.xp.repo.impl.storage.NodeMovedParams)2 RepositoryId (com.enonic.xp.repository.RepositoryId)2 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)2 MapSerializable (com.enonic.xp.script.serializer.MapSerializable)2 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)2 Member (com.hazelcast.core.Member)2 Message (com.hazelcast.core.Message)2 List (java.util.List)2