org.mockito.Mockito.anyVararg()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中org.mockito.Mockito.anyVararg()方法的一些代码示例,展示了Mockito.anyVararg()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.anyVararg()方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:anyVararg

Mockito.anyVararg介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

private static void verifyLogging( Log log, VerificationMode mode )
{
  verify( log, mode ).info( anyString(), Mockito.<Object[]>anyVararg() );
}

代码示例来源:origin: apache/flink

return new String[] {(String) invocationOnMock.getArguments()[1]};
}).when(yarnConf).getStrings(anyString(), Mockito.<String> anyVararg());

代码示例来源:origin: facebook/jcommon

case "error":
 if (hasThrowableParam(method)) {
  verify(mockLogger, times(1)).error(any(Throwable.class), anyString(), anyVararg());
 } else {
  verify(mockLogger, times(1)).error(anyString(), Matchers.<Object[]>anyVararg());
case "warn":
 if (hasThrowableParam(method)) {
  verify(mockLogger, times(1)).warn(any(Throwable.class), anyString(), anyVararg());
 } else {
  verify(mockLogger, times(1)).warn(anyString(), Matchers.<Object[]>anyVararg());
case "info":
 if (hasThrowableParam(method)) {
  verify(mockLogger, times(1)).info(any(Throwable.class), anyString(), anyVararg());
 } else {
  verify(mockLogger, times(1)).info(anyString(), Matchers.<Object[]>anyVararg());
case "debug":
 if (hasThrowableParam(method)) {
  verify(mockLogger, times(1)).debug(any(Throwable.class), anyString(), anyVararg());
 } else {
  verify(mockLogger, times(1)).debug(anyString(), Matchers.<Object[]>anyVararg());
case "trace":
 if (hasThrowableParam(method)) {
  verify(mockLogger, times(1)).trace(any(Throwable.class), anyString(), anyVararg());
 } else {
  verify(mockLogger, times(1)).trace(anyString(), anyVararg());

代码示例来源:origin: mattia-battiston/clean-architecture-example

private void givenThereIsADevice(String exchangeCode, String exchangeName, String exchangePostcode, String hostname, String serialNumber, DeviceType type, int availablePorts) {
  Map<String, Object> details = detailsForDevice(exchangeCode, exchangeName, exchangePostcode, hostname, serialNumber, type, availablePorts);
  when(jdbcTemplate.queryForMap(anyString(), anyVararg())).thenReturn(details);
}

代码示例来源:origin: mattia-battiston/clean-architecture-example

private void givenThereIsntADevice() {
  when(jdbcTemplate.queryForMap(anyString(), anyVararg())).thenThrow(new IncorrectResultSizeDataAccessException(1));
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Before
public void setUp() throws Exception {
  appContext = mock(AppContext.class);
  subAppContext = mock(SubAppContext.class);
  componentProvider = mock(ComponentProvider.class);
  doReturn(mock(DummyRule.class)).when(componentProvider).newInstance(any(Class.class), anyVararg());
  view = mock(ContentSubAppView.class);
  workbench = mock(BrowserPresenter.class);
  ActionbarPresenter actionbarPresenter = mock(ActionbarPresenter.class);
  when(workbench.getActionbarPresenter()).thenReturn(actionbarPresenter);
  subAppEventBus = mock(EventBus.class);
  this.subApp = new DummyContentSubApp(null, subAppContext, view, workbench, subAppEventBus);
}

代码示例来源:origin: caelum/vraptor4

@Test
public void shouldSetMovedPermanentlyStatusOfLogic() throws Exception {
  when(config.getApplicationPath()).thenReturn("http://myapp.com");
  Method method = Resource.class.getDeclaredMethod("method");
  when(router.urlFor(eq(Resource.class), eq(method), Mockito.anyVararg())).thenReturn("/resource/method");
  status.movedPermanentlyTo(Resource.class).method();
  verify(response).setStatus(301);
  verify(response).addHeader("Location", "http://myapp.com/resource/method");
}

代码示例来源:origin: it.tidalwave.northernwind.rca/it-tidalwave-northernwind-rca-ui-structure-editor

/*******************************************************************************************************************
 *
 ******************************************************************************************************************/
@BeforeMethod
public void setup()
 {
  ContextManager.Locator.set(null);
  context = new ClassPathXmlApplicationContext("DefaultStructureEditorPresentationControlTestBeans.xml");
  underTest = context.getBean(DefaultStructureEditorPresentationControl.class);
  presentation = context.getBean(StructureEditorPresentation.class);
  siteNode = mock(SiteNode.class);
  properties = mock(ResourceProperties.class);
  presentable = mock(Presentable.class);
  pm = mock(PresentationModel.class);
  when(siteNode.getProperties()).thenReturn(properties);
  when(presentable.createPresentationModel(anyVararg())).thenReturn(pm);
  when(properties.as(eq(Presentable))).thenReturn(presentable);
 }

代码示例来源:origin: org.uberfire/uberfire-preferences-ui-client

@Before
public void setup() {
  final TranslationService translationService = mock(TranslationService.class);
  doAnswer(invocationOnMock -> invocationOnMock.getArguments()[0])
      .when(translationService).format(any(), anyVararg());
  preference = spy(new PortablePreferenceMockPortableGeneratedImpl());
  formView = mock(DefaultPreferenceForm.View.class);
  formPresenter = new DefaultPreferenceForm(formView,
                       translationService);
  Map<String, String> params = new HashMap<>();
  params.put("id",
        "preference-id");
  formPresenter.onStartup(new DefaultPlaceRequest("preferenceForm",
                          params));
}

代码示例来源:origin: kiegroup/appformer

@Before
public void setup() {
  final TranslationService translationService = mock(TranslationService.class);
  doAnswer(invocationOnMock -> invocationOnMock.getArguments()[0])
      .when(translationService).format(any(), anyVararg());
  preference = spy(new PortablePreferenceMockPortableGeneratedImpl());
  formView = mock(DefaultPreferenceForm.View.class);
  formPresenter = new DefaultPreferenceForm(formView,
                       translationService);
  Map<String, String> params = new HashMap<>();
  params.put("id",
        "preference-id");
  formPresenter.onStartup(new DefaultPlaceRequest("preferenceForm",
                          params));
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

@Test
  public void testUseIOServiceToDeleteSubModule() {
    when(path.getFileName()).thenReturn("pom.xml");
    when(path.toURI()).thenReturn("file://space/project1/subproject/pom.xml");
    when(ioService.exists(any())).thenReturn(true);
    when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module);
    when(pomService.load(any())).thenReturn(mock(POM.class));
    Repository repo = mock(Repository.class);
    when(repoService.getRepository(path)).thenReturn(repo);
    String alias = "repo-alias";
    when(repo.getAlias()).thenReturn(alias);
    Space space = new Space("space");
    when(repo.getSpace()).thenReturn(space);

    abstractProjectService.delete(path, "");

    verify(repoService, times(0)).removeRepository(any(), any());
    verify(ioService).delete(eq(Paths.get("file://space/project1/subproject")), anyVararg());
  }
}

代码示例来源:origin: kiegroup/appformer

@Test
  public void testUseIOServiceToDeleteSubModule() {
    when(path.getFileName()).thenReturn("pom.xml");
    when(path.toURI()).thenReturn("file://space/project1/subproject/pom.xml");
    when(ioService.exists(any())).thenReturn(true);
    when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module);
    when(pomService.load(any())).thenReturn(mock(POM.class));
    Repository repo = mock(Repository.class);
    when(repoService.getRepository(path)).thenReturn(repo);
    String alias = "repo-alias";
    when(repo.getAlias()).thenReturn(alias);
    Space space = new Space("space");
    when(repo.getSpace()).thenReturn(space);

    abstractProjectService.delete(path, "");

    verify(repoService, times(0)).removeRepository(any(), any());
    verify(ioService).delete(eq(Paths.get("file://space/project1/subproject")), anyVararg());
  }
}

代码示例来源:origin: taskadapter/trello-java-wrapper

@Test
public void testGetActionBoard() {
  //Given
  Board mockBoard = new Board();
  mockBoard.setId("idBoard");
  when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockBoard);
  //When
  Board actionBoard = trello.getActionBoard("idBoard");
  //Then
  assertThat(actionBoard).isNotNull();
  assertThat(actionBoard.getId()).isEqualTo("idBoard");
  verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}/board?key={applicationKey}&token={userToken}"),
      eq(Board.class), eq("idBoard"), eq(""), eq(""));
}

