当前位置: 首页>>代码示例>>Java>>正文


Java GwtMockito.useProviderForType方法代码示例

本文整理汇总了Java中com.google.gwtmockito.GwtMockito.useProviderForType方法的典型用法代码示例。如果您正苦于以下问题:Java GwtMockito.useProviderForType方法的具体用法?Java GwtMockito.useProviderForType怎么用?Java GwtMockito.useProviderForType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwtmockito.GwtMockito的用法示例。


在下文中一共展示了GwtMockito.useProviderForType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() {
    imageAnchorMock = mock(ImageAnchor.class);
    GwtMockito.useProviderForType(ImageAnchor.class,
                                  new FakeProvider<ImageAnchor>() {
                                      @Override
                                      public ImageAnchor getFake(Class<?> aClass) {
                                          return imageAnchorMock;
                                      }
                                  });

    commentRow = new CommentRowWidget() {
        @Override
        SocialUserImageProvider getSocialUserImageProvider() {
            final SocialUserImageProvider provider = mock(SocialUserImageProvider.class);
            when(provider.getImageForSocialUser(any(SocialUser.class),
                                                any(
                                                        SocialUserImageRepositoryAPI.ImageSize.class))).thenReturn(mock(Image.class));
            return provider;
        }
    };
    commentRow.left = new FlowPanel();
    updateItem = new UpdateItem(new SocialActivitiesEvent(new SocialUser("dora"),
                                                          "",
                                                          new Date()));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:27,代码来源:CommentRowWidgetTest.java

示例2: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() {
    GwtMockito.useProviderForType(SimpleEventBus.class,
                                  new FakeProvider() {
                                      @Override
                                      public Object getFake(Class aClass) {
                                          return simpleEventBus;
                                      }
                                  });

    ctx = mock(ModalConfigurationContext.class);
    cleanupPlaceRequest = mock(Command.class);
    editScreen = spy(new EditScreenFake(ctx,
                                        cleanupPlaceRequest));

    when(editScreen.addHiddenHandler(Mockito.any(ModalHiddenHandler.class))).thenAnswer(new Answer() {
        public Object answer(InvocationOnMock aInvocation) throws Throwable {
            modalHiddenHandler = (ModalHiddenHandler) aInvocation.getArguments()[0];
            return null;
        }
    });

    editScreen.realAddHiddenHandler();
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:EditScreenTest.java

示例3: setUp

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    // Mock The ListBox with loaded choices
    GwtMockito.useProviderForType(ListBox.class, new FakeProvider<ListBox>() {
        @Override
        public ListBox getFake(Class<?> aClass) {
            return choices;
        }
    });

    // Mock partially the AsyncPackageDataModelOracle
    incrementalDataModelServiceCaller = new CallerMock<>(incrementalDataModelService);
    validatorInstance = new MockInstanceImpl<>();
    oracle = spy(new AsyncPackageDataModelOracleImpl(incrementalDataModelServiceCaller, validatorInstance));

    // Mock partially the AsyncPackageDataModelOracleFactory
    doReturn(syncBeanDef).when(syncBeanManager).lookupBean(AsyncPackageDataModelOracle.class);
    doReturn(oracle).when(syncBeanDef).getInstance();
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:20,代码来源:RuleModellerConditionSelectorPopupTest.java

示例4: setUp

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    fromCollectWidget = new FromCollectCompositeFactPatternWidget(ruleModeller,
                                                                  eventBus,
                                                                  pattern);

    GwtMockito.useProviderForType(ListBox.class,
                                  new ListBoxFakeProvider());

    collectionTypes = new ArrayList<String>() {{
        add("ArrayList");
        add("HashSet");
    }};

    when(ruleModeller.getDataModelOracle()).thenReturn(oracle);
    when(oracle.getAvailableCollectionTypes()).thenReturn(collectionTypes);
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:18,代码来源:FromCollectCompositeFactPatternWidgetTest.java

示例5: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() {
    GwtMockito.useProviderForType(TextBox.class, (aClass -> disabledTextBox));

    when(defaultValue.getDataType()).thenReturn(DataType.DataTypes.STRING);
    when(editingCol.getDefaultValue()).thenReturn(defaultValue);
    when(presenter.getModel()).thenReturn(model);
    when(presenter.getDataModelOracle()).thenReturn(oracle);
    when(plugin.patternWrapper()).thenReturn(patternWrapper);
    when(plugin.editingCol()).thenReturn(editingCol);
    when(plugin.getPresenter()).thenReturn(presenter);
    when(plugin.editingPattern()).thenReturn(pattern52);
    when(page.plugin()).thenReturn(plugin);
    when(model.getTableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);

    doCallRealMethod().when(plugin).defaultValueWidget();
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:18,代码来源:ValueOptionsPageTest.java

示例6: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() throws NoSuchFieldException, IllegalAccessException {
    GwtMockito.useProviderForType( WorkbenchResources.class,
                                   ( type ) -> null );

    lockManager = new GuidedDecisionTableLockManagerImpl();

    setLockManagerField( "lockService",
                         lockService );
    setLockManagerField( "lockInfo",
                         lockInfo );
    setLockManagerField( "changeTitleEvent",
                         changeTitleEvent );
    setLockManagerField( "user",
                         user );

    when( lockInfo.getFile() ).thenReturn( dtPath );
    when( user.getIdentifier() ).thenReturn( "user" );
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:20,代码来源:GuidedDecisionTableLockManagerImplTest.java

示例7: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() {
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(editorDefinition);

    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(ExpressionType.LITERAL_EXPRESSION).when(editorDefinition).getType();
    doReturn(Optional.of(expression)).when(editorDefinition).getModelClass();
    doReturn(viewport).when(editorTypesContainer).getViewport();
    doReturn(transform).when(viewport).getTransform();
    doReturn(editorTypesContainerLocation).when(editorTypesContainer).getAbsoluteLocation();

    GwtMockito.useProviderForType(Group.class, type -> editorTypesContainer);

    this.renderer = new MockUndefinedExpressionColumnRenderer(expressionEditorDefinitionsSupplier,
                                                              gridWidget);
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:18,代码来源:UndefinedExpressionColumnRendererTest.java

示例8: shouldUseFakeIfProvided

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Test
public void shouldUseFakeIfProvided() {
  GwtMockito.useProviderForType(
      TestRemoteService.class,
      new FakeProvider<TestRemoteServiceAsync>() {
        @Override
        public TestRemoteServiceAsync getFake(Class<?> type) {
          TestRemoteServiceAsync mock = mock(TestRemoteServiceAsync.class);
          doAnswer(returnSuccess("faked")).when(mock).doRpcWithoutArgs(anyAsyncCallback());
          return mock;
        }
      });
  MyWidget widget = new MyWidget();

  verify(widget.message).setText("faked");
}
 
开发者ID:google,项目名称:gwtmockito,代码行数:17,代码来源:GwtMockitoRpcWithoutGwtMockTest.java

示例9: gwtMockShouldTakePriorityOverFakes

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Test
public void gwtMockShouldTakePriorityOverFakes() {
  doAnswer(returnSuccess("mocked")).when(service).doRpcWithoutArgs(anyAsyncCallback());

  GwtMockito.useProviderForType(
      TestRemoteService.class,
      new FakeProvider<TestRemoteServiceAsync>() {
        @Override
        public TestRemoteServiceAsync getFake(Class<?> type) {
          TestRemoteServiceAsync mock = mock(TestRemoteServiceAsync.class);
          doAnswer(returnSuccess("faked")).when(mock).doRpcWithoutArgs(anyAsyncCallback());
          return mock;
        }
      });
  MyWidgetWithoutArgs widget = new MyWidgetWithoutArgs();

  verify(widget.message).setText("mocked");
}
 
开发者ID:google,项目名称:gwtmockito,代码行数:19,代码来源:GwtMockitoRpcTest.java

示例10: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
    mockTimer();

    GwtMockito.useProviderForType(WorkbenchResources.class,
                                  new FakeProvider<WorkbenchResources>() {

                                      @Override
                                      public WorkbenchResources getFake(Class<?> type) {
                                          return null;
                                      }
                                  });

    final Runnable reloadRunnable = new Runnable() {

        @Override
        public void run() {
            reloads++;
        }
    };

    final TitleProvider titleProvider = new TitleProvider() {

        @Override
        public String getTitle() {
            return "";
        }
    };

    target = new LockTarget(path,
                            widget,
                            new DefaultPlaceRequest("mockPlace"),
                            titleProvider,
                            reloadRunnable);

    lockManager.init(target);

    when(user.getIdentifier()).thenReturn("mockedUser");
    when(lockDemandDetector.isLockRequired(any(Event.class))).thenReturn(true);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:41,代码来源:LockManagerTest.java

示例11: setUp

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    GwtMockito.initMocks(this);
    GwtMockito.useProviderForType(ViewEngine.WidgetBindingMap.class, new FakeProvider<Object>() {
        @Override
        public Object getFake(Class<?> type) {
            return new WidgetBindingMapForTest();
        }
    });
}
 
开发者ID:growbit,项目名称:turbogwt-databind,代码行数:12,代码来源:DatabindViewEngineTest.java

示例12: setup

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setup() {
    this.ruleNamesServiceCaller = new CallerMock<>(ruleNamesService);
    this.creator = spy(new ScenarioWidgetComponentCreator(ruleNamesServiceCaller));

    when(ruleNamesService.getRuleNames(any(Path.class),
                                       anyString())).thenReturn(ruleNames);
    doReturn(button).when(creator).newOkButton();
    doNothing().when(creator).showSelectRuleNameWarning();
    GwtMockito.useProviderForType(HorizontalPanel.class, fakeProvider -> horizontalPanel);
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:12,代码来源:ScenarioWidgetComponentCreatorTest.java

示例13: setUp

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    model = new RuleModel();
    GwtMockito.useProviderForType(RuleSelector.class, aClass -> ruleSelector);

    ruleModeller = new RuleModeller(model,
                                    Collections.emptyList(),
                                    oracle,
                                    widgetFactory,
                                    eventBus,
                                    false,
                                    false);
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:14,代码来源:RuleModellerTest.java

示例14: setUp

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    // listBox is used for verification fo added available fact types into UI
    GwtMockito.useProviderForType(ListBox.class, aClass -> listBox);

    // Mock partially the AsyncPackageDataModelOracle
    validatorInstance = new MockInstanceImpl<>();
    oracle = spy(new AsyncPackageDataModelOracleImpl(new CallerMock<>(incrementalDataModelService), validatorInstance));

    // Mock partially the AsyncPackageDataModelOracleFactory and ensure oracle will contain data form payload below
    doReturn(syncBeanDef).when(syncBeanManager).lookupBean(AsyncPackageDataModelOracle.class);
    doReturn(oracle).when(syncBeanDef).getInstance();
    doReturn(oracle).when(ruleModeller).getDataModelOracle();

    // Prepare base payload that simulates two Facts in the package, Person and Car
    dataModelPayload = new PackageDataModelOracleBaselinePayload();
    dataModelPayload.setModelFields(new HashMap<String, ModelField[]>() {{
        final String fqnPerson = REDHAT_PACKAGE + "." + FACT_TYPE_PERSON;
        final String fqnCar = REDHAT_PACKAGE + "." + FACT_TYPE_CAR;
        final String fqnNumber = Number.class.getName();
        put(fqnPerson, new ModelField[]{modelField(DataType.TYPE_THIS, fqnPerson)});
        put(fqnCar, new ModelField[]{modelField(DataType.TYPE_THIS, fqnCar)});
        put(fqnNumber, new ModelField[]{modelField(DataType.TYPE_THIS, fqnNumber)});
    }});

    // Prevent NPE in FromAccumulateCompositeFactPatternWidget constructor
    when(pattern.useFunctionOrCode()).thenReturn(FromAccumulateCompositeFactPattern.USE_FUNCTION);

    fromAccumulateWidget = new FromAccumulateCompositeFactPatternWidget(ruleModeller,
                                                                        eventBus,
                                                                        pattern);

    ruleModelWithImportedNumber = new RuleModel() {{
        setImports(new Imports() {{
            addImport(new Import(Number.class));
        }});
    }};
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:39,代码来源:FromAccumulateCompositeFactPatternWidgetTest.java

示例15: setUp

import com.google.gwtmockito.GwtMockito; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    GwtMockito.useProviderForType(Label.class, aClass -> noAvailablePatternsLabel);

    view.setup();
    view.setValidator(mock(Validator.class));
    ActionSetFieldsPageView.Presenter presenter = mock(ActionSetFieldsPageView.Presenter.class);
    when(presenter.getTableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    view.init(presenter);
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:11,代码来源:ActionSetFieldsPageViewImplTest.java


注:本文中的com.google.gwtmockito.GwtMockito.useProviderForType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。