本文整理汇总了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()));
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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" );
}
示例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);
}
示例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");
}
示例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");
}
示例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);
}
示例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();
}
});
}
示例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);
}
示例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);
}
示例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));
}});
}};
}
示例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);
}