How to use anyList method of org.mockito.ArgumentMatchers class

Best Mockito code snippet using org.mockito.ArgumentMatchers.anyList

Source:CardControllerTest.java Github

copy

Full Screen

...102 eq(userId));103 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),104 anyInt(),105 any(CardLabelValue.LabelValue.class),106 ArgumentMatchers.<Integer>anyList(),107 eq(user));108 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),109 ArgumentMatchers.<Integer>anyList(),110 any(CardLabelValue.LabelValue.class),111 eq(user));112 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),113 ArgumentMatchers.<Integer>anyList(),114 any(CardLabelValue.LabelValue.class),115 eq(user));116 verify(bulkOperationService, never()).assign(eq(projectShortName),117 ArgumentMatchers.<Integer>anyList(),118 any(CardLabelValue.LabelValue.class),119 eq(user));120 verify(cardDataService, never()).assignFileToCard(anyString(),121 anyString(),122 anyInt(),123 eq(user),124 any(Date.class));125 }126 @Test127 public void createWithDescription() {128 CardData cardData = new CardData();129 cardData.setName("name");130 cardData.setDescription("description");131 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);132 when(cardDataService.updateDescription(anyInt(), anyString(), any(Date.class), anyInt())).thenReturn(1);133 cardController.create(columnId, cardData, user);134 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));135 verify(cardDataService).updateDescription(eq(cardId), eq("description"), any(Date.class), eq(userId));136 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),137 card, user);138 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),139 anyInt(),140 any(CardLabelValue.LabelValue.class),141 ArgumentMatchers.<Integer>anyList(),142 eq(user));143 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),144 ArgumentMatchers.<Integer>anyList(),145 any(CardLabelValue.LabelValue.class),146 eq(user));147 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),148 ArgumentMatchers.<Integer>anyList(),149 any(CardLabelValue.LabelValue.class),150 eq(user));151 verify(bulkOperationService, never()).assign(eq(projectShortName),152 ArgumentMatchers.<Integer>anyList(),153 any(CardLabelValue.LabelValue.class),154 eq(user));155 verify(cardDataService, never()).assignFileToCard(anyString(),156 anyString(),157 anyInt(),158 eq(user),159 any(Date.class));160 }161 @Test162 public void createWithLabels() {163 CardData cardData = new CardData();164 cardData.setName("name");165 List<BulkOperation> labels = new ArrayList<>();166 BulkOperation op1 = new BulkOperation(1, new CardLabelValue.LabelValue("test"), Collections.<Integer>emptyList());167 BulkOperation op2 = new BulkOperation(2, new CardLabelValue.LabelValue("test2"), Collections.<Integer>emptyList());168 labels.add(op1);169 labels.add(op2);170 cardData.setLabels(labels);171 Map<Permission, Permission> permissions = new HashMap<>();172 permissions.put(Permission.MANAGE_LABEL_VALUE, Permission.MANAGE_LABEL_VALUE);173 when(user.getBasePermissions()).thenReturn(permissions);174 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);175 when(bulkOperationService.addUserLabel(eq(projectShortName),176 any(Integer.class),177 any(CardLabelValue.LabelValue.class),178 eq(cardIds),179 eq(user))).thenReturn(cardIds);180 cardController.create(columnId, cardData, user);181 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));182 verify(bulkOperationService).addUserLabel(eq(projectShortName),183 eq(1),184 any(CardLabelValue.LabelValue.class),185 eq(cardIds),186 eq(user));187 verify(bulkOperationService).addUserLabel(eq(projectShortName),188 eq(2),189 any(CardLabelValue.LabelValue.class),190 eq(cardIds),191 eq(user));192 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),193 card, user);194 verify(cardDataService, never()).updateDescription(eq(cardId),195 anyString(),196 any(Date.class),197 eq(userId));198 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),199 ArgumentMatchers.<Integer>anyList(),200 any(CardLabelValue.LabelValue.class),201 eq(user));202 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),203 ArgumentMatchers.<Integer>anyList(),204 any(CardLabelValue.LabelValue.class),205 eq(user));206 verify(bulkOperationService, never()).assign(eq(projectShortName),207 ArgumentMatchers.<Integer>anyList(),208 any(CardLabelValue.LabelValue.class),209 eq(user));210 verify(cardDataService, never()).assignFileToCard(anyString(),211 anyString(),212 anyInt(),213 eq(user),214 any(Date.class));215 }216 @Test217 public void createWithDueDate() {218 CardData cardData = new CardData();219 cardData.setName("name");220 BulkOperation dueDate = new BulkOperation(1, new CardLabelValue.LabelValue(new Date()), Collections.<Integer>emptyList());221 cardData.setDueDate(dueDate);222 ImmutablePair<List<Integer>, List<Integer>> result = new ImmutablePair<>(cardIds, cardIds);223 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);224 when(bulkOperationService.setDueDate(eq(projectShortName),225 eq(cardIds),226 any(CardLabelValue.LabelValue.class),227 eq(user))).thenReturn(result);228 cardController.create(columnId, cardData, user);229 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));230 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),231 card, user);232 verify(bulkOperationService).setDueDate(eq(projectShortName),233 eq(cardIds),234 any(CardLabelValue.LabelValue.class),235 eq(user));236 verify(cardDataService, never()).updateDescription(eq(cardId),237 anyString(),238 any(Date.class),239 eq(userId));240 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),241 anyInt(),242 any(CardLabelValue.LabelValue.class),243 ArgumentMatchers.<Integer>anyList(),244 eq(user));245 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),246 ArgumentMatchers.<Integer>anyList(),247 any(CardLabelValue.LabelValue.class),248 eq(user));249 verify(bulkOperationService, never()).assign(eq(projectShortName),250 ArgumentMatchers.<Integer>anyList(),251 any(CardLabelValue.LabelValue.class),252 eq(user));253 verify(cardDataService, never()).assignFileToCard(anyString(),254 anyString(),255 anyInt(),256 eq(user),257 any(Date.class));258 }259 @Test260 public void createWithMilestone() {261 CardData cardData = new CardData();262 cardData.setName("name");263 BulkOperation milestone = new BulkOperation(1, new CardLabelValue.LabelValue(1), Collections.<Integer>emptyList());264 cardData.setMilestone(milestone);265 ImmutablePair<List<Integer>, List<Integer>> result = new ImmutablePair<>(cardIds, cardIds);266 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);267 when(bulkOperationService.setMilestone(eq(projectShortName),268 eq(cardIds),269 any(CardLabelValue.LabelValue.class),270 eq(user))).thenReturn(result);271 cardController.create(columnId, cardData, user);272 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));273 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),274 card, user);275 verify(bulkOperationService).setMilestone(eq(projectShortName),276 eq(cardIds),277 any(CardLabelValue.LabelValue.class),278 eq(user));279 verify(cardDataService, never()).updateDescription(eq(cardId),280 anyString(),281 any(Date.class),282 eq(userId));283 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),284 anyInt(),285 any(CardLabelValue.LabelValue.class),286 ArgumentMatchers.<Integer>anyList(),287 eq(user));288 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),289 ArgumentMatchers.<Integer>anyList(),290 any(CardLabelValue.LabelValue.class),291 eq(user));292 verify(bulkOperationService, never()).assign(eq(projectShortName),293 ArgumentMatchers.<Integer>anyList(),294 any(CardLabelValue.LabelValue.class),295 eq(user));296 verify(cardDataService, never()).assignFileToCard(anyString(),297 anyString(),298 anyInt(),299 eq(user),300 any(Date.class));301 }302 @Test303 public void createWithAssignedUsers() {304 CardData cardData = new CardData();305 cardData.setName("name");306 List<BulkOperation> users = new ArrayList<>();307 BulkOperation op1 = new BulkOperation(1, new CardLabelValue.LabelValue(1), Collections.<Integer>emptyList());308 BulkOperation op2 = new BulkOperation(1, new CardLabelValue.LabelValue(2), Collections.<Integer>emptyList());309 users.add(op1);310 users.add(op2);311 cardData.setAssignedUsers(users);312 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);313 when(bulkOperationService.assign(eq(projectShortName),314 eq(cardIds),315 any(CardLabelValue.LabelValue.class),316 eq(user))).thenReturn(cardIds);317 cardController.create(columnId, cardData, user);318 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));319 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),320 card, user);321 verify(bulkOperationService, times(2)).assign(eq(projectShortName),322 eq(cardIds),323 any(CardLabelValue.LabelValue.class),324 eq(user));325 verify(cardDataService, never()).updateDescription(eq(cardId),326 anyString(),327 any(Date.class),328 eq(userId));329 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),330 anyInt(),331 any(CardLabelValue.LabelValue.class),332 ArgumentMatchers.<Integer>anyList(),333 eq(user));334 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),335 ArgumentMatchers.<Integer>anyList(),336 any(CardLabelValue.LabelValue.class),337 eq(user));338 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),339 ArgumentMatchers.<Integer>anyList(),340 any(CardLabelValue.LabelValue.class),341 eq(user));342 verify(cardDataService, never()).assignFileToCard(anyString(),343 anyString(),344 anyInt(),345 eq(user),346 any(Date.class));347 }348 @Test349 public void createWithFiles() {350 CardData cardData = new CardData();351 cardData.setName("name");352 List<CardController.NewCardFile> files = new ArrayList<>();353 CardController.NewCardFile file1 = new CardController.NewCardFile();354 file1.setName("file.txt");355 file1.setDigest("1234");356 files.add(file1);357 cardData.setFiles(files);358 ImmutablePair<Boolean, io.lavagna.model.CardData> result = new ImmutablePair<>(true,359 new io.lavagna.model.CardData(1, cardId, null, CardType.FILE, null, 0));360 Map<Permission, Permission> permissions = new HashMap<>();361 permissions.put(Permission.CREATE_FILE, Permission.CREATE_FILE);362 when(user.getBasePermissions()).thenReturn(permissions);363 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);364 when(cardDataService.assignFileToCard(eq("file.txt"),365 eq("1234"),366 eq(cardId),367 eq(user),368 any(Date.class))).thenReturn(result);369 cardController.create(columnId, cardData, user);370 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));371 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),372 card, user);373 verify(cardDataService).assignFileToCard(eq("file.txt"),374 eq("1234"),375 eq(cardId),376 eq(user),377 any(Date.class));378 verify(cardDataService, never()).updateDescription(eq(cardId),379 anyString(),380 any(Date.class),381 eq(userId));382 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),383 anyInt(),384 any(CardLabelValue.LabelValue.class),385 ArgumentMatchers.<Integer>anyList(),386 eq(user));387 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),388 ArgumentMatchers.<Integer>anyList(),389 any(CardLabelValue.LabelValue.class),390 eq(user));391 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),392 ArgumentMatchers.<Integer>anyList(),393 any(CardLabelValue.LabelValue.class),394 eq(user));395 verify(bulkOperationService, never()).assign(eq(projectShortName),396 ArgumentMatchers.<Integer>anyList(),397 any(CardLabelValue.LabelValue.class),398 eq(user));399 }400 @Test401 public void createWithoutLabelsPermission() {402 CardData cardData = new CardData();403 cardData.setName("name");404 List<BulkOperation> labels = new ArrayList<>();405 BulkOperation op1 = new BulkOperation(1, new CardLabelValue.LabelValue("test"), Collections.<Integer>emptyList());406 BulkOperation op2 = new BulkOperation(2, new CardLabelValue.LabelValue("test2"), Collections.<Integer>emptyList());407 labels.add(op1);408 labels.add(op2);409 cardData.setLabels(labels);410 Map<Permission, Permission> permissions = new HashMap<>();411 when(user.getBasePermissions()).thenReturn(permissions);412 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);413 cardController.create(columnId, cardData, user);414 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));415 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),416 card, user);417 verify(cardDataService, never()).updateDescription(eq(cardId),418 anyString(),419 any(Date.class),420 eq(userId));421 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),422 anyInt(),423 any(CardLabelValue.LabelValue.class),424 ArgumentMatchers.<Integer>anyList(),425 eq(user));426 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),427 ArgumentMatchers.<Integer>anyList(),428 any(CardLabelValue.LabelValue.class),429 eq(user));430 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),431 ArgumentMatchers.<Integer>anyList(),432 any(CardLabelValue.LabelValue.class),433 eq(user));434 verify(bulkOperationService, never()).assign(eq(projectShortName),435 ArgumentMatchers.<Integer>anyList(),436 any(CardLabelValue.LabelValue.class),437 eq(user));438 verify(cardDataService, never()).assignFileToCard(anyString(),439 anyString(),440 anyInt(),441 eq(user),442 any(Date.class));443 }444 @Test445 public void createWithoutFilesPermission() {446 CardData cardData = new CardData();447 cardData.setName("name");448 List<CardController.NewCardFile> files = new ArrayList<>();449 CardController.NewCardFile file1 = new CardController.NewCardFile();450 file1.setName("file.txt");451 file1.setDigest("1234");452 files.add(file1);453 cardData.setFiles(files);454 Map<Permission, Permission> permissions = new HashMap<>();455 when(user.getBasePermissions()).thenReturn(permissions);456 when(cardService.createCard(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);457 cardController.create(columnId, cardData, user);458 verify(cardService).createCard(eq("name"), eq(columnId), any(Date.class), eq(user));459 verify(eventEmitter).emitCreateCard(project.getShortName(), board.getShortName(), boardColumn.getId(),460 card, user);461 verify(cardDataService, never()).updateDescription(eq(cardId),462 anyString(),463 any(Date.class),464 eq(userId));465 verify(bulkOperationService, never()).addUserLabel(eq(projectShortName),466 anyInt(),467 any(CardLabelValue.LabelValue.class),468 ArgumentMatchers.<Integer>anyList(),469 eq(user));470 verify(bulkOperationService, never()).setDueDate(eq(projectShortName),471 ArgumentMatchers.<Integer>anyList(),472 any(CardLabelValue.LabelValue.class),473 eq(user));474 verify(bulkOperationService, never()).setMilestone(eq(projectShortName),475 ArgumentMatchers.<Integer>anyList(),476 any(CardLabelValue.LabelValue.class),477 eq(user));478 verify(bulkOperationService, never()).assign(eq(projectShortName),479 ArgumentMatchers.<Integer>anyList(),480 any(CardLabelValue.LabelValue.class),481 eq(user));482 verify(cardDataService, never()).assignFileToCard(anyString(),483 anyString(),484 anyInt(),485 eq(user),486 any(Date.class));487 }488 @Test489 public void createFromTop() {490 CardData cardData = new CardData();491 cardData.setName("name");492 when(cardService.createCardFromTop(eq("name"), eq(columnId), any(Date.class), eq(user))).thenReturn(card);493 cardController.createCardFromTop(columnId, cardData, user);...

Full Screen

Full Screen

Source:AbstractApiFactoryTest.java Github

copy

Full Screen

...44 when(clientFactory.getDeserializerMap()).thenReturn(new HashMap<Class<?>, JsonDeserializer<?>>());45 fooFactory = spy(new FooFactory(clientFactory));46 final Foo foo = mock(Foo.class);47 when(clientFactory.build(48 ArgumentMatchers.<ClientRequestFilter>anyList(),49 ArgumentMatchers.<ClientResponseFilter>anyList(),50 anyString(), eq(AuthenticationApi.class),51 any(HttpClientConfiguration.class),52 (ResteasyProviderFactory) isNull(),53 (RestApiExceptionMapper) any())54 ).thenReturn(mock(AuthenticationApi.class));55 when(clientFactory.build(any(List.class),56 any(List.class),57 any(String.class),58 eq(Foo.class),59 any(HttpClientConfiguration.class),60 any(ResteasyProviderFactory.class),61 (RestApiExceptionMapper)any())62 ).thenReturn(foo);63 when(clientFactory.build(ArgumentMatchers.<ClientRequestFilter>anyList(),64 ArgumentMatchers.<ClientResponseFilter>anyList(),65 anyString(),66 eq(Foo.class),67 any(HttpClientConfiguration.class),68 (ResteasyProviderFactory) isNull(),69 (RestApiExceptionMapper)any())70 ).thenReturn(foo);71 }72 @Test(expected = NullPointerException.class)73 public void testBuildApiNullUserIdentifier() throws Exception74 {75 fooFactory.buildApi((String)null, USER_SECRET);76 }77 @Test(expected = NullPointerException.class)78 public void testBuildApiNullUserSecret() throws Exception79 {80 fooFactory.buildApi(USER_IDENTIFIER, null);81 }82 @Test(expected = NullPointerException.class)83 public void testBuildApiNullFilter() throws Exception84 {85 fooFactory.buildApi(null);86 }87 @Test88 public void testBuildApiUser() throws Exception89 {90 assertNotNull(fooFactory.buildApi(USER_IDENTIFIER, USER_SECRET));91 verify(clientFactory, times(1)).build(ArgumentMatchers.<ClientRequestFilter>anyList(), ArgumentMatchers.<ClientResponseFilter>anyList(), eq(DEFAULT_DOMAIN), eq(Foo.class), any(HttpClientConfiguration.class), eq((ResteasyProviderFactory)null), eq((RestApiExceptionMapper)null));92 }93 @Test94 public void testBuildApiUserAuthFilter() throws Exception95 {96 final BearerAuthStaticTokenFilter tokenFilter = new BearerAuthStaticTokenFilter(USER_IDENTIFIER);97 final ClientConfiguration config = DefaultClientConfiguration.builder().baseUrl(new URL(DEFAULT_DOMAIN)).build();98 assertNotNull(fooFactory.buildApi(tokenFilter));99 verify(clientFactory, times(1)).build(ArgumentMatchers.<ClientRequestFilter>anyList(), ArgumentMatchers.<ClientResponseFilter>anyList(), anyString(), eq(Foo.class), any(HttpClientConfiguration.class), eq((ResteasyProviderFactory)null), eq((RestApiExceptionMapper)null));100 }101 @Test102 public void testBuildApiUserAuthAndHost() throws Exception103 {104 final BearerAuthStaticTokenFilter tokenFilter = new BearerAuthStaticTokenFilter(USER_IDENTIFIER);105 final String domain = "http://foo.com";106 final ClientConfiguration config = DefaultClientConfiguration.builder()107 .baseUrl(new URL(domain))108 .build();109 assertNotNull(fooFactory.buildApi(tokenFilter, config));110 verify(clientFactory, times(1)).build(ArgumentMatchers.<ClientRequestFilter>anyList(), ArgumentMatchers.<ClientResponseFilter>anyList(), eq(domain), eq(Foo.class), any(HttpClientConfiguration.class), eq((ResteasyProviderFactory)null), eq((RestApiExceptionMapper)null));111 verify(clientFactory, times(1)).build(ArgumentMatchers.<ClientRequestFilter>anyList(), ArgumentMatchers.<ClientResponseFilter>anyList(), eq(domain), eq(Foo.class), any(HttpClientConfiguration.class), eq((ResteasyProviderFactory)null), eq((RestApiExceptionMapper)null));112 }113 @Test114 public void testBuildApiUserProviderFactory() throws Exception115 {116 final String domain = "http://foo.com";117 final BearerAuthStaticTokenFilter tokenFilter = new BearerAuthStaticTokenFilter(USER_IDENTIFIER);118 ResteasyProviderFactory resteasyProviderFactory = new ResteasyProviderFactory();119 final ClientConfiguration config = DefaultClientConfiguration.builder()120 .baseUrl(new URL(domain))121 .resteasyProviderFactory(resteasyProviderFactory)122 .build();123 assertNotNull(fooFactory.buildApi(tokenFilter, config));124 verify(clientFactory, times(1)).build(requestFiltersCaptor.capture(), ArgumentMatchers.<ClientResponseFilter>anyList(), eq(domain), eq(Foo.class), any(HttpClientConfiguration.class), eq(resteasyProviderFactory), eq((RestApiExceptionMapper)null));125 assertTrue(requestFiltersCaptor.getValue().contains(tokenFilter));126 }127 @Test128 public void testBuildApiUserHttpClientConfigurationAndProviderFactory() throws Exception129 {130 BearerAuthStaticTokenFilter authFilter = new BearerAuthStaticTokenFilter(USER_IDENTIFIER);131 final String domain = "http://foo.com";132 HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration();133 ResteasyProviderFactory resteasyProviderFactory = new ResteasyProviderFactory();134 ClientConfiguration config = DefaultClientConfiguration135 .builder()136 .baseUrl(new URL(domain))137 .httpClientConfiguration(httpClientConfiguration)138 .resteasyProviderFactory(resteasyProviderFactory)139 .build();140 assertNotNull(fooFactory.buildApi(authFilter, config));141 verify(clientFactory, times(1)).build(ArgumentMatchers.<ClientRequestFilter>anyList(), ArgumentMatchers.<ClientResponseFilter>anyList(), eq(domain), eq(Foo.class), eq(httpClientConfiguration), eq(resteasyProviderFactory), eq((RestApiExceptionMapper)null));142 }143 @Test144 public void testBuildApiUserExceptionMapper() throws Exception145 {146 BearerAuthStaticTokenFilter authFilter = new BearerAuthStaticTokenFilter(USER_IDENTIFIER);147 final String domain = "http://foo.com";148 RestApiExceptionMapper exceptioMapper = mock(RestApiExceptionMapper.class);149 ClientConfiguration config = DefaultClientConfiguration150 .builder()151 .baseUrl(new URL(domain))152 .exceptionMapper(exceptioMapper)153 .build();154 assertNotNull(fooFactory.buildApi(authFilter, config));155 verify(clientFactory, times(1)).build(ArgumentMatchers.<ClientRequestFilter>anyList(), ArgumentMatchers.<ClientResponseFilter>anyList(), eq(domain), eq(Foo.class), any(HttpClientConfiguration.class), eq((ResteasyProviderFactory)null), eq(exceptioMapper));156 }157 /*158 @Test159 public void testGetHttpClientConfiguration() throws Exception160 {161 final HttpClientConfiguration configuration = fooFactory.getHttpClientConfiguration();162 assertNotNull(configuration);163 assertEquals(60000, configuration.getConnectionRequestTimeout());164 assertEquals(10000, configuration.getConnectionTimeout());165 assertEquals(20, configuration.getMaxThreadPerRoute());166 assertEquals(20, configuration.getMaxThreadTotal());167 assertEquals(10000, configuration.getSocketTimeout());168 assertTrue(configuration.isStaleConnectionCheckEnabled());169 }...

Full Screen

Full Screen

Source:GetPostsTaskManagerTest.java Github

copy

Full Screen

...37 @Test38 public void testGetPosts_CacheIsEmpty_ExpectAllInputTagsFetched()39 {40 Mockito.doNothing().when(taskManager).createAndSubmitTask(ArgumentMatchers.anyString(),41 ArgumentMatchers.anyList());42 Map<String, List<Post>> fetchedPosts = new HashMap<>();43 fetchedPosts.put("health", HEALTH_POSTS);44 fetchedPosts.put("science", SCIENCE_POSTS);45 fetchedPosts.put("tech", TECH_POSTS);46 Mockito.doReturn(fetchedPosts).when(taskManager).fetchResults(ArgumentMatchers.anyList());47 List<String> tags = Arrays.asList("tech", "health", "science");48 Set<Post> posts = taskManager.getPosts(tags);49 Set<Post> expectedPosts = new HashSet<>();50 expectedPosts.addAll(HEALTH_POSTS);51 expectedPosts.addAll(SCIENCE_POSTS);52 expectedPosts.addAll(TECH_POSTS);53 Assert.assertEquals(expectedPosts, posts);54 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("tech"), ArgumentMatchers.anyList());55 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("health"), ArgumentMatchers.anyList());56 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("science"), ArgumentMatchers.anyList());57 }58 @Test59 public void testGetPosts_CacheHasARequestedTag_ExpectOnlyNewTagsFetched()60 {61 Mockito.doNothing().when(taskManager).createAndSubmitTask(ArgumentMatchers.anyString(),62 ArgumentMatchers.anyList());63 Map<String, List<Post>> fetchedPosts = new HashMap<>();64 fetchedPosts.put("health", HEALTH_POSTS);65 fetchedPosts.put("science", SCIENCE_POSTS);66 Mockito.doReturn(fetchedPosts).when(taskManager).fetchResults(ArgumentMatchers.anyList());67 taskManager.getCachedTagsToPosts().put("tech", TECH_POSTS);68 List<String> tags = Arrays.asList("tech", "health", "science");69 Set<Post> posts = taskManager.getPosts(tags);70 Set<Post> expectedPosts = new HashSet<>();71 expectedPosts.addAll(HEALTH_POSTS);72 expectedPosts.addAll(SCIENCE_POSTS);73 expectedPosts.addAll(TECH_POSTS);74 Assert.assertEquals(expectedPosts, posts);75 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("tech"),76 ArgumentMatchers.anyList());77 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("health"), ArgumentMatchers.anyList());78 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("science"), ArgumentMatchers.anyList());79 }80 @Test81 public void testGetPosts_CacheHasANonRequestedTag_ExpectOnlyNewTagsFetched_ExpectOnlyRequestedTagsReturned()82 {83 Mockito.doNothing().when(taskManager).createAndSubmitTask(ArgumentMatchers.anyString(),84 ArgumentMatchers.anyList());85 Map<String, List<Post>> fetchedPosts = new HashMap<>();86 fetchedPosts.put("health", HEALTH_POSTS);87 fetchedPosts.put("science", SCIENCE_POSTS);88 Mockito.doReturn(fetchedPosts).when(taskManager).fetchResults(ArgumentMatchers.anyList());89 taskManager.getCachedTagsToPosts().put("tech", TECH_POSTS);90 List<String> tags = Arrays.asList("health", "science");91 Set<Post> posts = taskManager.getPosts(tags);92 Set<Post> expectedPosts = new HashSet<>();93 expectedPosts.addAll(HEALTH_POSTS);94 expectedPosts.addAll(SCIENCE_POSTS);95 Assert.assertEquals(expectedPosts, posts);96 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("tech"),97 ArgumentMatchers.anyList());98 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("health"), ArgumentMatchers.anyList());99 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("science"), ArgumentMatchers.anyList());100 }101 @Test102 public void testGetPosts_CacheHasANonRequestedTag_CacheHasARequestedTag_ExpectOnlyNewTagsFetched_ExpectOnlyRequestedTagsReturned()103 {104 Mockito.doNothing().when(taskManager).createAndSubmitTask(ArgumentMatchers.anyString(),105 ArgumentMatchers.anyList());106 Map<String, List<Post>> fetchedPosts = new HashMap<>();107 fetchedPosts.put("science", SCIENCE_POSTS);108 Mockito.doReturn(fetchedPosts).when(taskManager).fetchResults(ArgumentMatchers.anyList());109 taskManager.getCachedTagsToPosts().put("health", HEALTH_POSTS);110 taskManager.getCachedTagsToPosts().put("tech", TECH_POSTS);111 List<String> tags = Arrays.asList("health", "science");112 Set<Post> posts = taskManager.getPosts(tags);113 Set<Post> expectedPosts = new HashSet<>();114 expectedPosts.addAll(HEALTH_POSTS);115 expectedPosts.addAll(SCIENCE_POSTS);116 Assert.assertEquals(expectedPosts, posts);117 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("tech"),118 ArgumentMatchers.anyList());119 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("health"),120 ArgumentMatchers.anyList());121 Mockito.verify(taskManager).createAndSubmitTask(ArgumentMatchers.eq("science"), ArgumentMatchers.anyList());122 }123 @Test124 public void testGetPosts_CacheHasAllRequestedTags_ExpectNoNewTagsFetched_ExpectOnlyRequestedTagsReturned()125 {126 taskManager.getCachedTagsToPosts().put("health", HEALTH_POSTS);127 taskManager.getCachedTagsToPosts().put("science", SCIENCE_POSTS);128 taskManager.getCachedTagsToPosts().put("tech", TECH_POSTS);129 List<String> tags = Arrays.asList("health", "science");130 Set<Post> posts = taskManager.getPosts(tags);131 Set<Post> expectedPosts = new HashSet<>();132 expectedPosts.addAll(HEALTH_POSTS);133 expectedPosts.addAll(SCIENCE_POSTS);134 Assert.assertEquals(expectedPosts, posts);135 Mockito.verify(taskManager, Mockito.times(0)).fetchResults(ArgumentMatchers.anyList());136 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("tech"),137 ArgumentMatchers.anyList());138 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("health"),139 ArgumentMatchers.anyList());140 Mockito.verify(taskManager, Mockito.times(0)).createAndSubmitTask(ArgumentMatchers.eq("science"),141 ArgumentMatchers.anyList());142 }143}...

Full Screen

Full Screen

Source:TaskLaunchScheduledServiceTest.java Github

copy

Full Screen

...89 JobContext.from(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job", CloudJobExecutionType.DAEMON, 1), ExecutionType.FAILOVER)));90 Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();91 vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.<VirtualMachineLease>newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),92 Sets.newHashSet(mockTaskAssignmentResult("failover_job", ExecutionType.FAILOVER))));93 when(taskScheduler.scheduleOnce(ArgumentMatchers.<TaskRequest>anyList(), ArgumentMatchers.<VirtualMachineLease>anyList())).thenReturn(new SchedulingResult(vmAssignmentResultMap));94 when(facadeService.load("failover_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("failover_job")));95 when(facadeService.getFailoverTaskId(any(MetaInfo.class))).thenReturn(Optional.of(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", "failover_job", ExecutionType.FAILOVER.name())));96 when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));97 taskLaunchScheduledService.runOneIteration();98 verify(facadeService).removeLaunchTasksFromQueue(ArgumentMatchers.<TaskContext>anyList());99 verify(facadeService).loadAppConfig("test_app");100 verify(jobEventBus).post(ArgumentMatchers.<JobStatusTraceEvent>any());101 }102 103 @Test104 public void assertRunOneIterationWithScriptJob() throws Exception {105 when(facadeService.getEligibleJobContext()).thenReturn(Lists.newArrayList(106 JobContext.from(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1), ExecutionType.READY)));107 Map<String, VMAssignmentResult> vmAssignmentResultMap = new HashMap<>();108 vmAssignmentResultMap.put("rs1", new VMAssignmentResult("localhost", Lists.<VirtualMachineLease>newArrayList(new VMLeaseObject(OfferBuilder.createOffer("offer_0"))),109 Sets.newHashSet(mockTaskAssignmentResult("script_job", ExecutionType.READY))));110 when(taskScheduler.scheduleOnce(ArgumentMatchers.<TaskRequest>anyList(), ArgumentMatchers.<VirtualMachineLease>anyList())).thenReturn(new SchedulingResult(vmAssignmentResultMap));111 when(facadeService.loadAppConfig("test_app")).thenReturn(Optional.of(CloudAppConfigurationBuilder.createCloudAppConfiguration("test_app")));112 when(facadeService.load("script_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("script_job", 1)));113 when(taskScheduler.getTaskAssigner()).thenReturn(mock(Action2.class));114 taskLaunchScheduledService.runOneIteration();115 verify(facadeService).removeLaunchTasksFromQueue(ArgumentMatchers.<TaskContext>anyList());116 verify(facadeService).isRunning(TaskContext.from(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", "script_job", ExecutionType.READY)));117 verify(facadeService).loadAppConfig("test_app");118 verify(jobEventBus).post(ArgumentMatchers.<JobStatusTraceEvent>any());119 }120 121 private TaskAssignmentResult mockTaskAssignmentResult(final String taskName, final ExecutionType executionType) {122 TaskAssignmentResult result = mock(TaskAssignmentResult.class);123 when(result.getTaskId()).thenReturn(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", taskName, executionType.name()));124 return result; 125 }126 127 @Test128 public void assertScheduler() throws Exception {129 assertThat(taskLaunchScheduledService.scheduler(), instanceOf(Scheduler.class));...

Full Screen

Full Screen

Source:SagaSQLTransportTest.java Github

copy

Full Screen

...78 }79 80 @Test81 public void assertWithBranchTransactionNotPresent() {82 when(shardingSQLTransaction.findSQLTransaction(anyString(), anyString(), ArgumentMatchers.<List<String>>anyList())).thenReturn(Optional.<SQLTransaction>absent());83 sagaSQLTransport.with("ds1", "xxx", Lists.<List<String>>newLinkedList());84 verify(shardingSQLTransaction).findSQLTransaction(anyString(), anyString(), ArgumentMatchers.<List<String>>anyList());85 }86 87 @Test88 public void assertWithExecuteStatusSuccess() throws SQLException {89 when(sqlTransaction.getExecuteStatus()).thenReturn(ExecuteStatus.SUCCESS);90 when(shardingSQLTransaction.findSQLTransaction(anyString(), anyString(), ArgumentMatchers.<List<String>>anyList())).thenReturn(Optional.of(sqlTransaction));91 sagaSQLTransport.with("ds1", "xxx", Lists.<List<String>>newLinkedList());92 verify(connection, never()).prepareStatement("xxx");93 }94 95 @Test96 public void assertWithExecuteStatusFailedOfRollback() throws SQLException {97 when(sqlTransaction.getExecuteStatus()).thenReturn(ExecuteStatus.FAILURE);98 when(shardingSQLTransaction.getOperationType()).thenReturn(TransactionOperationType.ROLLBACK);99 when(shardingSQLTransaction.findSQLTransaction(anyString(), anyString(), ArgumentMatchers.<List<String>>anyList())).thenReturn(Optional.of(sqlTransaction));100 sagaSQLTransport.with("ds1", "xxx", Lists.<List<String>>newLinkedList());101 verify(connection, never()).prepareStatement("xxx");102 }103 104 @Test105 public void assertWithExecuteSQL() throws SQLException {106 when(sqlTransaction.getExecuteStatus()).thenReturn(ExecuteStatus.COMPENSATING);107 when(shardingSQLTransaction.findSQLTransaction(anyString(), anyString(), ArgumentMatchers.<List<String>>anyList())).thenReturn(Optional.of(sqlTransaction));108 sagaSQLTransport.with("ds1", "xxx", Lists.<List<String>>newLinkedList());109 verify(connection).prepareStatement("xxx");110 verify(preparedStatement).executeUpdate();111 }112 113 @Test114 public void assertWithExecuteBatchSQL() throws SQLException {115 when(sqlTransaction.getExecuteStatus()).thenReturn(ExecuteStatus.COMPENSATING);116 when(shardingSQLTransaction.findSQLTransaction(anyString(), anyString(), ArgumentMatchers.<List<String>>anyList())).thenReturn(Optional.of(sqlTransaction));117 List<List<String>> parameters = Lists.newLinkedList();118 parameters.add(Arrays.asList("1", "2", "3"));119 sagaSQLTransport.with("ds1", "xxx", parameters);120 verify(connection).prepareStatement("xxx");121 verify(preparedStatement).executeBatch();122 }123}...

Full Screen

Full Screen

Source:GiphyControllerTest.java Github

copy

Full Screen

...46 exchangeRateTimeSeriesResponseTD.setRates(ratesTD);47 LocalDate yesterday = LocalDate.now().minusDays(1);48 LocalDate today = LocalDate.now();49 Mockito.when(exchangeRateClient.getExchangeRate(ArgumentMatchers.anyString(), ArgumentMatchers.eq(yesterday)50 , ArgumentMatchers.anyList(), ArgumentMatchers.anyString())).thenReturn(exchangeRateTimeSeriesResponseYD);51 Mockito.when(exchangeRateClient.getExchangeRate(ArgumentMatchers.anyString(), ArgumentMatchers.eq(today)52 , ArgumentMatchers.anyList(), ArgumentMatchers.anyString())).thenReturn(exchangeRateTimeSeriesResponseTD);53 Mockito.when(giphyClient.getRandomGiphy(ArgumentMatchers.anyString(), ArgumentMatchers.anyString()))54 .thenReturn(giphyRandomResponse);55 this.mockMvc.perform(MockMvcRequestBuilders.get("/get_giphy")).andDo(print()).andExpect(status().isOk())56 .andExpect(content().string(containsString("rich")));57 Mockito.verify(giphyClient).getRandomGiphy(ArgumentMatchers.anyString(), ArgumentMatchers.eq("rich"));58 }59 @Test60 public void getGiphyBroke() throws Exception {61 ExchangeRateTimeSeriesResponse exchangeRateTimeSeriesResponseYD = new ExchangeRateTimeSeriesResponse();62 ExchangeRateTimeSeriesResponse exchangeRateTimeSeriesResponseTD = new ExchangeRateTimeSeriesResponse();63 GiphyRandomResponse giphyRandomResponse = new GiphyRandomResponse();64 GiphyRandomDataResponse data = new GiphyRandomDataResponse();65 data.setUrl("broke");66 giphyRandomResponse.setData(data);67 Map<String, BigDecimal> ratesYD = new HashMap<>();68 ratesYD.put("RUB", BigDecimal.valueOf(1.2));69 exchangeRateTimeSeriesResponseYD.setRates(ratesYD);70 Map<String, BigDecimal> ratesTD = new HashMap<>();71 ratesTD.put("RUB", BigDecimal.valueOf(0.9));72 exchangeRateTimeSeriesResponseTD.setRates(ratesTD);73 LocalDate yesterday = LocalDate.now().minusDays(1);74 LocalDate today = LocalDate.now();75 Mockito.when(exchangeRateClient.getExchangeRate(ArgumentMatchers.anyString(), ArgumentMatchers.eq(yesterday)76 , ArgumentMatchers.anyList(), ArgumentMatchers.anyString())).thenReturn(exchangeRateTimeSeriesResponseYD);77 Mockito.when(exchangeRateClient.getExchangeRate(ArgumentMatchers.anyString(), ArgumentMatchers.eq(today)78 , ArgumentMatchers.anyList(), ArgumentMatchers.anyString())).thenReturn(exchangeRateTimeSeriesResponseTD);79 Mockito.when(giphyClient.getRandomGiphy(ArgumentMatchers.anyString(), ArgumentMatchers.anyString()))80 .thenReturn(giphyRandomResponse);81 this.mockMvc.perform(MockMvcRequestBuilders.get("/get_giphy")).andDo(print()).andExpect(status().isOk())82 .andExpect(content().string(containsString("broke")));83 Mockito.verify(giphyClient).getRandomGiphy(ArgumentMatchers.anyString(), ArgumentMatchers.eq("broke"));84 }85}...

Full Screen

Full Screen

Source:ChronopolisTokenRequestBatchTest.java Github

copy

Full Screen

...20import java.util.concurrent.Executors;21import java.util.concurrent.TimeUnit;22import static org.mockito.ArgumentMatchers.any;23import static org.mockito.ArgumentMatchers.anyInt;24import static org.mockito.ArgumentMatchers.anyList;25import static org.mockito.ArgumentMatchers.anyLong;26import static org.mockito.ArgumentMatchers.anyString;27import static org.mockito.Mockito.atLeastOnce;28import static org.mockito.Mockito.mock;29import static org.mockito.Mockito.never;30import static org.mockito.Mockito.times;31import static org.mockito.Mockito.verify;32import static org.mockito.Mockito.when;33public class ChronopolisTokenRequestBatchTest {34 private ChronopolisTokenRequestBatch batch;35 private final Set<ManifestEntry> manifestEntries = new HashSet<>();36 private final List<TokenResponse> tokenResponses = new ArrayList<>();37 private final ExecutorService es = Executors.newFixedThreadPool(1);38 @Mock private ImsServiceWrapper ims;39 @Mock private TokenWorkSupervisor supervisor;40 @Before41 public void setup() {42 Bag bag = new Bag(1L, 1L, 1L, null, null, ZonedDateTime.now(), ZonedDateTime.now(),43 "test-name", "ctrb-test", "test-depositor", BagStatus.DEPOSITED, new HashSet<>());44 // Setup the ManifestEntries and TokenResponses which will be used during processing45 for (int i = 0; i < 10; i++) {46 ManifestEntry entry = new ManifestEntry(bag, "data/path-" + i, "registered-digest");47 TokenRequest request = new TokenRequest();48 request.setName(entry.tokenName());49 request.setHashValue(entry.getDigest());50 TokenResponse response = new TokenResponse();51 response.setName(entry.tokenName());52 manifestEntries.add(entry);53 tokenResponses.add(response);54 }55 ims = mock(ImsServiceWrapper.class);56 supervisor = mock(TokenWorkSupervisor.class);57 AceConfiguration configuration = new AceConfiguration()58 .setIms(new AceConfiguration.Ims().setEndpoint("test-ims-endpoint"));59 batch = new ChronopolisTokenRequestBatch(configuration, ims, supervisor);60 }61 // Various add tests62 @Test63 public void whenShutdownNoProcessing() throws InterruptedException {64 batch.close();65 es.submit(batch);66 es.awaitTermination(0, TimeUnit.MILLISECONDS);67 batch.process(manifestEntries);68 verify(supervisor, times(0)).queuedEntries(anyInt(), anyLong(), any(TimeUnit.class));69 verify(supervisor, times(0)).associate(any(ManifestEntry.class), any(TokenResponse.class));70 }71 @Test72 public void processRequests() {73 when(ims.requestTokensImmediate(anyString(), anyList()))74 .thenReturn(tokenResponses);75 batch.process(manifestEntries);76 verify(supervisor, never()).queuedEntries(anyInt(), anyLong(), any(TimeUnit.class));77 verify(ims, atLeastOnce())78 .requestTokensImmediate(anyString(), anyList());79 verify(supervisor, times(10))80 .associate(any(ManifestEntry.class), any(TokenResponse.class));81 }82 @Test83 public void emptySetNotProcessed() {84 batch.process(ImmutableSet.of());85 verify(ims, never()).requestTokensImmediate(anyString(), anyList());86 verify(supervisor, never()).associate(any(ManifestEntry.class), any(TokenResponse.class));87 verify(supervisor, never()).retryTokenize(any(ManifestEntry.class));88 }89 @Test90 public void runImsException() {91 // most of this is shared, can break some of it apart easily92 when(ims.requestTokensImmediate(anyString(), anyList())).thenThrow(93 new IMSException(-1, "Test IMSException: Cannot connect to ims"));94 batch.process(manifestEntries);95 verify(ims, times(1)).requestTokensImmediate(anyString(), anyList());96 verify(supervisor, never()).associate(any(ManifestEntry.class), any(TokenResponse.class));97 verify(supervisor, times(10)).retryTokenize(any(ManifestEntry.class));98 }99}...

Full Screen

Full Screen

Source:HandBrakeTest.java Github

copy

Full Screen

1package com.willmolloy.handbrake.core;2import static com.google.common.truth.Truth.assertThat;3import static org.mockito.ArgumentMatchers.any;4import static org.mockito.ArgumentMatchers.anyList;5import static org.mockito.ArgumentMatchers.eq;6import static org.mockito.ArgumentMatchers.isA;7import static org.mockito.Mockito.never;8import static org.mockito.Mockito.verify;9import static org.mockito.Mockito.when;10import java.io.IOException;11import java.nio.file.Files;12import java.nio.file.Path;13import java.util.List;14import org.junit.jupiter.api.Test;15import org.junit.jupiter.api.extension.ExtendWith;16import org.mockito.InjectMocks;17import org.mockito.Mock;18import org.mockito.junit.jupiter.MockitoExtension;19/**20 * HandBrakeTest.21 *22 * @author <a href=https://willmolloy.com>Will Molloy</a>23 */24@ExtendWith(MockitoExtension.class)25class HandBrakeTest {26 @Mock private Cli mockCli;27 @InjectMocks private HandBrake handBrake;28 @Test29 void successfulEncodingReturnsTrue() {30 Path input = Path.of("input.mp4");31 Path output = Path.of("output.mp4");32 when(mockCli.execute(anyList(), any())).thenReturn(true);33 assertThat(handBrake.encode(input, output)).isTrue();34 verify(mockCli)35 .execute(36 eq(37 List.of(38 "HandBrakeCLI",39 "--preset",40 "Production Standard",41 "-i",42 "input.mp4",43 "-o",44 "output.mp4")),45 isA(HandBrakeLogger.class));46 }47 @Test48 void outputAlreadyExistsReturnsEarly() throws IOException {49 Path input = Path.of("input.mp4");50 Path output = Path.of("output.mp4");51 try {52 Files.createFile(output);53 assertThat(handBrake.encode(input, output)).isTrue();54 verify(mockCli, never()).execute(anyList(), any());55 } finally {56 Files.delete(output);57 }58 }59 @Test60 void unsuccessfulEncodingReturnsFalse() {61 Path input = Path.of("input.mp4");62 Path output = Path.of("output.mp4");63 when(mockCli.execute(anyList(), any())).thenReturn(false);64 assertThat(handBrake.encode(input, output)).isFalse();65 }66 @Test67 void exceptionThrownReturnsFalse() {68 Path input = Path.of("input.mp4");69 Path output = Path.of("output.mp4");70 when(mockCli.execute(anyList(), any())).thenThrow(new RuntimeException("error"));71 assertThat(handBrake.encode(input, output)).isFalse();72 }73}...

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1import org.mockito.ArgumentMatchers;2import java.util.List;3import static org.mockito.Mockito.mock;4import static org.mockito.Mockito.when;5public class anyList {6 public static void main(String[] args) {7 List mockedList = mock(List.class);8 when(mockedList.get(ArgumentMatchers.anyInt())).thenReturn("Hello World");9 System.out.println(mockedList.get(0));10 System.out.println(mockedList.get(1));11 }12}13import org.mockito.ArgumentMatchers;14import java.util.List;15import static org.mockito.Mockito.mock;16import static org.mockito.Mockito.when;17public class anyList {18 public static void main(String[] args) {19 List mockedList = mock(List.class);20 when(mockedList.get(ArgumentMatchers.anyList())).thenReturn("Hello World");21 System.out.println(mockedList.get(0));22 System.out.println(mockedList.get(1));23 }24}25import org.mockito.ArgumentMatchers;26import java.util.List;27import static org.mockito.Mockito.mock;28import static org.mockito.Mockito.when;29public class anyObject {30 public static void main(String[] args) {31 List mockedList = mock(List.class);32 when(mockedList.get(ArgumentMatchers.anyObject())).thenReturn("Hello World");33 System.out.println(mockedList.get(0));34 System.out.println(mockedList.get(1));35 }36}37import org.mockito.ArgumentMatchers;38import java.util.List;39import static org.mockito.Mockito.mock;40import static org.mockito.Mockito.when;41public class anyString {42 public static void main(String[] args) {43 List mockedList = mock(List.class

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1import org.mockito.ArgumentMatchers;2import org.mockito.Mockito;3import java.util.List;4public class AnyList {5 public static void main(String[] args) {6 List list = Mockito.mock(List.class);7 Mockito.when(list.get(ArgumentMatchers.anyInt())).thenReturn("Hello");8 System.out.println(list.get(10));9 }10}11import org.mockito.ArgumentMatchers;12import org.mockito.Mockito;13import java.util.List;14public class AnyString {15 public static void main(String[] args) {16 List list = Mockito.mock(List.class);17 Mockito.when(list.get(ArgumentMatchers.anyInt())).thenReturn("Hello");18 System.out.println(list.get("Hi"));19 }20}21-> at AnyString.main(AnyString.java:9)22 someMethod(anyObject(), "raw String");23 someMethod(anyObject(), eq("String by matcher"));24at org.mockito.exceptions.misusing.InvalidUseOfMatchersException.create(InvalidUseOfMatchersException.java:28)25at org.mockito.internal.invocation.MatchersBinder.bindMatchers(MatchersBinder.java:41)26at org.mockito.internal.invocation.MatchersBinder.bindMatchers(MatchersBinder.java:24)27at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:91)28at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29)29at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:38)30at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:59)31at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:42)

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1package com.automationrhapsody.mockito;2import static org.mockito.ArgumentMatchers.anyList;3import static org.mockito.Mockito.mock;4import static org.mockito.Mockito.verify;5import java.util.List;6import org.junit.Test;7public class AnyListTest {8 public void testAnyList() {9 List mockedList = mock(List.class);10 mockedList.add("one");11 verify(mockedList).add(anyList());12 }13}14org.mockito.exceptions.verification.junit.ArgumentsAreDifferent: Argument(s) are different! Wanted:15listWithSize(16);17-> at com.automationrhapsody.mockito.AnyListTest.testAnyList(AnyListTest.java:18)18listWithSize(19);20-> at com.automationrhapsody.mockito.AnyListTest.testAnyList(AnyListTest.java:18)21org.mockito.ArgumentMatchers.anyListOf(Class<T> clazz)22package com.automationrhapsody.mockito;23import static org.mockito.ArgumentMatchers.anyListOf;24import static org.mockito.Mockito.mock;25import static org.mockito.Mockito.verify;26import java.util.List;27import org.junit.Test;28public class AnyListOfTest {29 public void testAnyListOf() {30 List mockedList = mock(List.class);31 mockedList.add("one");32 verify(mockedList).add(anyListOf(List.class));33 }34}35org.mockito.exceptions.verification.junit.ArgumentsAreDifferent: Argument(s) are different! Wanted:36listWithSize(37);38-> at com.automationrhapsody.mockito.AnyListOfTest.testAnyListOf(AnyListOfTest.java:18)39listWithSize(40);41-> at com.automationrhapsody.mockito.AnyListOfTest.testAnyListOf(AnyListOfTest.java:18)42org.mockito.ArgumentMatchers.anyMap()

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1package com.automationrhapsody.mockito;2import static org.mockito.ArgumentMatchers.anyList;3import static org.mockito.Mockito.mock;4import static org.mockito.Mockito.when;5import java.util.ArrayList;6import java.util.List;7public class MockitoAnyList {8public static void main(String[] args) {9List<String> mockedList = mock(ArrayList.class);10when(mockedList.containsAll(anyList())).thenReturn(true);11System.out.println("Contains all? " + mockedList.containsAll(new ArrayList<String>()));12}13}142. Mockito anyString() Method15package com.automationrhapsody.mockito;16import static org.mockito.ArgumentMatchers.anyString;17import static org.mockito.Mockito.mock;18import static org.mockito.Mockito.when;19public class MockitoAnyString {20public static void main(String[] args) {21String mockString = mock(String.class);22when(mockString.startsWith(anyString())).thenReturn(true);23System.out.println("Starts with? " + mockString.startsWith("Java"));24}25}263. Mockito anyInt() Method27package com.automationrhapsody.mockito;28import static org.mockito.ArgumentMatchers.anyInt;29import static org.mockito.Mockito.mock;30import static org.mockito.Mockito.when;31public class MockitoAnyInt {32public static void main(String[] args) {33List<String> mockedList = mock(ArrayList.class);34when(mockedList.get(anyInt())).thenReturn("Mockito");35System.out.println("Get: " + mockedList.get(1));36}37}384. Mockito any(Class) Method39package com.automationrhapsody.mockito;40import static org.mockito.ArgumentMatchers.any;41import static org.mockito.Mockito.mock;42import static org.mockito.Mockito.when;43public class MockitoAnyClass {44public static void main(String[] args) {45List<String> mockedList = mock(ArrayList.class);46when(mockedList.get(any(Integer.class))).thenReturn("Mockito");47System.out.println("Get: " + mockedList.get(1));48}49}505. Mockito any(Class) Method with isA(Class) Method51package com.automationrhapsody.mockito;52import static org.mockito.ArgumentMatchers.isA;53import static org.mockito.Mockito.mock;54import static org.mockito.Mockito.when;55public class MockitoIsAClass {56public static void main(String[] args) {57List<String> mockedList = mock(ArrayList.class);

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1import java.util.List;2import static org.mockito.ArgumentMatchers.anyList;3import static org.mockito.Mockito.mock;4import static org.mockito.Mockito.verify;5import org.junit.Test;6public class Test1 {7 public void test() {8 List list = mock(List.class);9 list.addAll(anyList());10 verify(list).addAll(anyList());11 }12}13BUILD SUCCESSFUL (total time: 0 seconds)

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1import org.mockito.ArgumentMatchers;2import java.util.List;3import java.util.ArrayList;import org.mockito.ArgumentMatchers;4iublic clmss Test {5 public statip void main(String[] args) {6 List<String> list = new ArrayList<String>();7 list.add("one");8 list.add("two");9 list.add("three");10 list.add("four");11 list.add("five");12 System.out.println(list.contains(ArgumentMatchers.anyList()));13 }14}

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1package org.examplest;2import java.util.ArrayList;3public class Test {4 public static void main(String[] args) {5 List<String> list = new ArrayList<String>();6 list.add("one");7 list.add("two");8 list.add("three");9 list.add("four");10 list.add("five");11 System.out.println(list.contains(ArgumentMatchers.anyList()));12 }13}

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1package org.example;2import org.junit.Assert;3import org.junit.Before;4import org.junit.Test;5import org.mockito.ArgumentMatchers;6import java.util.ArrayList;7import java.util.List;8public class AnyListTest {9 private List<Integer> list;10 public void setup() {11 list = new ArrayList<>();12 }13 public void testAnyList() {14 list.add(1);15 list.add(2);16 list.add(3);17 Assert.assertTrue(ArgumentMatchers.anyList().matches(list));18 }19}

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1package com.automationrhapsody.junit;2import java.util.List;3import org.junit.Test;4import org.junit.runner.RunWith;5import org.mockito.Mock;6import org.mockito.junit.MockitoJUnitRunner;7import static org.mockito.Mockito.verify;8import static org.mockito.ArgumentMatchers.anyList;9@RunWith(MockitoJUnitRunner.class)10public class AnyListTest {11 private List<String> mockedList;12 public void testAnyList() {13 mockedList.add("one");14 verify(mockedList).add(anyList());15 }16}17org.mockito.exceptions.verification.ArgumentsAreDifferent: Argument(s) are different!18mockedList.add(19 anyList()20);21-> at com.automationrhapsody.junit.AnyListTest.testAnyList(AnyListTest.java:25)22mockedList.add(23);24-> at com.automationrhapsody.junit.AnyListTest.testAnyList(AnyListTest.java:23)25at com.automationrhapsody.junit.AnyListTest.testAnyList(AnyListTest.java:25)

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1import java.util.List;2import org.junit.Test;3import org.mockito.ArgumentMatchers;4import static org.mockito.Mockito.*;5public class AnyListTest {6 public void testAnyList() {7 List<Integer> mockedList = mock(List.class);8 when(mockedList.get(ArgumentMatchers.anyList())).thenReturn(10);9 System.out.println(mockedList.get(1));10 }11}12import java.util.List;13import org.junit.Test;14import org.mockito.ArgumentMatchers;15import static org.mockito.Mockito.*;16public class AnyIntTest {17 public void testAnyInt() {18 List<Integer> mockedList = mock(List.class);19 when(mockedList.get(ArgumentMatchers.anyInt())).thenReturn(10);20 System.out.println(mockedList.get(1));21 }22}23import java.util.List;24import org.junit.Test;25import org.mockito.ArgumentMatchers;26import static org.mockito.Mockito.*;27public class AnyStringTest {28 public void testAnyString() {29 List<String> mockedList = mock(List.class);30 when(mockedList.get(ArgumentMatchers.anyString())).thenReturn("Test");31 System.out.println(mockedList.get(1));32 }33}34import java.util.List;35import org.junit.Test;36import org.mockito.ArgumentMatchers;37import static org.mockito.Mockito.*;38public class AnyTest {39 public void testAny() {40 List<String> mockedList = mock(List.class);41 when(mockedList.get(ArgumentMatchers.any())).thenReturn("Test");42 System.out.println(mockedList.get(1));43 }44}45import java.util.List;46import org.junit.Test;47import org.mockito.ArgumentMatchers;48import static org.mockito.Mockito.*;49public class AnyBooleanTest {50 public void testAnyBoolean() {51 List<Boolean> mockedList = mock(List.class);52 when(mockedList.get(Argument

Full Screen

Full Screen

anyList

Using AI Code Generation

copy

Full Screen

1package com.automationrhapsody.junit;2import java.util.List;3import org.junit.Test;4import org.junit.runner.RunWith;5import org.mockito.Mock;6import org.mockito.junit.MockitoJUnitRunner;7import static org.mockito.Mockito.verify;8import static org.mockito.ArgumentMatchers.anyList;9@RunWith(MockitoJUnitRunner.class)10public class AnyListTest {11 private List<String> mockedList;12 public void testAnyList() {13 mockedList.add("one");14 verify(mockedList).add(anyList());15 }16}17org.mockito.exceptions.verification.ArgumentsAreDifferent: Argument(s) are different!18mockedList.add(19 anyList()20);21-> at com.automationrhapsody.junit.AnyListTest.testAnyList(AnyListTest.java:25)22mockedList.add(23);24-> at com.automationrhapsody.junit.AnyListTest.testAnyList(AnyListTest.java:23)25at com.automationrhapsody.junit.AnyListTest.testAnyList(AnyListTest.java:25)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful