本文整理汇总了Java中org.uberfire.mocks.MockInstanceImpl类的典型用法代码示例。如果您正苦于以下问题:Java MockInstanceImpl类的具体用法?Java MockInstanceImpl怎么用?Java MockInstanceImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockInstanceImpl类属于org.uberfire.mocks包,在下文中一共展示了MockInstanceImpl类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupGuvnorM2Repository
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Before
public void setupGuvnorM2Repository() {
ArtifactRepositoryPreference pref = mock(ArtifactRepositoryPreference.class);
when(pref.getGlobalM2RepoDir()).thenReturn("repositories/kie");
when(pref.isGlobalM2RepoDirEnabled()).thenReturn(true);
when(pref.isDistributionManagementM2RepoDirEnabled()).thenReturn(true);
when(pref.isWorkspaceM2RepoDirEnabled()).thenReturn(false);
WorkspaceNameResolver resolver = mock(WorkspaceNameResolver.class);
when(resolver.getWorkspaceName()).thenReturn("global");
ArtifactRepositoryProducer producer = new ArtifactRepositoryProducer(pref,
resolver);
producer.initialize();
Instance<ArtifactRepository> repositories = new MockInstanceImpl<>(producer.produceLocalRepository(),
producer.produceGlobalRepository(),
producer.produceDistributionManagementRepository());
ArtifactRepositoryService factory = new ArtifactRepositoryService(repositories);
repository = new GuvnorM2Repository(factory);
repository.init();
}
示例2: setUp
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的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();
}
示例3: setUp
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Before
public void setUp() {
artifactRepository1 = mock(ArtifactRepository.class);
artifactRepository2 = mock(ArtifactRepository.class);
artifactRepository3 = mock(ArtifactRepository.class);
artifactRepository4 = mock(ArtifactRepository.class);
artifactRepository5 = mock(ArtifactRepository.class);
when(artifactRepository1.isRepository()).thenReturn(true);
when(artifactRepository2.isRepository()).thenReturn(true);
when(artifactRepository3.isRepository()).thenReturn(true);
when(artifactRepository4.isRepository()).thenReturn(true);
when(artifactRepository5.isRepository()).thenReturn(false);
when(artifactRepository1.isPomRepository()).thenReturn(true);
when(artifactRepository2.isPomRepository()).thenReturn(true);
when(artifactRepository3.isPomRepository()).thenReturn(false);
when(artifactRepository4.isPomRepository()).thenReturn(false);
when(artifactRepository5.isPomRepository()).thenReturn(false);
MockInstanceImpl<ArtifactRepository> instance = new MockInstanceImpl<>(artifactRepository1,
artifactRepository2,
artifactRepository3,
artifactRepository4,
artifactRepository5);
this.artifactRepositoryService = new ArtifactRepositoryService(instance);
}
示例4: setUp
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的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));
}});
}};
}
示例5: addPropertyTypeBrowseColumn
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Test
public void addPropertyTypeBrowseColumn() {
FieldMetadataProvider fieldMetadataProvider = objectProperty -> {
if ("testField".equals(objectProperty.getName())) {
ImageWrapper imageWrapper = new ImageWrapper("testUri",
"testDescription");
FieldMetadata fieldMetadata = new FieldMetadata(imageWrapper);
return Optional.of(fieldMetadata);
}
return Optional.empty();
};
Instance<FieldMetadataProvider> fieldMetadataProviderInstance = new MockInstanceImpl<>(fieldMetadataProvider);
view = new DataObjectBrowserViewImpl(validationPopup,
fieldMetadataProviderInstance);
Column<ObjectProperty, List<ImageWrapper>> column = view.createPropertyTypeBrowseColumn();
ObjectProperty matchingObjectProperty = new ObjectPropertyImpl("testField",
"className",
false);
List<ImageWrapper> imageWrapperList = column.getValue(matchingObjectProperty);
assertEquals(1,
imageWrapperList.size());
ObjectProperty nonMatchingObjectProperty = new ObjectPropertyImpl("nonMatchingTestField",
"className",
false);
imageWrapperList = column.getValue(nonMatchingObjectProperty);
assertEquals(0,
imageWrapperList.size());
}
示例6: setup
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setup() {
final Instance<TextPropertyProvider> providers = new MockInstanceImpl<>(provider1,
provider2);
final ManagedInstance<TextPropertyProvider> managedProviders = mock(ManagedInstance.class);
when(managedProviders.iterator()).thenReturn(providers.iterator());
this.factory = new TextPropertyProviderFactoryImpl(managedProviders);
}
示例7: setup
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Before
public void setup() throws Exception {
log.info("Deleting existing Repositories instance..");
ArtifactRepositoryPreference pref = mock(ArtifactRepositoryPreference.class);
when(pref.getGlobalM2RepoDir()).thenReturn("repositories/kie");
when(pref.isGlobalM2RepoDirEnabled()).thenReturn(true);
when(pref.isDistributionManagementM2RepoDirEnabled()).thenReturn(true);
when(pref.isWorkspaceM2RepoDirEnabled()).thenReturn(false);
WorkspaceNameResolver resolver = mock(WorkspaceNameResolver.class);
when(resolver.getWorkspaceName()).thenReturn("global");
ArtifactRepositoryProducer producer = new ArtifactRepositoryProducer(pref,
resolver);
producer.initialize();
Instance<ArtifactRepository> repositories = new MockInstanceImpl<>(producer.produceLocalRepository(),
producer.produceGlobalRepository(),
producer.produceDistributionManagementRepository());
ArtifactRepositoryService factory = new ArtifactRepositoryService(repositories);
repo = new GuvnorM2Repository(factory);
repo.init();
Aether aether = mock(Aether.class);
when(aether.getSession()).thenReturn(repositorySystemSession);
when(aether.getSystem()).thenReturn(repositorySystem);
mockStatic(Aether.class);
when(Aether.getAether()).thenReturn(aether);
try {
when(repositorySystem.install(any(RepositorySystemSession.class),
any(InstallRequest.class)))
.thenAnswer(new Answer<InstallResult>() {
@Override
public InstallResult answer(InvocationOnMock invocation) throws Throwable {
return new InstallResult((InstallRequest) invocation.getArguments()[1]);
}
});
} catch (InstallationException e) {
e.printStackTrace();
}
}
示例8: setup
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Before
public void setup() throws Exception {
log.info("Deleting existing Repositories instance..");
File dir = new File("repositories");
log.info("DELETING test repo: " + dir.getAbsolutePath());
deleteDir(dir);
log.info("TEST repo was deleted.");
ArtifactRepositoryPreference pref = mock(ArtifactRepositoryPreference.class);
when(pref.getGlobalM2RepoDir()).thenReturn("repositories/kie");
when(pref.isGlobalM2RepoDirEnabled()).thenReturn(true);
when(pref.isDistributionManagementM2RepoDirEnabled()).thenReturn(true);
when(pref.isWorkspaceM2RepoDirEnabled()).thenReturn(false);
WorkspaceNameResolver resolver = mock(WorkspaceNameResolver.class);
when(resolver.getWorkspaceName()).thenReturn("global");
ArtifactRepositoryProducer producer = new ArtifactRepositoryProducer(pref,
resolver);
producer.initialize();
Instance<ArtifactRepository> repositories = new MockInstanceImpl<>(producer.produceLocalRepository(),
producer.produceGlobalRepository(),
producer.produceDistributionManagementRepository());
ArtifactRepositoryService factory = new ArtifactRepositoryService(repositories);
repo = new GuvnorM2Repository(factory);
repo.init();
//Create a shell M2RepoService and set the M2Repository
service = new M2RepoServiceImpl(this.repo);
java.lang.reflect.Field repositoryField = M2RepoServiceImpl.class.getDeclaredField("repository");
repositoryField.setAccessible(true);
repositoryField.set(service,
repo);
//Make private method accessible for testing
helper = new HttpPostHelper();
helperMethod = HttpPostHelper.class.getDeclaredMethod("upload",
FormData.class);
helperMethod.setAccessible(true);
//Set the repository service created above in the HttpPostHelper
java.lang.reflect.Field m2RepoServiceField = HttpPostHelper.class.getDeclaredField("m2RepoService");
m2RepoServiceField.setAccessible(true);
m2RepoServiceField.set(helper,
service);
}
示例9: setUp
import org.uberfire.mocks.MockInstanceImpl; //导入依赖的package包/类
@Before
public void setUp() {
this.view = new DataObjectBrowserViewImpl(
validationPopup,
new MockInstanceImpl<>());
}