Search in sources :

Example 1 with ContentChangeHandler

use of org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler in project kie-wb-common by kiegroup.

the class NewContainerFormPresenterTest method init.

@Before
public void init() {
    contentChangeHandlers.clear();
    m2RepoServiceCaller = new CallerMock<M2RepoService>(m2RepoService);
    specManagementServiceCaller = new CallerMock<SpecManagementService>(specManagementService);
    doNothing().when(wizardPageStatusChangeEvent).fire(any(WizardPageStatusChangeEvent.class));
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final ContentChangeHandler handler = (ContentChangeHandler) invocation.getArguments()[0];
            contentChangeHandlers.add(handler);
            return null;
        }
    }).when(view).addContentChangeHandler(any(ContentChangeHandler.class));
    doAnswer(contentHandlerAnswer).when(view).setArtifactId(anyString());
    doAnswer(contentHandlerAnswer).when(view).setGroupId(anyString());
    doAnswer(contentHandlerAnswer).when(view).setVersion(anyString());
    presenter = spy(new NewContainerFormPresenter(logger, view, presenterProvider, m2RepoServiceCaller, specManagementServiceCaller, wizardPageStatusChangeEvent));
    doReturn(artifactListWidgetPresenter).when(presenterProvider).get();
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ContentChangeHandler(org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler) M2RepoService(org.guvnor.m2repo.service.M2RepoService) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) Before(org.junit.Before)

Example 2 with ContentChangeHandler

use of org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler in project kie-wb-common by kiegroup.

the class NewTemplatePresenterTest method testAddContentChangeHandler.

@Test
public void testAddContentChangeHandler() {
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final ContentChangeHandler handler = (ContentChangeHandler) invocation.getArguments()[0];
            if (handler != null) {
                handler.onContentChange();
            }
            return null;
        }
    }).when(view).addContentChangeHandler(any(ContentChangeHandler.class));
    presenter.addContentChangeHandler(mock(ContentChangeHandler.class));
    final ArgumentCaptor<WizardPageStatusChangeEvent> eventCaptor = ArgumentCaptor.forClass(WizardPageStatusChangeEvent.class);
    verify(wizardPageStatusChangeEvent).fire(eventCaptor.capture());
    assertEquals(presenter, eventCaptor.getValue().getPage());
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ContentChangeHandler(org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) Test(org.junit.Test)

Example 3 with ContentChangeHandler

use of org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler in project kie-wb-common by kiegroup.

the class NewContainerFormPresenter method init.

@PostConstruct
public void init() {
    view.init(this);
    view.addContentChangeHandler(new ContentChangeHandler() {

        @Override
        public void onContentChange() {
            wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewContainerFormPresenter.this));
        }
    });
}
Also used : ContentChangeHandler(org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) PostConstruct(javax.annotation.PostConstruct)

Example 4 with ContentChangeHandler

use of org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler in project kie-wb-common by kiegroup.

the class NewTemplatePresenter method addContentChangeHandler.

public void addContentChangeHandler(final ContentChangeHandler contentChangeHandler) {
    checkNotNull("contentChangeHandler", contentChangeHandler);
    view.addContentChangeHandler(new ContentChangeHandler() {

        @Override
        public void onContentChange() {
            contentChangeHandler.onContentChange();
            wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewTemplatePresenter.this));
        }
    });
}
Also used : ContentChangeHandler(org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent)

Example 5 with ContentChangeHandler

use of org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler in project kie-wb-common by kiegroup.

the class NewServerTemplateWizardTest method setup.

@Before
public void setup() throws IllegalAccessException, NoSuchFieldException {
    specManagementServiceCaller = new CallerMock<SpecManagementService>(specManagementService);
    when(newTemplatePresenter.getView()).thenReturn(newTemplatePresenterView);
    final Answer addContentChangeHandler = new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            final ContentChangeHandler handler = (ContentChangeHandler) invocation.getArguments()[0];
            contentChangeHandlers.add(handler);
            return null;
        }
    };
    doAnswer(addContentChangeHandler).when(newTemplatePresenter).addContentChangeHandler(any(ContentChangeHandler.class));
    doAnswer(addContentChangeHandler).when(newContainerFormPresenter).addContentChangeHandler(any(ContentChangeHandler.class));
    newServerTemplateWizard = new NewServerTemplateWizard(newTemplatePresenter, newContainerFormPresenter, processConfigPagePresenter, specManagementServiceCaller, notification, serverTemplateListRefreshEvent);
    final Field field = AbstractWizard.class.getDeclaredField("view");
    field.setAccessible(true);
    field.set(newServerTemplateWizard, view);
    newServerTemplateWizard = spy(newServerTemplateWizard);
}
Also used : Answer(org.mockito.stubbing.Answer) Field(java.lang.reflect.Field) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ContentChangeHandler(org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler) SpecManagementService(org.kie.workbench.common.screens.server.management.service.SpecManagementService) Before(org.junit.Before)

Aggregations

ContentChangeHandler (org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler)6 WizardPageStatusChangeEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 Before (org.junit.Before)2 Test (org.junit.Test)2 SpecManagementService (org.kie.workbench.common.screens.server.management.service.SpecManagementService)2 Field (java.lang.reflect.Field)1 PostConstruct (javax.annotation.PostConstruct)1 M2RepoService (org.guvnor.m2repo.service.M2RepoService)1