Search in sources :

Example 11 with WizardPageStatusChangeEvent

use of org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent in project kie-wb-common by kiegroup.

the class SearchAnnotationPageTest method testSearchAnnotationNotFound.

@Test
public void testSearchAnnotationNotFound() {
    modelerServiceCaller = new CallerMock<DataModelerService>(modelerService);
    SearchAnnotationPage searchPage = new SearchAnnotationPage(view, modelerServiceCaller, wizardPageStatusChangeEvent);
    searchPage.init(kieModule, ElementType.FIELD);
    searchPage.prepareView();
    searchPage.addSearchAnnotationHandler(searchAnnotationHandler);
    // emulates the user is typing
    searchPage.onSearchClassChanged();
    // the wizard page should be automatically invalidated since the annotation class name to search
    // has changed.
    verify(wizardPageStatusChangeEvent, times(1)).fire(any(WizardPageStatusChangeEvent.class));
    WizardTestUtil.assertPageComplete(false, searchPage);
    assertEquals(CreateAnnotationWizardPage.PageStatus.NOT_VALIDATED, searchPage.getStatus());
    // the handler should also have been invocked.
    verify(searchAnnotationHandler, times(1)).onSearchClassChanged();
    // emulate the user is searching the javax.persistence.Entity annotation.
    AnnotationDefinitionRequest request = new AnnotationDefinitionRequest(Entity.class.getName());
    // empty response was returned
    AnnotationDefinitionResponse response = new AnnotationDefinitionResponse(null);
    when(view.getClassName()).thenReturn(Entity.class.getName());
    when(modelerService.resolveDefinitionRequest(request, kieModule)).thenReturn(response);
    // emulate the user click on the search button
    searchPage.onSearchClass();
    // now the page should be completed
    WizardTestUtil.assertPageComplete(false, searchPage);
    verify(wizardPageStatusChangeEvent, times(2)).fire(any(WizardPageStatusChangeEvent.class));
    // the handler should also have been invoked with the expected annotation definition.
    verify(searchAnnotationHandler, times(1)).onAnnotationDefinitionChange(null);
}
Also used : Entity(javax.persistence.Entity) DataModelerService(org.kie.workbench.common.screens.datamodeller.service.DataModelerService) AnnotationDefinitionRequest(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionRequest) AnnotationDefinitionResponse(org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionResponse) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) Test(org.junit.Test)

Example 12 with WizardPageStatusChangeEvent

use of org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent 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 13 with WizardPageStatusChangeEvent

use of org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent in project kie-wb-common by kiegroup.

the class CreateAnnotationWizardPage method fireStatusChangeEvent.

public void fireStatusChangeEvent() {
    final WizardPageStatusChangeEvent event = new WizardPageStatusChangeEvent(this);
    wizardPageStatusChangeEvent.fire(event);
}
Also used : WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent)

Example 14 with WizardPageStatusChangeEvent

use of org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent 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 15 with WizardPageStatusChangeEvent

use of org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent in project kie-wb-common by kiegroup.

the class NewContainerFormPresenter method onDependencyPathSelectedEvent.

void onDependencyPathSelectedEvent(@Observes final DependencyPathSelectedEvent event) {
    if (event != null && event.getContext() != null && event.getPath() != null) {
        if (event.getContext().equals(artifactListWidgetPresenter)) {
            m2RepoService.call(new RemoteCallback<GAV>() {

                @Override
                public void callback(GAV gav) {
                    setAValidContainerName(gav.toString());
                    view.setGroupId(gav.getGroupId());
                    view.setArtifactId(gav.getArtifactId());
                    view.setVersion(gav.getVersion());
                    wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewContainerFormPresenter.this));
                }
            }).loadGAVFromJar(event.getPath());
        }
    } else {
        logger.warn("Illegal event argument.");
    }
}
Also used : WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) GAV(org.guvnor.common.services.project.model.GAV)

Aggregations

WizardPageStatusChangeEvent (org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent)27 Test (org.junit.Test)8 ContentChangeHandler (org.kie.workbench.common.screens.server.management.client.util.ContentChangeHandler)5 Entity (javax.persistence.Entity)2 GAV (org.guvnor.common.services.project.model.GAV)2 DataModelerService (org.kie.workbench.common.screens.datamodeller.service.DataModelerService)2 AnnotationDefinitionRequest (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionRequest)2 AnnotationDefinitionResponse (org.kie.workbench.common.services.datamodeller.driver.model.AnnotationDefinitionResponse)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 PostConstruct (javax.annotation.PostConstruct)1 PipelineParamsPagePresenter (org.guvnor.ala.ui.client.wizard.pipeline.params.PipelineParamsPagePresenter)1 ArtifactIdChangeHandler (org.guvnor.common.services.project.client.ArtifactIdChangeHandler)1 GroupIdChangeHandler (org.guvnor.common.services.project.client.GroupIdChangeHandler)1 NameChangeHandler (org.guvnor.common.services.project.client.NameChangeHandler)1 VersionChangeHandler (org.guvnor.common.services.project.client.VersionChangeHandler)1 M2RepoService (org.guvnor.m2repo.service.M2RepoService)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 Before (org.junit.Before)1 ReleaseId (org.kie.server.api.model.ReleaseId)1