use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.
the class ContainerPresenter method resetReleaseIdForFailedContainers.
private void resetReleaseIdForFailedContainers(Collection<Container> containers, ContainerSpec containerSpec) {
containers.forEach(container -> {
if (KieContainerStatus.FAILED == container.getStatus() || container.getResolvedReleasedId() == null) {
container.setResolvedReleasedId(containerSpec.getReleasedId());
container.addMessage(new Message(Severity.ERROR, Collections.emptyList()));
}
});
}
use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.
the class BodyPresenter method setup.
public void setup(final Collection<Message> messages) {
checkNotNull("messages", messages);
view.clear();
if (messages.isEmpty()) {
view.addNotification(setupNotification(null).getView());
} else {
for (final Message message : messages) {
view.addNotification(setupNotification(message).getView());
}
}
}
use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.
the class AsyncKieServerInstanceManagerTest method testContainerOperationFailure.
private void testContainerOperationFailure(ContainerRuntimeOperation operation) {
List<Message> messages = new ArrayList<Message>();
messages.add(new Message(Severity.ERROR, "No kmodule found"));
returnedContainers.addAll(createContainers(KieContainerStatus.FAILED, 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.OFFLINE, 1);
}
use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.
the class ContainerCardPresenterTest method testSetup.
@Test
public void testSetup() {
final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class);
when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter);
final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class)));
when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter);
final BodyPresenter bodyPresenter = mock(BodyPresenter.class);
when(bodyPresenterProvider.get()).thenReturn(bodyPresenter);
final FooterPresenter footerPresenter = mock(FooterPresenter.class);
when(footerPresenterProvider.get()).thenReturn(footerPresenter);
final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class);
final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView));
when(cardPresenterProvider.get()).thenReturn(cardPresenter);
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
final Message message = new Message(Severity.INFO, "testMessage");
final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0");
final Container container = new Container("containerSpecId", "containerName", serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null);
presenter.setup(container);
verify(linkTitlePresenter).setup(eq(container.getContainerName()), any(Command.class));
verify(infoTitlePresenter).setup(container.getResolvedReleasedId());
verify(bodyPresenter).setup(Arrays.asList(message));
verify(footerPresenter).setup(container.getUrl(), resolvedReleasedId.getVersion());
verify(cardPresenter).addTitle(linkTitlePresenter);
verify(cardPresenter).addTitle(infoTitlePresenter);
verify(cardPresenter).addBody(bodyPresenter);
verify(cardPresenter).addFooter(footerPresenter);
verify(view).setCard(cardPresenterView);
linkTitlePresenter.onSelect();
final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), ""));
verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey)));
}
use of org.kie.server.api.model.Message in project kie-wb-common by kiegroup.
the class ContainerCardPresenterTest method testSetupWithUnNamedContainer.
@Test
public void testSetupWithUnNamedContainer() {
final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class);
when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter);
final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class)));
when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter);
final BodyPresenter bodyPresenter = mock(BodyPresenter.class);
when(bodyPresenterProvider.get()).thenReturn(bodyPresenter);
final FooterPresenter footerPresenter = mock(FooterPresenter.class);
when(footerPresenterProvider.get()).thenReturn(footerPresenter);
final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class);
final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView));
when(cardPresenterProvider.get()).thenReturn(cardPresenter);
final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url");
final Message message = new Message(Severity.INFO, "testMessage");
final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0");
final Container container = new Container("containerSpecId", null, serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null);
presenter.setup(container);
verify(linkTitlePresenter).setup(eq(container.getContainerSpecId()), any(Command.class));
verify(view).setCard(cardPresenterView);
linkTitlePresenter.onSelect();
final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerSpecId(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), ""));
verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey)));
}
Aggregations