代码示例来源:origin: taskadapter/trello-java-wrapper

@Test
public void testGetActionMemberCreator() {
  //Given
  Member mockMember = new Member();
  mockMember.setId("idMember");
  when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockMember);
  //When
  Member actionMember = trello.getActionMemberCreator("idMember");
  //Then
  assertThat(actionMember).isNotNull();
  assertThat(actionMember.getId()).isEqualTo("idMember");
  verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}/memberCreator?key={applicationKey}&token={userToken}"),
      eq(Member.class), eq("idMember"), eq(""), eq(""));
}

代码示例来源:origin: taskadapter/trello-java-wrapper

@Test
public void testGetActionList() {
  //Given
  TList mockList = new TList();
  mockList.setId("idList");
  when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockList);
  //When
  TList actionList = trello.getActionList("idList");
  //Then
  assertThat(actionList).isNotNull();
  assertThat(actionList.getId()).isEqualTo("idList");
  verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}/list?key={applicationKey}&token={userToken}"),
      eq(TList.class), eq("idList"), eq(""), eq(""));
}

代码示例来源:origin: taskadapter/trello-java-wrapper

@Test
public void testGetActionMember() {
  //Given
  Member mockMember = new Member();
  mockMember.setId("idMember");
  when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockMember);
  //When
  Member actionMember = trello.getActionMember("idMember");
  //Then
  assertThat(actionMember).isNotNull();
  assertThat(actionMember.getId()).isEqualTo("idMember");
  verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}/member?key={applicationKey}&token={userToken}"),
      eq(Member.class), eq("idMember"), eq(""), eq(""));
}

