Search in sources :

Example 6 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class AsyncKieServerInstanceManagerTest method testContainerOperationSuccess.

private void testContainerOperationSuccess(ContainerRuntimeOperation operation) {
    List<Message> messages = new ArrayList<Message>();
    returnedContainers.addAll(createContainers(KieContainerStatus.STARTED, messages, 1));
    switch(operation) {
        case STOP_CONTAINER:
            this.kieServerInstanceManager.stopContainer(serverTemplate, containerSpec);
            break;
        case START_CONTAINER:
            this.kieServerInstanceManager.startContainer(serverTemplate, containerSpec);
            break;
        case UPGRADE_CONTAINER:
            this.kieServerInstanceManager.upgradeContainer(serverTemplate, containerSpec);
            break;
        case SCAN:
            this.kieServerInstanceManager.scanNow(serverTemplate, containerSpec);
            break;
        case START_SCANNER:
            this.kieServerInstanceManager.startScanner(serverTemplate, containerSpec, 10);
            break;
        case STOP_SCANNER:
            this.kieServerInstanceManager.stopScanner(serverTemplate, containerSpec);
            break;
    }
    assertFalse(receivedEvents.isEmpty());
    assertEquals(1, receivedEvents.size());
    ContainerUpdateEvent updateEvent = receivedEvents.get(0);
    assertContainerUpdateEvent(updateEvent, ContainerRuntimeState.ONLINE, 0);
}
Also used : Message(org.kie.server.api.model.Message) ArrayList(java.util.ArrayList) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)

Example 7 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnContainerNull.

@Test
public void testOnContainerNull() {
    presenter.onContainerUpdate(new ContainerUpdateEvent());
    verify(notification, never()).fire(any());
}
Also used : ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Example 8 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnContainerUpdateFailed.

@Test
public void testOnContainerUpdateFailed() {
    when(view.getErrorMessage(ClientContainerRuntimeOperation.START_CONTAINER, 2)).thenReturn("Error");
    presenter.onContainerUpdate(new ContainerUpdateEvent(mock(ServerTemplateKey.class), mock(ContainerSpec.class), new ArrayList<ServerInstanceKey>() {

        {
            add(mock(ServerInstanceKey.class));
            add(mock(ServerInstanceKey.class));
        }
    }, ContainerRuntimeState.OFFLINE, ContainerRuntimeOperation.START_CONTAINER));
    verify(notification).fire(new NotificationEvent("Error", NotificationEvent.NotificationType.ERROR));
}
Also used : ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Example 9 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnContainerUpdateSuccess.

@Test
public void testOnContainerUpdateSuccess() {
    when(view.getSuccessMessage(ClientContainerRuntimeOperation.START_CONTAINER, 2)).thenReturn("Success");
    presenter.onContainerUpdate(new ContainerUpdateEvent(mock(ServerTemplateKey.class), mock(ContainerSpec.class), new ArrayList<ServerInstanceKey>() {

        {
            add(mock(ServerInstanceKey.class));
            add(mock(ServerInstanceKey.class));
        }
    }, ContainerRuntimeState.ONLINE, ContainerRuntimeOperation.START_CONTAINER));
    verify(notification).fire(new NotificationEvent("Success", NotificationEvent.NotificationType.SUCCESS));
}
Also used : ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Example 10 with ContainerUpdateEvent

use of org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnContainerEmptyList.

@Test
public void testOnContainerEmptyList() {
    presenter.onContainerUpdate(new ContainerUpdateEvent(mock(ServerTemplateKey.class), mock(ContainerSpec.class), Collections.emptyList(), ContainerRuntimeState.PARTIAL_ONLINE, ContainerRuntimeOperation.START_CONTAINER));
    verify(notification, never()).fire(any());
}
Also used : ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Aggregations

ContainerUpdateEvent (org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)10 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)4 Message (org.kie.server.api.model.Message)3 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 Container (org.kie.server.controller.api.model.runtime.Container)1 ContainerRuntimeState (org.kie.workbench.common.screens.server.management.model.ContainerRuntimeState)1