Search in sources :

Example 1 with EnumService

use of org.drools.workbench.screens.enums.service.EnumService in project drools-wb by kiegroup.

the class EnumEditorPresenterTest method setup.

@Before
public void setup() {
    // Mock EnumResourceType
    this.type = GWT.create(EnumResourceType.class);
    // Mock FileMenuBuilder usage since we cannot use FileMenuBuilderImpl either
    when(mockFileMenuBuilder.addSave(any(MenuItem.class))).thenReturn(mockFileMenuBuilder);
    when(mockFileMenuBuilder.addCopy(any(ObservablePath.class), any(DefaultFileNameValidator.class))).thenReturn(mockFileMenuBuilder);
    when(mockFileMenuBuilder.addRename(any(Command.class))).thenReturn(mockFileMenuBuilder);
    when(mockFileMenuBuilder.addDelete(any(ObservablePath.class))).thenReturn(mockFileMenuBuilder);
    when(mockFileMenuBuilder.addValidate(any(Command.class))).thenReturn(mockFileMenuBuilder);
    when(mockFileMenuBuilder.addNewTopLevelMenu(any(MenuItem.class))).thenReturn(mockFileMenuBuilder);
    when(mockVersionRecordManager.getCurrentPath()).thenReturn(path);
    when(mockVersionRecordManager.getPathToLatest()).thenReturn(path);
    when(mockWorkbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    this.model = new EnumModel("'Fact.field' : ['a', 'b']");
    this.content = new EnumModelContent(model, overview);
    when(enumService.loadContent(path)).thenReturn(content);
    when(view.getContent()).thenReturn(new ArrayList<EnumRow>() {

        {
            add(new EnumRow("Fact", "field", "['a', 'b']"));
        }
    });
    this.enumServiceCaller = new CallerMock<EnumService>(enumService);
    this.presenter = new EnumEditorPresenter(view, enumServiceCaller, type, validationPopup) {

        {
            // Yuck, yuck, yuck... the class hierarchy is really a mess
            this.kieView = mockKieView;
            this.overviewWidget = mockOverviewWidget;
            this.fileMenuBuilder = mockFileMenuBuilder;
            this.fileNameValidator = mockFileNameValidator;
            this.versionRecordManager = mockVersionRecordManager;
            this.notification = mockNotification;
            this.workbenchContext = mockWorkbenchContext;
            this.saveAndRenameCommandBuilder = mockSaveAndRenameCommandBuilder;
            this.alertsButtonMenuItemBuilder = mockAlertsButtonMenuItemBuilder;
        }

        @Override
        protected Command getSaveAndRename() {
            return mock(Command.class);
        }
    };
}
Also used : EnumService(org.drools.workbench.screens.enums.service.EnumService) EnumModelContent(org.drools.workbench.screens.enums.model.EnumModelContent) EnumResourceType(org.drools.workbench.screens.enums.client.type.EnumResourceType) MenuItem(org.uberfire.workbench.model.menu.MenuItem) DefaultFileNameValidator(org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator) Command(org.uberfire.mvp.Command) EnumModel(org.drools.workbench.screens.enums.model.EnumModel) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Before(org.junit.Before)

Aggregations

EnumResourceType (org.drools.workbench.screens.enums.client.type.EnumResourceType)1 EnumModel (org.drools.workbench.screens.enums.model.EnumModel)1 EnumModelContent (org.drools.workbench.screens.enums.model.EnumModelContent)1 EnumService (org.drools.workbench.screens.enums.service.EnumService)1 Before (org.junit.Before)1 ObservablePath (org.uberfire.backend.vfs.ObservablePath)1 DefaultFileNameValidator (org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator)1 Command (org.uberfire.mvp.Command)1 MenuItem (org.uberfire.workbench.model.menu.MenuItem)1