代码示例来源:origin: taskadapter/trello-java-wrapper

@Test
public void testGetActionCard() {
  //Given
  Card mockCard = new Card();
  mockCard.setId("idCard");
  when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockCard);
  //When
  Card actionCard = trello.getActionCard("idCard");
  //Then
  assertThat(actionCard).isNotNull();
  assertThat(actionCard.getId()).isEqualTo("idCard");
  verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}/card?key={applicationKey}&token={userToken}"),
      eq(Card.class), eq("idCard"), eq(""), eq(""));
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void moveNodeIntoNode() throws Exception {
  //GIVEN
  definition.setMoveLocation(MoveLocation.INSIDE);
  when(provider.newInstance(any(Class.class), anyVararg())).thenReturn(action);
  //WHEN
  executor.execute(MOVE_ACTION_NAME);
  //THEN
  assertThat(node3.getJcrItem(), hasNode(NODE_NAME_1));
  assertThat(node3.getJcrItem(), hasNode(NODE_NAME_2));
  verify(adminCentralEventBusMock, times(1)).fireEvent(any(ContentChangedEvent.class));
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void movePropertyIntoNode() throws Exception {
  //GIVEN
  action = new MoveNodeAction(definition, Arrays.asList(property1), node1, adminCentralEventBusMock, mock(UiContext.class), callback, new TreeViewDropHandler(null, null));
  definition.setMoveLocation(MoveLocation.INSIDE);
  when(provider.newInstance(any(Class.class), anyVararg())).thenReturn(action);
  //WHEN
  executor.execute(MOVE_ACTION_NAME);
  //THEN
  assertThat(node1.getJcrItem(), hasProperty(PROPERTY_NAME_1));
  assertThat(node2.getJcrItem(), not(hasProperty(PROPERTY_NAME_1)));
  verify(adminCentralEventBusMock, times(1)).fireEvent(any(ContentChangedEvent.class));
}

代码示例来源:origin: taskadapter/trello-java-wrapper

@Test
public void testGetActionById() {
  //Given
  Action mockAction = new Action();
  mockAction.setId("idAction");
  mockAction.setType("createCard");
  when(httpClient.get(anyString(), any(Class.class), (String[]) anyVararg())).thenReturn(mockAction);
  //When
  Action action = trello.getAction("idAction");
  //Then
  assertThat(action).isNotNull();
  assertThat(action.getId()).isEqualTo("idAction");
  assertThat(action.getType()).isEqualTo("createCard");
  verify(httpClient).get(eq("https://api.trello.com/1/actions/{actionId}?key={applicationKey}&token={userToken}"),
      eq(Action.class), eq("idAction"), eq(""), eq(""));
  verifyNoMoreInteractions(httpClient);
}

相关文章