本文整理了Java中org.mockito.Mockito.anyCollection()
方法的一些代码示例,展示了Mockito.anyCollection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.anyCollection()
方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:anyCollection
暂无
代码示例来源:origin: spring-projects/spring-security
@Test
public void roleHierarchyIsUsedWhenSet() throws Exception {
RoleHierarchy rh = mock(RoleHierarchy.class);
List rhAuthorities = AuthorityUtils.createAuthorityList("D");
when(rh.getReachableGrantedAuthorities(anyCollection()))
.thenReturn(rhAuthorities);
SidRetrievalStrategy strat = new SidRetrievalStrategyImpl(rh);
List<Sid> sids = strat.getSids(authentication);
assertThat(sids).hasSize(2);
assertThat(sids.get(0)).isNotNull();
assertThat(sids.get(0) instanceof PrincipalSid).isTrue();
assertThat(((GrantedAuthoritySid) sids.get(1)).getGrantedAuthority()).isEqualTo("D");
}
}
代码示例来源:origin: spring-projects/spring-security
@Test // http@access-decision-manager-ref
public void configureWhenAccessDecisionManagerSetThenVerifyUse() throws Exception {
AccessDecisionManagerRefConfig.ACCESS_DECISION_MANAGER = mock(AccessDecisionManager.class);
when(AccessDecisionManagerRefConfig.ACCESS_DECISION_MANAGER.supports(FilterInvocation.class)).thenReturn(true);
when(AccessDecisionManagerRefConfig.ACCESS_DECISION_MANAGER.supports(any(ConfigAttribute.class))).thenReturn(true);
this.spring.register(AccessDecisionManagerRefConfig.class).autowire();
this.mockMvc.perform(get("/"));
verify(AccessDecisionManagerRefConfig.ACCESS_DECISION_MANAGER, times(1)).decide(any(Authentication.class), any(), anyCollection());
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void getAllNullable() {
// ask for 3 keys but only 2 are available in backed (third key is missing)
List<String> keys = Arrays.asList("one", "two", "three");
Map<String, String> values = new HashMap<>();
values.put("one", "un");
values.put("two", "deux");
when(loader.loadAll(keys)).thenReturn(values);
assertThat(cache.getAll(keys))
.hasSize(3)
.containsEntry("one", "un")
.containsEntry("two", "deux")
.containsEntry("three", null);
// ask for 4 keys. Only a single one was never loaded. The 3 others are kept from cache
when(loader.loadAll(Arrays.asList("four"))).thenReturn(ImmutableMap.of("four", "quatre"));
assertThat(cache.getAll(Arrays.asList("one", "two", "three", "four")))
.hasSize(4)
.containsEntry("one", "un")
.containsEntry("two", "deux")
.containsEntry("three", null)
.containsEntry("four", "quatre");
verify(loader, times(2)).loadAll(anyCollection());
}
}
代码示例来源:origin: westnordost/StreetComplete
@Test public void putAllElements()
{
ArrayList<Element> elements = new ArrayList<>();
elements.add(createANode());
elements.add(createAWay());
elements.add(createARelation());
dao.putAll(elements);
verify(nodeDao).putAll(anyCollection());
verify(wayDao).putAll(anyCollection());
verify(relationDao).putAll(anyCollection());
}
代码示例来源:origin: westnordost/StreetComplete
@Test public void putAllRelations()
{
ArrayList<Element> elements = new ArrayList<>();
elements.add(createARelation());
dao.putAll(elements);
verify(relationDao).putAll(anyCollection());
}
代码示例来源:origin: westnordost/StreetComplete
@Test public void putAllNodes()
{
ArrayList<Element> elements = new ArrayList<>();
elements.add(createANode());
dao.putAll(elements);
verify(nodeDao).putAll(anyCollection());
}
代码示例来源:origin: westnordost/StreetComplete
@Test public void putAllWays()
{
ArrayList<Element> elements = new ArrayList<>();
elements.add(createAWay());
dao.putAll(elements);
verify(wayDao).putAll(anyCollection());
}
代码示例来源:origin: org.guvnor/guvnor-structure-client
private void getRepositories() {
context.getRepositories(callback);
verify(callback).callback(anyCollection());
}
}
代码示例来源:origin: org.dashbuilder/dashbuilder-displayer-client
@Test
public void testEmpty() {
reset(htmlValidator);
presenter.init(SourceCodeType.HTML, null, new HashMap<>(), onChange);
verify(htmlValidator, never()).validate(any());
reset(htmlValidator);
presenter.init(SourceCodeType.HTML, "", new HashMap<>(), onChange);
verify(htmlValidator, never()).validate(any());
reset(jsValidator);
presenter.init(SourceCodeType.JAVASCRIPT, null, new HashMap<>(), onChange);
verify(jsValidator, never()).validate(any(), anyCollection());
reset(jsValidator);
presenter.init(SourceCodeType.JAVASCRIPT, "", new HashMap<>(), onChange);
verify(jsValidator, never()).validate(any(), anyCollection());
}
代码示例来源:origin: org.uberfire/uberfire-preferences-client
@Test
public void saveCollectionWithErrorTest() {
doThrow(new RuntimeException("error")).when(store).save(anyCollection());
Collection<BasePreferencePortable<? extends BasePreference<?>>> preferences = new ArrayList<>();
preferences.add(new MyPreferencePortable());
preferenceBeanStoreImpl.save(preferences,
successCommand,
errorParameterizedCommand);
verify(store).save(preferences);
verify(errorParameterizedCommand).execute(any(Throwable.class));
}
代码示例来源:origin: kiegroup/appformer
@Test
public void testEmpty() {
reset(htmlValidator);
presenter.init(SourceCodeType.HTML, null, new HashMap<>(), onChange);
verify(htmlValidator, never()).validate(any());
reset(htmlValidator);
presenter.init(SourceCodeType.HTML, "", new HashMap<>(), onChange);
verify(htmlValidator, never()).validate(any());
reset(jsValidator);
presenter.init(SourceCodeType.JAVASCRIPT, null, new HashMap<>(), onChange);
verify(jsValidator, never()).validate(any(), anyCollection());
reset(jsValidator);
presenter.init(SourceCodeType.JAVASCRIPT, "", new HashMap<>(), onChange);
verify(jsValidator, never()).validate(any(), anyCollection());
}
代码示例来源:origin: kiegroup/appformer
@Test
public void saveCollectionWithErrorTest() {
doThrow(new RuntimeException("error")).when(store).save(anyCollection());
Collection<BasePreferencePortable<? extends BasePreference<?>>> preferences = new ArrayList<>();
preferences.add(new MyPreferencePortable());
preferenceBeanStoreImpl.save(preferences,
successCommand,
errorParameterizedCommand);
verify(store).save(preferences);
verify(errorParameterizedCommand).execute(any(Throwable.class));
}
代码示例来源:origin: org.uberfire/uberfire-runtime-plugins-client
@Test
public void loadContentTest() {
final PluginContent pluginContent = mock(PluginContent.class);
when(pluginServices.getPluginContent(Matchers.<Path>any())).thenReturn(pluginContent);
assertNull(editor.getOriginalHash());
editor.loadContent();
verify(pluginServices).getPluginContent(Matchers.<Path>any());
verify(baseEditorView).setFramework(anyCollection());
verify(baseEditorView).setupContent(eq(pluginContent),
Matchers.<ParameterizedCommand<Media>>any());
verify(baseEditorView).hideBusyIndicator();
assertNotNull(editor.getOriginalHash());
}
代码示例来源:origin: kiegroup/appformer
@Test
public void loadContentTest() {
final PluginContent pluginContent = mock(PluginContent.class);
when(pluginServices.getPluginContent(Matchers.<Path>any())).thenReturn(pluginContent);
assertNull(editor.getOriginalHash());
editor.loadContent();
verify(pluginServices).getPluginContent(Matchers.<Path>any());
verify(baseEditorView).setFramework(anyCollection());
verify(baseEditorView).setupContent(eq(pluginContent),
Matchers.<ParameterizedCommand<Media>>any());
verify(baseEditorView).hideBusyIndicator();
assertNotNull(editor.getOriginalHash());
}
代码示例来源:origin: trellis-ldp/trellis
@BeforeEach
public void setUp() {
initMocks(this);
doCallRealMethod().when(mockResource).getMembershipResource();
doCallRealMethod().when(mockResource).getMemberRelation();
doCallRealMethod().when(mockResource).getMemberOfRelation();
doCallRealMethod().when(mockResource).getInsertedContentRelation();
doCallRealMethod().when(mockResource).stream(any(IRI.class));
doCallRealMethod().when(mockResource).stream(anyCollection());
doCallRealMethod().when(mockResource).getBinaryMetadata();
doCallRealMethod().when(mockResource).hasAcl();
doCallRealMethod().when(mockResource).getExtraLinkRelations();
when(mockResource.stream()).thenAnswer((x) -> empty());
}
代码示例来源:origin: org.guvnor/guvnor-structure-client
@Test
public void testReLoadRemembersBranches() throws Exception {
context.changeBranch("your-repo",
"release");
context.getRepositories(callback);
assertEquals(2,
result.size());
assertEquals("master",
context.getCurrentBranch("my-repo"));
assertEquals("release",
context.getCurrentBranch("your-repo"));
verify(callback,
times(2)).callback(anyCollection());
}
代码示例来源:origin: org.guvnor/guvnor-structure-client
@Test
public void testReLoadPicksUpNewRepositories() throws Exception {
repositories.add(makeRepository("my-new-repo",
"master"));
context.getRepositories(callback);
assertEquals(3,
result.size());
assertEquals("master",
context.getCurrentBranch("my-repo"));
assertEquals("master",
context.getCurrentBranch("your-repo"));
assertEquals("master",
context.getCurrentBranch("my-new-repo"));
verify(callback,
times(2)).callback(anyCollection());
}
代码示例来源:origin: org.drools/drools-verifier-core
@Test
public void testListen() throws
Exception {
conditions.add(new FieldCondition(new Field(mock(ObjectField.class),
"Person",
"String",
"name",
configuration),
new Column(1,
configuration),
"==",
new Values<>(10),
configuration));
verify(allListener).onAllChanged(anyCollection());
}
代码示例来源:origin: org.drools/drools-wb-verifier-api
@Test
public void testListen() throws
Exception {
conditions.add( new FieldCondition( new Field( mock( ObjectField.class ),
"Person",
"String",
"name",
configuration ),
new Column( 1,
configuration ),
"==",
new Values<>( 10 ),
configuration ) );
verify( allListener ).onAllChanged( anyCollection() );
}
代码示例来源:origin: org.drools/drools-wb-verifier-api
@Test
public void testUpdate() throws
Exception {
final Condition condition = new FieldCondition( new Field( mock( ObjectField.class ),
"Person",
"String",
"name",
configuration ),
new Column( 1,
configuration ),
"==",
new Values<>( 10 ),
configuration );
conditions.add( condition );
reset( allListener );
condition.setValue( new Values<>( 20 ) );
verify( allListener ).onAllChanged( anyCollection() );
}
内容来源于网络,如有侵权,请联系作者删除!