private void setContainerName(final String containerId) { final Optional<ServerTemplate> serverTemplate = Optional.ofNullable(getServerTemplate()); final RemoteCallback<String> setContainerName = (validContainerId) -> { view.setContainerName(validContainerId); wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(this)); }; if (serverTemplate.isPresent()) { specManagementService .call(setContainerName) .validContainerId(serverTemplate.get().getId(), containerId); } else { setContainerName.callback(containerId); } }
@Test public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenServerTemplateIsNull() { final String path = "org:kie:1.0"; final GAV gav = new GAV(path); when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav); when(view.getContainerName()).thenReturn(""); presenter.setServerTemplate(null); presenter.asWidget(); presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path)); verify(view).setContainerName(path); verify(specManagementService, never()).validContainerId(anyString(), anyString()); }
@Test public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsNotEmpty() { final String path = "org:kie:1.0"; final String templateId = "templateId"; final GAV gav = new GAV(path); final ServerTemplate serverTemplate = mock(ServerTemplate.class); when(serverTemplate.getId()).thenReturn(templateId); when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav); when(specManagementService.validContainerId(templateId, path)).thenReturn(path); when(view.getContainerName()).thenReturn("custom"); presenter.setServerTemplate(serverTemplate); presenter.asWidget(); presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path)); verify(view, never()).setContainerName(path); }
@Test public void testOnDependencyPathSelectedEventWithDefaultContainerNameWhenContainerNameIsEmpty() { final String path = "org:kie:1.0"; final String templateId = "templateId"; final GAV gav = new GAV(path); final ServerTemplate serverTemplate = mock(ServerTemplate.class); when(serverTemplate.getId()).thenReturn(templateId); when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav); when(specManagementService.validContainerId(templateId, path)).thenReturn(path); when(view.getContainerName()).thenReturn(""); presenter.setServerTemplate(serverTemplate); presenter.asWidget(); presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path)); verify(view).setContainerName(path); }