How to use doReturn method of org.mockito.Mockito class

Best Mockito code snippet using org.mockito.Mockito.doReturn

Source:AttributeActionBeanTestIT.java Github

copy

Full Screen

...93 }94 95 @Test96 public void testView() throws ResourceNotFoundException, UserAuthenticationException, UserAuthorizationException, BadRequestException {97 Mockito.doReturn(user).when(actionBean).getUser();98 Mockito.doReturn(1).when(attribute).getId();99 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));100 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());101 Mockito.doReturn(new ArrayList<FixedValue>()).when(attributeDataService).getFixedValues(anyInt());102 103 actionBean.setAttribute(attribute);104 Resolution resolution = actionBean.view();105 106 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s1",Permission.VIEW);107 Mockito.verify(attributeDataService).getFixedValues(1);108 Mockito.verify(attributeDataService).getAttribute(1);109 assertNotNull(resolution);110 assertEquals(resolution.getClass(), ForwardResolution.class);111 }112 113 @Test(expected = UserAuthenticationException.class)114 public void testViewNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException, BadRequestException {115 Mockito.doReturn(null).when(actionBean).getUser();116 actionBean.view();117 }118 119 120 @Test(expected = UserAuthorizationException.class)121 public void testViewNotAuthorizedUser() throws BadRequestException, UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {122 Mockito.doReturn(user).when(actionBean).getUser();123 Mockito.doReturn(1).when(attribute).getId();124 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s1", Permission.VIEW);125 actionBean.setAttribute(attribute);126 actionBean.view();127 }128 129 @Test(expected = BadRequestException.class)130 public void testViewBadRequest() throws UserAuthenticationException, BadRequestException, ResourceNotFoundException, UserAuthorizationException {131 Mockito.doReturn(user).when(actionBean).getUser();132 Mockito.doReturn(null).when(attribute).getId();133 actionBean.setAttribute(attribute);134 actionBean.view();135 }136 137 @Test138 public void testAdd() throws UserAuthenticationException, UserAuthorizationException {139 Mockito.doReturn(user).when(actionBean).getUser();140 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), any(Permission.class));141 142 Resolution resolution = actionBean.add();143 144 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, Permission.INSERT);145 Mockito.verify(namespaceDataService).getAttributeNamespaces();146 Mockito.verify(rdfNamespaceDataService).getRdfNamespaces();147 assertNotNull(resolution);148 assertEquals(resolution.getClass(), ForwardResolution.class);149 assertNotNull(actionBean.getAttribute());150 assertEquals(Attribute.ValueInheritanceMode.NONE, actionBean.getAttribute().getValueInheritanceMode());151 }152 153 @Test(expected = UserAuthenticationException.class)154 public void testAddNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException {155 Mockito.doReturn(null).when(actionBean).getUser();156 actionBean.add();157 }158 159 @Test(expected = UserAuthorizationException.class)160 public void testAddNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException {161 Mockito.doReturn(user).when(actionBean).getUser();162 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), any(Permission.class));163 actionBean.add();164 }165 166 @Test 167 public void testEdit() throws ResourceNotFoundException, UserAuthenticationException, UserAuthorizationException, BadRequestException{168 Mockito.doReturn(user).when(actionBean).getUser();169 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));170 Mockito.doReturn(0).when(attribute).getId();171 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());172 Mockito.doReturn(null).when(actionBean).getRequestParameter(anyString());173 Resolution resolution = actionBean.edit();174 assertNotNull(resolution);175 assertEquals(ForwardResolution.class, resolution.getClass());176 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s0", Permission.UPDATE);177 Mockito.verify(attributeDataService).getAttribute(0);178 Mockito.verify(namespaceDataService).getAttributeNamespaces();179 Mockito.verify(rdfNamespaceDataService).getRdfNamespaces();180 }181 182 @Test183 public void testEditForNewVocabularyId() throws ResourceNotFoundException, UserAuthenticationException, UserAuthorizationException, BadRequestException {184 Mockito.doReturn(user).when(actionBean).getUser();185 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));186 Mockito.doReturn(0).when(attribute).getId();187 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());188 Mockito.doReturn(attribute).when(attributeDataService).setNewVocabularyToAttributeObject(any(Attribute.class), anyInt());189 actionBean.setVocabularyId("1");190 Resolution resolution = actionBean.edit();191 assertNotNull(resolution);192 assertEquals(ForwardResolution.class, resolution.getClass());193 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s0", Permission.UPDATE);194 Mockito.verify(attributeDataService).getAttribute(0);195 Mockito.verify(attributeDataService).setNewVocabularyToAttributeObject(attribute, Integer.parseInt("1"));196 } 197 198 @Test(expected = UserAuthenticationException.class)199 public void testEditNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException, BadRequestException {200 Mockito.doReturn(null).when(actionBean).getUser();201 actionBean.edit();202 }203 204 @Test(expected = UserAuthorizationException.class)205 public void testEditNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException, BadRequestException {206 Mockito.doReturn(user).when(actionBean).getUser();207 Mockito.doReturn(0).when(attribute).getId();208 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));209 actionBean.edit();210 }211 212 @Test(expected = BadRequestException.class)213 public void testEditBadRequest() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException, BadRequestException {214 Mockito.doReturn(user).when(actionBean).getUser();215 Mockito.doReturn(null).when(attribute).getId();216 actionBean.edit();217 }218 219 @Test(expected = ResourceNotFoundException.class)220 public void testEditAttributeNotFound() throws ResourceNotFoundException, UserAuthenticationException, UserAuthorizationException, BadRequestException {221 Mockito.doReturn(user).when(actionBean).getUser();222 Mockito.doReturn(1).when(attribute).getId();223 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));224 Mockito.doThrow(ResourceNotFoundException.class).when(attributeDataService).getAttribute(anyInt());225 actionBean.edit();226 }227 228 @Test(expected = ResourceNotFoundException.class)229 public void testEditNewVocabularyNotFound() throws ResourceNotFoundException, UserAuthenticationException, UserAuthorizationException, BadRequestException {230 Mockito.doReturn(user).when(actionBean).getUser();231 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));232 Mockito.doReturn(0).when(attribute).getId();233 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());234 Mockito.doThrow(ResourceNotFoundException.class).when(attributeDataService).setNewVocabularyToAttributeObject(any(Attribute.class), anyInt());235 actionBean.setVocabularyId("1");236 Resolution resolution = actionBean.edit();237 assertNotNull(resolution);238 assertEquals(ForwardResolution.class, resolution.getClass());239 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s0", Permission.UPDATE);240 Mockito.verify(attributeDataService).getAttribute(0);241 Mockito.verify(attributeDataService).setNewVocabularyToAttributeObject(attribute, Integer.parseInt("1"));242 } 243 244 @Test245 public void testSave() throws UserAuthenticationException, UserAuthorizationException, BadRequestException {246 Mockito.doReturn(user).when(actionBean).getUser();247 Mockito.doReturn(0).when(attributeService).save(any(Attribute.class), any(DDUser.class));248 Resolution resolution = actionBean.save();249 assertNotNull(resolution);250 assertEquals(resolution.getClass(), RedirectResolution.class);251 Mockito.verify(attributeService).save(attribute, user);252 Mockito.verify(namespaceDataService).getAttributeNamespaces();253 Mockito.verify(rdfNamespaceDataService).getRdfNamespaces();254 }255 256 @Test257 public void testDelete() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {258 Mockito.doReturn(user).when(actionBean).getUser();259 Mockito.doReturn(Boolean.TRUE).when(attributeDataService).existsAttribute(0);260 Mockito.doReturn(0).when(attribute).getId();261 Mockito.doNothing().when(attributeService).delete(anyInt(), any(DDUser.class));262 Resolution resolution = actionBean.delete();263 assertNotNull(resolution);264 assertEquals(RedirectResolution.class, resolution.getClass());265 Mockito.verify(attributeService).delete(0, user);266 }267 268 @Test (expected = ResourceNotFoundException.class)269 public void testDeleteResourceNotFound() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {270 Mockito.doReturn(user).when(actionBean).getUser();271 Mockito.doReturn(Boolean.FALSE).when(attributeDataService).existsAttribute(anyInt());272 Mockito.doReturn(0).when(attribute).getId();273 actionBean.delete();274 }275 276 @Test277 public void testConfirmDeleteWithNoDependencies() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {278 Mockito.doReturn(user).when(actionBean).getUser();279 Mockito.doReturn(0).when(attribute).getId();280 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));281 Mockito.doReturn(Boolean.TRUE).when(attributeDataService).existsAttribute(anyInt());282 Mockito.doReturn(0).when(attributeDataService).countAttributeValues(0);283 Mockito.doReturn(null).when(actionBean).delete();284 actionBean.confirmDelete();285 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s0", Permission.DELETE);286 Mockito.verify(attributeDataService).existsAttribute(0);287 Mockito.verify(attributeDataService).countAttributeValues(0);288 Mockito.verify(actionBean).delete();289 }290 291 @Test292 public void testConfirmDeleteWithDependencies() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {293 Mockito.doReturn(user).when(actionBean).getUser();294 Mockito.doReturn(0).when(attribute).getId();295 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));296 Mockito.doReturn(Boolean.TRUE).when(attributeDataService).existsAttribute(anyInt());297 Mockito.doReturn(1).when(attributeDataService).countAttributeValues(0);298 Mockito.doReturn(null).when(attributeDataService).getDistinctTypesWithAttributeValues(0);299 Resolution resolution = actionBean.confirmDelete();300 assertNotNull(resolution);301 assertEquals(ForwardResolution.class, resolution.getClass());302 Mockito.verify(actionBean, times(0)).delete(); 303 }304 305 @Test (expected = UserAuthenticationException.class)306 public void testConfirmDeleteNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {307 Mockito.doReturn(null).when(actionBean).getUser();308 actionBean.confirmDelete();309 }310 311 @Test (expected = UserAuthorizationException.class)312 public void testConfirmDeleteNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {313 Mockito.doReturn(user).when(actionBean).getUser();314 Mockito.doReturn(0).when(attribute).getId();315 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));316 actionBean.confirmDelete();317 }318 319 @Test(expected = ResourceNotFoundException.class)320 public void testConfirmDeleteResourceNotFound() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {321 Mockito.doReturn(user).when(actionBean).getUser();322 Mockito.doReturn(0).when(attribute).getId();323 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));324 Mockito.doReturn(Boolean.FALSE).when(attributeDataService).existsAttribute(0);325 actionBean.confirmDelete();326 }327 328 @Test329 public void testReset() {330 Mockito.doReturn(0).when(attribute).getId();331 Resolution resolution = actionBean.reset();332 assertNotNull(resolution);333 assertEquals(RedirectResolution.class, resolution.getClass());334 }335 336 @Test337 public void testRemoveVocabularyBinding() throws ResourceNotFoundException, UserAuthenticationException, UserAuthorizationException {338 Mockito.doReturn(user).when(actionBean).getUser();339 Mockito.doReturn(0).when(attribute).getId();340 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));341 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(0);342 Resolution resolution = actionBean.removeVocabularyBinding();343 assertNotNull(resolution);344 assertEquals(ForwardResolution.class, resolution.getClass());345 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s0", Permission.UPDATE);346 Mockito.verify(attribute).setVocabulary(null);347 Mockito.verify(namespaceDataService).getAttributeNamespaces();348 Mockito.verify(rdfNamespaceDataService).getRdfNamespaces();349 }350 351 @Test (expected = UserAuthenticationException.class)352 public void testRemoveVocabularyBindingNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {353 Mockito.doReturn(null).when(actionBean).getUser();354 actionBean.removeVocabularyBinding();355 }356 357 @Test (expected = UserAuthorizationException.class)358 public void testRemoveVocabularyBindintNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException, ResourceNotFoundException {359 Mockito.doReturn(user).when(actionBean).getUser();360 Mockito.doReturn(0).when(attribute).getId();361 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));362 actionBean.removeVocabularyBinding();363 }364 365 @Test366 public void testViewRoundTrip() throws ResourceNotFoundException, Exception {367 MockRoundtrip trip = createRoundtrip();368 trip.setParameter("attribute.id", "1");369 Mockito.doReturn(user).when(actionBean).getUser();370 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));371 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());372 Mockito.doReturn(1).when(attribute).getId();373 Mockito.doReturn(new ArrayList<FixedValue>()).when(attributeDataService).getFixedValues(anyInt());374 trip.execute("view");375 376 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s1",Permission.VIEW);377 Mockito.verify(attributeDataService).getFixedValues(1);378 Mockito.verify(attributeDataService).getAttribute(1);379 assertTrue(trip.getDestination().contains("viewAttribute.jsp"));380 }381 382 @Test383 public void testEditVocabularyIdRoundTrip() throws ResourceNotFoundException, Exception {384 MockRoundtrip trip = createRoundtrip();385 trip.setParameter("attribute.id", "1");386 trip.setParameter("vocabularyId", "1");387 388 Mockito.doReturn(user).when(actionBean).getUser();389 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));390 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());391 392 trip.execute("editVocabulary");393 394 Mockito.verify(attributeDataService).setNewVocabularyToAttributeObject(attribute, 1); 395 }396 397 @Test398 public void testEditRoundTripWithOutVocabularyId() throws ResourceNotFoundException, Exception {399 MockRoundtrip trip = createRoundtrip();400 trip.setParameter("attribute.id", "1");401 402 Mockito.doReturn(user).when(actionBean).getUser();403 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));404 Mockito.doReturn(attribute).when(attributeDataService).getAttribute(anyInt());405 406 trip.execute("edit");407 408 Mockito.verify(attributeDataService, times(0)).setNewVocabularyToAttributeObject(attribute, 1); 409 }410 411 412 private MockRoundtrip createRoundtrip() {413 MockServletContext ctx = ActionBeanUtils.getServletContext();414 MockRoundtrip trip = new MockRoundtrip(ctx, AttributeActionBean.class);415 416 return trip;417 }418}...

Full Screen

Full Screen

Source:TestRegionSplitPolicy.java Github

copy

Full Screen

...48 conf = HBaseConfiguration.create();49 HRegionInfo hri = new HRegionInfo(TABLENAME);50 htd = new HTableDescriptor(TABLENAME);51 mockRegion = Mockito.mock(HRegion.class);52 Mockito.doReturn(htd).when(mockRegion).getTableDesc();53 Mockito.doReturn(hri).when(mockRegion).getRegionInfo();54 stores = new TreeMap<byte[], HStore>(Bytes.BYTES_COMPARATOR);55 Mockito.doReturn(stores).when(mockRegion).getStores();56 }57 @Test58 public void testIncreasingToUpperBoundRegionSplitPolicy() throws IOException {59 // Configure IncreasingToUpperBoundRegionSplitPolicy as our split policy60 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,61 IncreasingToUpperBoundRegionSplitPolicy.class.getName());62 // Now make it so the mock region has a RegionServerService that will63 // return 'online regions'.64 RegionServerServices rss = Mockito.mock(RegionServerServices.class);65 final List<HRegion> regions = new ArrayList<HRegion>();66 Mockito.when(rss.getOnlineRegions(TABLENAME)).thenReturn(regions);67 Mockito.when(mockRegion.getRegionServerServices()).thenReturn(rss);68 // Set max size for this 'table'.69 long maxSplitSize = 1024L;70 htd.setMaxFileSize(maxSplitSize);71 // Set flush size to 1/8. IncreasingToUpperBoundRegionSplitPolicy72 // grows by the cube of the number of regions times flushsize each time.73 long flushSize = maxSplitSize/8;74 conf.setLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, flushSize);75 htd.setMemStoreFlushSize(flushSize);76 // If RegionServerService with no regions in it -- 'online regions' == 0 --77 // then IncreasingToUpperBoundRegionSplitPolicy should act like a78 // ConstantSizePolicy79 IncreasingToUpperBoundRegionSplitPolicy policy =80 (IncreasingToUpperBoundRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);81 doConstantSizePolicyTests(policy);82 // Add a store in excess of split size. Because there are "no regions"83 // on this server -- rss.getOnlineRegions is 0 -- then we should split84 // like a constantsizeregionsplitpolicy would85 HStore mockStore = Mockito.mock(HStore.class);86 Mockito.doReturn(2000L).when(mockStore).getSize();87 Mockito.doReturn(true).when(mockStore).canSplit();88 stores.put(new byte[]{1}, mockStore);89 // It should split90 assertTrue(policy.shouldSplit());91 // Now test that we increase our split size as online regions for a table92 // grows. With one region, split size should be flushsize.93 regions.add(mockRegion);94 Mockito.doReturn(flushSize).when(mockStore).getSize();95 // Should not split since store is flush size.96 assertFalse(policy.shouldSplit());97 // Set size of store to be > 2*flush size and we should split98 Mockito.doReturn(flushSize*2 + 1).when(mockStore).getSize();99 assertTrue(policy.shouldSplit());100 // Add another region to the 'online regions' on this server and we should101 // now be no longer be splittable since split size has gone up.102 regions.add(mockRegion);103 assertFalse(policy.shouldSplit());104 // Quadruple (2 squared) the store size and make sure its just over; verify it'll split105 Mockito.doReturn((flushSize * 2 * 2 * 2) + 1).when(mockStore).getSize();106 assertTrue(policy.shouldSplit());107 // Finally assert that even if loads of regions, we'll split at max size108 assertEquals(maxSplitSize, policy.getSizeToCheck(1000));109 // Assert same is true if count of regions is zero.110 assertEquals(maxSplitSize, policy.getSizeToCheck(0));111 }112 @Test113 public void testCreateDefault() throws IOException {114 conf.setLong(HConstants.HREGION_MAX_FILESIZE, 1234L);115 // Using a default HTD, should pick up the file size from116 // configuration.117 ConstantSizeRegionSplitPolicy policy =118 (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(119 mockRegion, conf);120 assertEquals(1234L, policy.getDesiredMaxFileSize());121 // If specified in HTD, should use that122 htd.setMaxFileSize(9999L);123 policy = (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(124 mockRegion, conf);125 assertEquals(9999L, policy.getDesiredMaxFileSize());126 }127 /**128 * Test setting up a customized split policy129 */130 @Test131 public void testCustomPolicy() throws IOException {132 HTableDescriptor myHtd = new HTableDescriptor();133 myHtd.setValue(HTableDescriptor.SPLIT_POLICY,134 KeyPrefixRegionSplitPolicy.class.getName());135 myHtd.setValue(KeyPrefixRegionSplitPolicy.PREFIX_LENGTH_KEY, String.valueOf(2));136 HRegion myMockRegion = Mockito.mock(HRegion.class);137 Mockito.doReturn(myHtd).when(myMockRegion).getTableDesc();138 Mockito.doReturn(stores).when(myMockRegion).getStores();139 HStore mockStore = Mockito.mock(HStore.class);140 Mockito.doReturn(2000L).when(mockStore).getSize();141 Mockito.doReturn(true).when(mockStore).canSplit();142 Mockito.doReturn(Bytes.toBytes("abcd")).when(mockStore).getSplitPoint();143 stores.put(new byte[] { 1 }, mockStore);144 KeyPrefixRegionSplitPolicy policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy145 .create(myMockRegion, conf);146 assertEquals("ab", Bytes.toString(policy.getSplitPoint()));147 Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();148 Mockito.doReturn(Bytes.toBytes("efgh")).when(myMockRegion)149 .getExplicitSplitPoint();150 policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy151 .create(myMockRegion, conf);152 assertEquals("ef", Bytes.toString(policy.getSplitPoint()));153 }154 @Test155 public void testConstantSizePolicy() throws IOException {156 htd.setMaxFileSize(1024L);157 ConstantSizeRegionSplitPolicy policy =158 (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);159 doConstantSizePolicyTests(policy);160 }161 /**162 * Run through tests for a ConstantSizeRegionSplitPolicy163 * @param policy164 */165 private void doConstantSizePolicyTests(final ConstantSizeRegionSplitPolicy policy) {166 // For no stores, should not split167 assertFalse(policy.shouldSplit());168 // Add a store above the requisite size. Should split.169 HStore mockStore = Mockito.mock(HStore.class);170 Mockito.doReturn(2000L).when(mockStore).getSize();171 Mockito.doReturn(true).when(mockStore).canSplit();172 stores.put(new byte[]{1}, mockStore);173 assertTrue(policy.shouldSplit());174 // Act as if there's a reference file or some other reason it can't split.175 // This should prevent splitting even though it's big enough.176 Mockito.doReturn(false).when(mockStore).canSplit();177 assertFalse(policy.shouldSplit());178 // Reset splittability after above179 Mockito.doReturn(true).when(mockStore).canSplit();180 // Set to a small size but turn on forceSplit. Should result in a split.181 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();182 Mockito.doReturn(100L).when(mockStore).getSize();183 assertTrue(policy.shouldSplit());184 // Turn off forceSplit, should not split185 Mockito.doReturn(false).when(mockRegion).shouldForceSplit();186 assertFalse(policy.shouldSplit());187 // Clear families we added above188 stores.clear();189 }190 @Test191 public void testGetSplitPoint() throws IOException {192 ConstantSizeRegionSplitPolicy policy =193 (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);194 // For no stores, should not split195 assertFalse(policy.shouldSplit());196 assertNull(policy.getSplitPoint());197 // Add a store above the requisite size. Should split.198 HStore mockStore = Mockito.mock(HStore.class);199 Mockito.doReturn(2000L).when(mockStore).getSize();200 Mockito.doReturn(true).when(mockStore).canSplit();201 Mockito.doReturn(Bytes.toBytes("store 1 split"))202 .when(mockStore).getSplitPoint();203 stores.put(new byte[]{1}, mockStore);204 assertEquals("store 1 split",205 Bytes.toString(policy.getSplitPoint()));206 // Add a bigger store. The split point should come from that one207 HStore mockStore2 = Mockito.mock(HStore.class);208 Mockito.doReturn(4000L).when(mockStore2).getSize();209 Mockito.doReturn(true).when(mockStore2).canSplit();210 Mockito.doReturn(Bytes.toBytes("store 2 split"))211 .when(mockStore2).getSplitPoint();212 stores.put(new byte[]{2}, mockStore2);213 assertEquals("store 2 split",214 Bytes.toString(policy.getSplitPoint()));215 }216 @Test217 public void testDelimitedKeyPrefixRegionSplitPolicy() throws IOException {218 HTableDescriptor myHtd = new HTableDescriptor();219 myHtd.setValue(HTableDescriptor.SPLIT_POLICY,220 DelimitedKeyPrefixRegionSplitPolicy.class.getName());221 myHtd.setValue(DelimitedKeyPrefixRegionSplitPolicy.DELIMITER_KEY, ",");222 HRegion myMockRegion = Mockito.mock(HRegion.class);223 Mockito.doReturn(myHtd).when(myMockRegion).getTableDesc();224 Mockito.doReturn(stores).when(myMockRegion).getStores();225 HStore mockStore = Mockito.mock(HStore.class);226 Mockito.doReturn(2000L).when(mockStore).getSize();227 Mockito.doReturn(true).when(mockStore).canSplit();228 Mockito.doReturn(Bytes.toBytes("ab,cd")).when(mockStore).getSplitPoint();229 stores.put(new byte[] { 1 }, mockStore);230 DelimitedKeyPrefixRegionSplitPolicy policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy231 .create(myMockRegion, conf);232 assertEquals("ab", Bytes.toString(policy.getSplitPoint()));233 Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();234 Mockito.doReturn(Bytes.toBytes("efg,h")).when(myMockRegion)235 .getExplicitSplitPoint();236 policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy237 .create(myMockRegion, conf);238 assertEquals("efg", Bytes.toString(policy.getSplitPoint()));239 Mockito.doReturn(Bytes.toBytes("ijk")).when(myMockRegion)240 .getExplicitSplitPoint();241 assertEquals("ijk", Bytes.toString(policy.getSplitPoint()));242 }243}...

Full Screen

Full Screen

Source:AttributeServiceTest.java Github

copy

Full Screen

...46 47 @Test48 public void testSaveForCreation() throws UserAuthorizationException, BadRequestException, UserAuthenticationException{49 DDUser user = new DDUser("name", true);50 Mockito.doReturn(0).when(attributeService).saveWithCreate(any(Attribute.class), any(DDUser.class));51 Mockito.doReturn(null).when(attribute).getId();52 53 attributeService.save(attribute, user);54 55 Mockito.verify(attributeService, times(1)).saveWithCreate(attribute, user);56 }57 58 @Test59 public void testSaveForUpdate() throws UserAuthorizationException, BadRequestException, UserAuthenticationException {60 DDUser user = new DDUser("name", true);61 Mockito.doReturn(0).when(attribute).getId();62 Mockito.doReturn(0).when(attributeService).saveWithUpdate(attribute, user);63 64 attributeService.save(attribute, user);65 66 Mockito.verify(attributeService, times(1)).saveWithUpdate(attribute, user);67 }68 69 @Test70 public void testSaveWithCreate() throws BadRequestException, UserAuthorizationException {71 DDUser user = new DDUser();72 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(user, AclEntity.ATTRIBUTE, Permission.INSERT);73 Mockito.doNothing().when(aclService).grantAccess(any(DDUser.class), any(AclEntity.class), anyString(), anyString());74 Mockito.doNothing().when(attributeService).validateMandatoryAttributeFields(any(Attribute.class));75 Mockito.doReturn(1).when(attributeDataService).createAttribute(any(Attribute.class));76 77 attributeService.saveWithCreate(attribute, user);78 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, Permission.INSERT);79 Mockito.verify(attributeService, times(1)).validateMandatoryAttributeFields(attribute);80 Mockito.verify(aclService, times(1)).grantAccess(any(DDUser.class), any(AclEntity.class), anyString(), anyString());81 Mockito.verify(attributeDataService, times(1)).createAttribute(attribute);82 }83 @Test84 public void testSaveWithUpdate() throws BadRequestException, UserAuthorizationException {85 DDUser user = new DDUser();86 87 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));88 Mockito.doNothing().when(attributeService).validateMandatoryAttributeFields(attribute);89 Mockito.doNothing().when(attributeDataService).updateAttribute(attribute);90 Mockito.doReturn(1).when(attribute).getId();91 Mockito.doNothing().when(attributeService).removeIncompatibleOldValues(attribute);92 93 attributeService.saveWithUpdate(attribute, user);94 95 Mockito.verify(aclService).hasPermission(user, AclEntity.ATTRIBUTE, "s1", Permission.UPDATE);96 Mockito.verify(attributeService).validateMandatoryAttributeFields(attribute);97 Mockito.verify(attributeDataService).updateAttribute(attribute);98 }99 100 @Test(expected = UserAuthenticationException.class)101 public void testSaveNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException, BadRequestException {102 attributeService.save(attribute, null);103 }104 105 @Test(expected = UserAuthorizationException.class)106 public void testSaveCreateNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException, BadRequestException {107 DDUser user = new DDUser();108 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), any(Permission.class));109 Mockito.doReturn(null).when(attribute).getId();110 attributeService.save(attribute, user);111 } 112 113 @Test(expected = UserAuthorizationException.class)114 public void testSaveUpdateNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException, BadRequestException {115 DDUser user = new DDUser();116 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));117 Mockito.doReturn(1).when(attribute).getId();118 attributeService.save(attribute, user);119 }120 121 @Test(expected = BadRequestException.class)122 public void testSaveCreateMandatoryFieldMissing() throws UserAuthenticationException, UserAuthorizationException, BadRequestException {123 DDUser user = new DDUser();124 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), any(Permission.class));125 Mockito.doReturn(null).when(attribute).getId();126 attributeService.save(attribute, user);127 }128 129 @Test(expected = BadRequestException.class)130 public void testSaveUpdateMandatoryFieldMissing() throws UserAuthenticationException, UserAuthorizationException, BadRequestException {131 DDUser user = new DDUser();132 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));133 Mockito.doReturn(1).when(attribute).getId();134 attributeService.save(attribute, user);135 }136 137 @Test138 public void testValidateMandatoryFields() throws BadRequestException {139 Mockito.doReturn("shortName").when(attribute).getShortName();140 Mockito.doReturn("name").when(attribute).getName();141 Mockito.doReturn(namespace).when(attribute).getNamespace();142 Mockito.doReturn(1).when(namespace).getId();143 Mockito.doReturn(ObligationType.CONDITIONAL).when(attribute).getObligationType();144 attributeService.validateMandatoryAttributeFields(attribute);145 }146 147 @Test148 public void testDelete() throws UserAuthenticationException, UserAuthorizationException {149 DDUser user = new DDUser();150 Mockito.doReturn(Boolean.TRUE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));151 Mockito.doNothing().when(attributeDataService).deleteAttributeById(anyInt());152 Mockito.doNothing().when(aclService).removeAccessRightsForDeletedEntity(any(AclEntity.class), anyString());153 154 attributeService.delete(0, user);155 156 Mockito.verify(aclService, times(1)).hasPermission(user, AclEntity.ATTRIBUTE, "s0", Permission.DELETE);157 Mockito.verify(attributeDataService, times(1)).deleteAttributeById(0);158 Mockito.verify(aclService, times(1)).removeAccessRightsForDeletedEntity(AclEntity.ATTRIBUTE, "s0");159 }160 161 @Test(expected = UserAuthenticationException.class)162 public void testDeleteNotAuthenticatedUser() throws UserAuthenticationException, UserAuthorizationException {163 attributeService.delete(9, null);164 }165 166 @Test(expected = UserAuthorizationException.class)167 public void testDeleteNotAuthorizedUser() throws UserAuthenticationException, UserAuthorizationException {168 Mockito.doReturn(Boolean.FALSE).when(aclService).hasPermission(any(DDUser.class), any(AclEntity.class), anyString(), any(Permission.class));169 attributeService.delete(9, new DDUser());170 }171 172 @Test173 public void testgetAttributeAclId() {174 assertEquals("s1", attributeService.getAttributeAclId(1));175 }176}...

Full Screen

Full Screen

Source:RetryTemplateAspectTest.java Github

copy

Full Screen

...34 @Before35 public void setUp() {36 aspect = new RetryTemplateAspect();37 aspect.setBeanFactory(beanFactory);38 Mockito.doReturn("Signature").when(mockSignature).getName();39 Mockito.doReturn(TEST_RETRY_TEMPLATE).when(mockAnnotation).name();40 Mockito.doReturn(TEST_RETRY_TEMPLATE_RECOVERY).when(mockAnnotation).recoveryCallbackName();41 Mockito.doReturn("Target").when(mockPjp).getTarget();42 Mockito.doReturn(mockSignature).when(mockPjp).getSignature();43 }44 @Test(expected = NoSuchBeanDefinitionException.class)45 public void testRetryWithMissingBean() throws Throwable {46 Mockito.doThrow(new NoSuchBeanDefinitionException("")).when(beanFactory)47 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);48 try {49 aspect.retry(mockPjp, mockAnnotation);50 }51 finally {52 Mockito.verify(mockPjp, Mockito.never()).proceed();53 }54 }55 @Test(expected = BeanNotOfRequiredTypeException.class)56 public void testRetryWithWrongBeanType() throws Throwable {57 Mockito.doThrow(new BeanNotOfRequiredTypeException("", String.class, String.class)).when(beanFactory)58 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);59 try {60 aspect.retry(mockPjp, mockAnnotation);61 }62 finally {63 Mockito.verify(mockPjp, Mockito.never()).proceed();64 }65 }66 @Test67 public void testRetry() throws Throwable {68 org.springframework.retry.support.RetryTemplate template =69 new org.springframework.retry.support.RetryTemplate();70 Mockito.doReturn(template).when(beanFactory)71 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);72 Mockito.doReturn("a").when(mockPjp).proceed();73 Assert.assertEquals("a", aspect.retry(mockPjp, mockAnnotation));74 Mockito.verify(mockPjp, Mockito.times(1)).proceed();75 }76 @Test77 public void testRetryExceptionWithRecovery() throws Throwable {78 Mockito.doReturn(TEST_RETRY_TEMPLATE_RECOVERY).when(mockAnnotation).recoveryCallbackName();79 org.springframework.retry.support.RetryTemplate template =80 new org.springframework.retry.support.RetryTemplate();81 Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();82 exceptionMap.put(RuntimeException.class, Boolean.TRUE);83 template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));84 Mockito.doReturn(template).when(beanFactory)85 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);86 Mockito.doReturn(recoveryCallback).when(beanFactory)87 .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);88 Mockito.doThrow(new RuntimeException()).when(mockPjp).proceed();89 Mockito.doReturn("a").when(recoveryCallback).recover(Mockito.any(RetryContext.class));90 Assert.assertEquals("a", aspect.retry(mockPjp, mockAnnotation));91 Mockito.verify(mockPjp, Mockito.times(1)).proceed();92 }93 @Test(expected=RuntimeException.class)94 public void testRetryExceptionWithoutRecovery() throws Throwable {95 org.springframework.retry.support.RetryTemplate template =96 new org.springframework.retry.support.RetryTemplate();97 Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();98 exceptionMap.put(RuntimeException.class, Boolean.TRUE);99 template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));100 Mockito.doReturn(template).when(beanFactory)101 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);102 Mockito.doReturn(null).when(beanFactory)103 .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);104 Mockito.doThrow(new RuntimeException()).when(mockPjp).proceed();105 try {106 aspect.retry(mockPjp, mockAnnotation);107 }108 finally {109 Mockito.verify(mockPjp, Mockito.times(1)).proceed();110 }111 }112 @Test(expected=OutOfMemoryError.class)113 public void testRetryErrorWithoutRecovery() throws Throwable {114 org.springframework.retry.support.RetryTemplate template =115 new org.springframework.retry.support.RetryTemplate();116 Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();117 exceptionMap.put(RuntimeException.class, Boolean.TRUE);118 template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));119 Mockito.doReturn(template).when(beanFactory)120 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);121 Mockito.doReturn(null).when(beanFactory)122 .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);123 Mockito.doThrow(new OutOfMemoryError()).when(mockPjp).proceed();124 try {125 aspect.retry(mockPjp, mockAnnotation);126 }127 finally {128 Mockito.verify(mockPjp, Mockito.times(1)).proceed();129 }130 }131 @Test(expected=RuntimeException.class)132 public void testRetryThrowableWithoutRecovery() throws Throwable {133 org.springframework.retry.support.RetryTemplate template =134 new org.springframework.retry.support.RetryTemplate();135 Map<Class<? extends Throwable>, Boolean> exceptionMap = new HashMap<Class<? extends Throwable>, Boolean>();136 exceptionMap.put(RuntimeException.class, Boolean.TRUE);137 template.setRetryPolicy(new SimpleRetryPolicy(1, exceptionMap));138 Mockito.doReturn(template).when(beanFactory)139 .getBean(TEST_RETRY_TEMPLATE, org.springframework.retry.support.RetryTemplate.class);140 Mockito.doReturn(null).when(beanFactory)141 .getBean(TEST_RETRY_TEMPLATE_RECOVERY, RecoveryCallback.class);142 Mockito.doThrow(new Throwable("")).when(mockPjp).proceed();143 try {144 aspect.retry(mockPjp, mockAnnotation);145 }146 finally {147 Mockito.verify(mockPjp, Mockito.times(1)).proceed();148 }149 }150}...

Full Screen

Full Screen

Source:AttributeDataServiceTestIT.java Github

copy

Full Screen

...52 }53 54 @Test55 public void testGetAttributeWithNoVocabulary() throws ResourceNotFoundException {56 Mockito.doReturn(attribute).when(attributeDao).getById(anyInt());57 Mockito.doReturn(null).when(attribute).getVocabulary();58 assertNotNull(attributeDataService.getAttribute(0));59 Mockito.verify(attributeDao, times(1)).getById(0);60 }61 62 @Test63 public void testGetAttributeWithVocabulary() throws ResourceNotFoundException {64 Mockito.doReturn(attribute).when(attributeDao).getById(anyInt());65 Mockito.doReturn(vocabulary).when(attribute).getVocabulary();66 Mockito.doReturn(vocabulary).when(vocabularyDao).getPlainVocabularyById(anyInt());67 Mockito.doNothing().when(attribute).setVocabulary(any(VocabularyFolder.class));68 assertNotNull(attributeDataService.getAttribute(0));69 Mockito.verify(attributeDao).getById(0);70 Mockito.verify(vocabularyDao).getPlainVocabularyById(0);71 Mockito.verify(attribute).setVocabulary(vocabulary);72 }73 74 @Test(expected = ResourceNotFoundException.class)75 public void testGetAttributeNotFound() throws ResourceNotFoundException{76 Mockito.doReturn(null).when(attributeDao).getById(0);77 attributeDataService.getAttribute(0);78 }79 @Test80 public void testExists() {81 Mockito.doReturn(Boolean.TRUE).when(attributeDao).exists(anyInt());82 attributeDataService.existsAttribute(0);83 Mockito.verify(attributeDao, times(1)).exists(0);84 }85 @Test86 public void testGetAllAttributes() {87 attributeDataService.getAllAttributes();88 Mockito.verify(attributeDao, times(1)).getAll();89 }90 @Test91 public void testCreateAttribute() {92 Mockito.doReturn(1).when(attributeDao).create(attribute);93 attributeDataService.createAttribute(attribute);94 Mockito.verify(attributeDao, times(1)).create(attribute);95 }96 97 @Test98 public void testUpdateAttributeWithNullVocabulary() {99 Mockito.doNothing().when(attributeDao).update(attribute);100 Mockito.doReturn(null).when(attribute).getVocabulary();101 Mockito.doNothing().when(attributeDao).deleteVocabularyBinding(anyInt());102 Mockito.doReturn(0).when(attribute).getId();103 attributeDataService.updateAttribute(attribute);104 Mockito.verify(attributeDao, times(1)).update(attribute);105 Mockito.verify(attributeDao, times(1)).deleteVocabularyBinding(0);106 }107 108 @Test109 public void testUpdateAttributeWithVocabulary() {110 Mockito.doNothing().when(attributeDao).update(attribute);111 Mockito.doReturn(vocabulary).when(attribute).getVocabulary();112 Mockito.doNothing().when(attributeDao).updateVocabularyBinding(anyInt(), anyInt());113 Mockito.doReturn(0).when(attribute).getId();114 Mockito.doReturn(0).when(vocabulary).getId();115 116 attributeDataService.updateAttribute(attribute);117 118 Mockito.verify(attributeDao, times(1)).update(attribute);119 Mockito.verify(attributeDao, times(1)).updateVocabularyBinding(0, 0);120 }121 122 @Test123 public void testDeleteAttributeById() {124 Mockito.doNothing().when(attributeDao).deleteValues(0);125 Mockito.doNothing().when(attributeDao).deleteVocabularyBinding(0);126 Mockito.doNothing().when(attributeDao).delete(0);127 Mockito.doNothing().when(fixedValueDao).deleteAll(FixedValue.OwnerType.ATTRIBUTE, 0);128 attributeDataService.deleteAttributeById(0);129 Mockito.verify(attributeDao, times(1)).deleteValues(0);130 Mockito.verify(attributeDao, times(1)).deleteVocabularyBinding(0);131 Mockito.verify(attributeDao, times(1)).delete(0);132 Mockito.verify(fixedValueDao, times(1)).deleteAll(FixedValue.OwnerType.ATTRIBUTE, 0);133 }134 135 @Test136 public void testCountAttributeValues() {137 Mockito.doReturn(2).when(attributeDao).countAttributeValues(0);138 attributeDataService.countAttributeValues(0);139 Mockito.verify(attributeDao, times(1)).countAttributeValues(0);140 }141 142 @Test143 public void testSetNewVocabularyToAttributeObject() throws ResourceNotFoundException {144 Mockito.doNothing().when(attribute).setVocabulary(any(VocabularyFolder.class));145 Mockito.doReturn(vocabulary).when(vocabularyDao).getPlainVocabularyById(0);146 attributeDataService.setNewVocabularyToAttributeObject(attribute, 0);147 Mockito.verify(attribute).setVocabulary(vocabulary);148 }149 150 @Test151 public void testDeleteVocabularyBInding() {152 Mockito.doNothing().when(attributeDao).deleteVocabularyBinding(0);153 attributeDataService.deleteVocabularyBinding(0);154 Mockito.verify(attributeDao, times(1)).deleteVocabularyBinding(0);155 }156 157 @Test158 public void testDeleteRelatedFixedValues() {159 Mockito.doNothing().when(fixedValueDao).deleteAll(FixedValue.OwnerType.ATTRIBUTE, 0);160 attributeDataService.deleteRelatedFixedValues(0);161 Mockito.verify(fixedValueDao).deleteAll(FixedValue.OwnerType.ATTRIBUTE, 0);162 }163 164 @Test165 public void testFixedValues() {166 Mockito.doReturn(new ArrayList<FixedValue>()).when(fixedValueDao).getValueByOwner(FixedValue.OwnerType.ATTRIBUTE, 0);167 attributeDataService.getFixedValues(0);168 Mockito.verify(fixedValueDao, times(1)).getValueByOwner(FixedValue.OwnerType.ATTRIBUTE, 0);169 }170 171 @Test172 public void testDeleteAllAttributeValues() {173 Mockito.doNothing().when(attributeValueDao).deleteAllAttributeValues(anyInt());174 Mockito.doNothing().when(attributeValueDao).deleteAllAttributeValues(anyInt(), any(DataDictEntity.class));175 176 attributeDataService.deleteAllAttributeValues(0);177 Mockito.verify(attributeValueDao, times(1)).deleteAllAttributeValues(0); 178 attributeDataService.deleteAllAttributeValues(anyInt(), new DataDictEntity(anyInt(), DataDictEntity.Entity.DS));179 Mockito.verify(attributeValueDao, times(1)).deleteAllAttributeValues(anyInt(), any(DataDictEntity.class));180 }...

Full Screen

Full Screen

Source:TestMasterStatusServlet.java Github

copy

Full Screen

...61 @Before62 public void setupBasicMocks() {63 conf = HBaseConfiguration.create();64 master = Mockito.mock(HMaster.class);65 Mockito.doReturn(FAKE_HOST).when(master).getServerName();66 Mockito.doReturn(conf).when(master).getConfiguration();67 //Fake DeadServer68 DeadServer deadServer = Mockito.mock(DeadServer.class);69 // Fake serverManager70 ServerManager serverManager = Mockito.mock(ServerManager.class);71 Mockito.doReturn(1.0).when(serverManager).getAverageLoad();72 Mockito.doReturn(serverManager).when(master).getServerManager();73 Mockito.doReturn(deadServer).when(serverManager).getDeadServers();74 // Fake AssignmentManager and RIT75 AssignmentManager am = Mockito.mock(AssignmentManager.class);76 RegionStates rs = Mockito.mock(RegionStates.class);77 NavigableMap<String, RegionState> regionsInTransition =78 Maps.newTreeMap();79 regionsInTransition.put("r1",80 new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L, FAKE_HOST));81 Mockito.doReturn(rs).when(am).getRegionStates();82 Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();83 Mockito.doReturn(am).when(master).getAssignmentManager();84 Mockito.doReturn(serverManager).when(master).getServerManager();85 // Fake ZKW86 ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);87 Mockito.doReturn("fakequorum").when(zkw).getQuorum();88 Mockito.doReturn(zkw).when(master).getZooKeeper();89 // Fake MasterAddressTracker90 MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);91 Mockito.doReturn(tracker).when(master).getMasterAddressTracker();92 Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();93 MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);94 Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();95 Mockito.doReturn(rms).when(master).getRegionServerMetrics();96 // Mock admin97 admin = Mockito.mock(HBaseAdmin.class); 98 }99 private void setupMockTables() throws IOException {100 HTableDescriptor tables[] = new HTableDescriptor[] {101 new HTableDescriptor(TableName.valueOf("foo")),102 new HTableDescriptor(TableName.valueOf("bar"))103 };104 Mockito.doReturn(tables).when(admin).listTables();105 }106 107 @Test108 public void testStatusTemplateNoTables() throws IOException {109 new MasterStatusTmpl().render(new StringWriter(),110 master, admin);111 }112 @Test113 public void testStatusTemplateMetaAvailable() throws IOException {114 setupMockTables();115 116 new MasterStatusTmpl()117 .setMetaLocation(ServerName.valueOf("metaserver:123,12345"))118 .render(new StringWriter(),119 master, admin);120 }121 @Test122 public void testStatusTemplateWithServers() throws IOException {123 setupMockTables();124 125 List<ServerName> servers = Lists.newArrayList(126 ServerName.valueOf("rootserver:123,12345"),127 ServerName.valueOf("metaserver:123,12345"));128 Set<ServerName> deadServers = new HashSet<ServerName>(129 Lists.newArrayList(130 ServerName.valueOf("badserver:123,12345"),131 ServerName.valueOf("uglyserver:123,12345"))132 );133 new MasterStatusTmpl()134 .setMetaLocation(ServerName.valueOf("metaserver:123,12345"))135 .setServers(servers)136 .setDeadServers(deadServers)137 .render(new StringWriter(),138 master, admin);139 }140 141 @Test142 public void testAssignmentManagerTruncatedList() throws IOException {143 AssignmentManager am = Mockito.mock(AssignmentManager.class);144 RegionStates rs = Mockito.mock(RegionStates.class);145 // Add 100 regions as in-transition146 NavigableMap<String, RegionState> regionsInTransition =147 Maps.newTreeMap();148 for (byte i = 0; i < 100; i++) {149 HRegionInfo hri = new HRegionInfo(FAKE_TABLE.getTableName(),150 new byte[]{i}, new byte[]{(byte) (i+1)});151 regionsInTransition.put(hri.getEncodedName(),152 new RegionState(hri, RegionState.State.CLOSING, 12345L, FAKE_HOST));153 }154 // Add hbase:meta in transition as well155 regionsInTransition.put(156 HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(),157 new RegionState(HRegionInfo.FIRST_META_REGIONINFO,158 RegionState.State.CLOSING, 12345L, FAKE_HOST));159 Mockito.doReturn(rs).when(am).getRegionStates();160 Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();161 // Render to a string162 StringWriter sw = new StringWriter();163 new AssignmentManagerStatusTmpl()164 .setLimit(50)165 .render(sw, am);166 String result = sw.toString();167 // Should always include META168 assertTrue(result.contains(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()));169 170 // Make sure we only see 50 of them171 Matcher matcher = Pattern.compile("CLOSING").matcher(result);172 int count = 0;173 while (matcher.find()) {174 count++;...

Full Screen

Full Screen

Source:ParseTests.java Github

copy

Full Screen

...24import static junit.framework.Assert.assertTrue;25import static org.mockito.ArgumentMatchers.any;26import static org.mockito.ArgumentMatchers.anyLong;27import static org.mockito.Mockito.doAnswer;28import static org.mockito.Mockito.doReturn;29import static org.mockito.Mockito.doThrow;30@RunWith(RobolectricTestRunner.class)31@Config(constants = BuildConfig.class, sdk = 23)32public class ParseTests {33 private final PInterface parseInterface = PInterface.INST;34 @SuppressWarnings({"unchecked", "rawtypes"})35 @Test36 public void testParseProxyCancelQueryCalled() throws InterruptedException {37 ParseQuery<ParseObject> query = Mockito.mock(ParseQuery.class);38 doAnswer(new Answer() {39 @Override40 public Object answer(InvocationOnMock invocation) throws InterruptedException {41 Thread.sleep(1000);42 return null;43 }44 }).doAnswer(new Answer() {45 @Override46 public Object answer(InvocationOnMock invocation) throws InterruptedException {47 Thread.sleep(1000);48 return null;49 }50 }).when(query).findInBackground(any(FindCallback.class));51 TimeoutQuery<ParseObject> toQuery = new TimeoutQuery(query, 10);52 toQuery.findInBackground(new FindCallback<ParseObject>() {53 @Override54 public void done(List<ParseObject> objects, ParseException e) {55 throw new IllegalStateException("Shouldn't have been called");56 }57 });58 Thread.sleep(3000);59 // we cannot check that cancelQuery was called, but only that the first query failed.60 assertTrue(toQuery.firstQueryFailed());61 }62 @SuppressWarnings({"unchecked", "rawtypes"})63 @Test (expected = ParseException.class)64 public void testFindQuery2ndFailure() throws InterruptedException, ParseException {65 ParseQuery<ParseObject> query = Mockito.mock(ParseQuery.class);66 Task<List<ParseObject>> mockTask = Mockito.mock(Task.class);67 doReturn(false).when(mockTask).isCompleted();68 doReturn(false).when(mockTask).isFaulted();69 doReturn(mockTask).when(query).findInBackground();70 parseInterface.getProxy().executeFindQuery(query);71 }72 @SuppressWarnings({"rawtypes", "unchecked"})73 @Test74 public void findQueryThrowsParseException() {75 ParseQuery<ParseObject> query = Mockito.mock(ParseQuery.class);76 Task<List<ParseObject>> mockTask = Mockito.mock(Task.class);77 doReturn(mockTask).when(query).findInBackground();78 doReturn(false).when(mockTask).isCompleted();79 doReturn(true).when(mockTask).isFaulted();80 Throwable exception = new Throwable("Parse Exception from mock task!");81 //noinspection ThrowableResultOfMethodCallIgnored82 doReturn(new ParseException(exception)).when(mockTask).getError();83 try {84 parseInterface.getProxy().executeFindQuery(query);85 } catch (ParseException e) {86 assertEquals(exception.toString(), e.getMessage());87 }88 }89 @SuppressWarnings({"rawtypes", "unchecked"})90 @Test91 public void findQueryThrowsAnyException() {92 ParseQuery<ParseObject> query = Mockito.mock(ParseQuery.class);93 Task<List<ParseObject>> mockTask = Mockito.mock(Task.class);94 doReturn(mockTask).when(query).findInBackground();95 doReturn(false).when(mockTask).isCompleted();96 doReturn(true).when(mockTask).isFaulted();97 Exception exception = new IllegalStateException("Parse Exception from mock task!");98 //noinspection ThrowableResultOfMethodCallIgnored99 doReturn(exception).when(mockTask).getError();100 try {101 parseInterface.getProxy().executeFindQuery(query);102 } catch (ParseException e) {103 assertEquals(exception.toString(), e.getMessage());104 }105 }106 @SuppressWarnings({"rawtypes", "unchecked"})107 @Test108 public void findQueryReturnsEmptyOnError() throws InterruptedException, ParseException {109 ParseQuery<ParseObject> query = Mockito.mock(ParseQuery.class);110 Task<List<ParseObject>> mockTask = Mockito.mock(Task.class);111 doThrow(new InterruptedException("Interrupted Exception from Mock task!"))112 .when(mockTask).waitForCompletion(anyLong(), any(TimeUnit.class));113 doReturn(mockTask).when(query).findInBackground();114 assertEquals(Collections.emptyList(), parseInterface.getProxy().executeFindQuery(query));115 }116 @Test117 public void parseInitialiserEnum() {118 assertEquals(ParseInitialiser.INSTANCE, ParseInitialiser.valueOf("INSTANCE"));119 assertEquals(ParseInitialiser.values().length, ParseInitialiser.values().length);120 }121}...

Full Screen

Full Screen

Source:AbsSellPriceStrategyTest.java Github

copy

Full Screen

...14 public void update_price_1_limit_false() throws Exception {15 AbsSellPriceStrategy absSellPriceStrategy = PowerMockito.mock(AbsSellPriceStrategy.class);16 Item item = new Item("test", 2, 10);17 PowerMockito.doCallRealMethod().when(absSellPriceStrategy, "update", item);18 PowerMockito.doReturn(1).when(absSellPriceStrategy, "getPriceChangeCount", Mockito.anyInt());19 PowerMockito.doReturn(false).when(absSellPriceStrategy, "needLimitPrice");20 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getChangeSellDeadline");21 absSellPriceStrategy.update(item);22 Assert.assertEquals(11, item.price);23 }24 @Test25 public void update_price_2_limit_false() throws Exception {26 AbsSellPriceStrategy absSellPriceStrategy = PowerMockito.mock(AbsSellPriceStrategy.class);27 Item item = new Item("test", 2, 10);28 PowerMockito.doCallRealMethod().when(absSellPriceStrategy, "update", item);29 PowerMockito.doReturn(2).when(absSellPriceStrategy, "getPriceChangeCount", Mockito.anyInt());30 PowerMockito.doReturn(false).when(absSellPriceStrategy, "needLimitPrice");31 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getChangeSellDeadline");32 absSellPriceStrategy.update(item);33 Assert.assertEquals(12, item.price);34 }35 @Test36 public void update_price_n1_limit_false() throws Exception {37 AbsSellPriceStrategy absSellPriceStrategy = PowerMockito.mock(AbsSellPriceStrategy.class);38 Item item = new Item("test", 2, 10);39 PowerMockito.doCallRealMethod().when(absSellPriceStrategy, "update", item);40 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getPriceChangeCount", Mockito.anyInt());41 PowerMockito.doReturn(false).when(absSellPriceStrategy, "needLimitPrice");42 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getChangeSellDeadline");43 absSellPriceStrategy.update(item);44 Assert.assertEquals(9, item.price);45 }46 @Test47 public void update_price_limit_true() throws Exception {48 AbsSellPriceStrategy absSellPriceStrategy = PowerMockito.mock(AbsSellPriceStrategy.class);49 Item item = new Item("test", 2, 50);50 PowerMockito.doCallRealMethod().when(absSellPriceStrategy, "update", item);51 PowerMockito.doReturn(1).when(absSellPriceStrategy, "getPriceChangeCount", Mockito.anyInt());52 PowerMockito.doReturn(true).when(absSellPriceStrategy, "needLimitPrice");53 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getChangeSellDeadline");54 PowerMockito.doReturn(50).when(absSellPriceStrategy, "getMaxPrice");55 absSellPriceStrategy.update(item);56 Assert.assertEquals(50, item.price);57 }58 @Test59 public void update_price_limit_min_true() throws Exception {60 AbsSellPriceStrategy absSellPriceStrategy = PowerMockito.mock(AbsSellPriceStrategy.class);61 Item item = new Item("test", 2, 0);62 PowerMockito.doCallRealMethod().when(absSellPriceStrategy, "update", item);63 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getPriceChangeCount", Mockito.anyInt());64 PowerMockito.doReturn(true).when(absSellPriceStrategy, "needLimitPrice");65 PowerMockito.doReturn(-1).when(absSellPriceStrategy, "getChangeSellDeadline");66 PowerMockito.doReturn(0).when(absSellPriceStrategy, "getMinPrice");67 absSellPriceStrategy.update(item);68 Assert.assertEquals(0, item.price);69 }70}...

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1import org.mockito.Mockito;2import org.mockito.stubbing.OngoingStubbing;3import org.mockito.stubbing.Stubber;4import org.mockito.invocation.InvocationOnMock;5import org.mockito.stubbing.Answer;6import org.mockito.stubbing.Stubber;7import org.mockito.stubbing.Stubber;8import org.mockito.stubbing.Stubber;9public class MockitoDoReturn {10 public static void main(String[] args) {11 List mockedList = Mockito.mock(List.class);12 Mockito.doReturn("first").when(mockedList).get(0);13 Mockito.doReturn("second").when(mockedList).get(1);14 System.out.println(mockedList.get(0));15 System.out.println(mockedList.get(1));16 System.out.println(mockedList.get(999));17 }18}

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1import org.mockito.Mockito;2import org.mockito.stubbing.OngoingStubbing;3import org.mockito.stubbing.Stubber;4import org.mockito.invocation.InvocationOnMock;5import org.mockito.stubbing.Answer;6import org.mockito.stubbing.OngoingStubbing;7import org.mockito.stubbing.Stubber;8import org.mockito.invocation.InvocationOnMock;9import org.mockito.stubbing.Answer;10import org.mockito.stubbing.OngoingStubbing;11import org.mockito.stubbing.Stubber;12import org.mockito.invocation.InvocationOnMock;13import org.mockito.stubbing.Answer;14import org.mockito.stubbing.OngoingStubbing;15import org.mockito.stubbing.Stubber;16import org.mockito.invocation.InvocationOnMock;17import org.mockito.stubbing.Answer;18import org.mockito.stubbing.OngoingStubbing;19import org.mockito.stubbing.Stubber;20import org.mockito.invocation.InvocationOnMock;21import org.mockito.stubbing.Answer;22import org.mockito.stubbing.OngoingStubbing;23import org.mockito.stubbing.Stubber;24import org.mockito.invocation.InvocationOnMock;25import org.mockito.stubbing.Answer;26import org.mockito.stubbing.OngoingStubbing;27import org.mockito.stubbing.Stubber;28import org.mockito.invocation.InvocationOnMock;29import org.mockito.stubbing.Answer;30import org.mockito.stubbing.OngoingStubbing;31import org.mockito.stubbing.Stubber;32import org.mockito.invocation.InvocationOnMock;33import org.mockito.stubbing.Answer;34import org.mockito.stubbing.OngoingStubbing;35import org.mockito.stubbing.Stubber;36import org.mockito.invocation.InvocationOnMock;37import org.mockito.stubbing.Answer;38import org.mockito.stubbing.OngoingStubbing;39import org.mockito.stubbing.Stubber;40import org.mockito.invocation.InvocationOnMock;41import org.mockito.stubbing.Answer;42import org.mockito.stubbing.OngoingStubbing;43import org.mockito.stubbing.Stubber;44import org.mockito.invocation.InvocationOnMock;45import org.mockito.stubbing.Answer;46import org.mockito.stubbing.OngoingStubbing;47import org.mockito.stubbing.Stubber;48import org.mockito.invocation.InvocationOnMock;49import org.mockito.stubbing.Answer;50import org.mockito.stubbing.OngoingStubbing;51import org.mockito.stubbing.Stubber;52import org.mockito.invocation.InvocationOnMock;53import org.mockito.stubbing.Answer;54import org.mockito.stubbing.OngoingStubbing;55import org.mockito.stubbing.Stubber;56import org.mockito.invocation.Invocation

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1package com.ack.j2se.mockito;2import java.util.List;3import org.junit.Test;4import static org.mockito.Mockito.*;5public class DoReturnTest {6 public void testDoReturn() {7 List mockedList = mock( List.class );8 doReturn( "foo" ).when( mockedList ).get( 0 );9 System.out.println( mockedList.get( 0 ) );10 System.out.println( mockedList.get( 1 ) );11 }12}

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1import static org.mockito.Mockito.*;2public class MockitoTest {3 public static void main(String[] args) {4 List<String> mockedList = mock(List.class);5 when(mockedList.get(0)).thenReturn("first");6 when(mockedList.get(1)).thenThrow(new RuntimeException());7 System.out.println(mockedList.get(0));8 System.out.println(mockedList.get(1));9 System.out.println(mockedList.get(999));10 }11}12 at org.mockito.Mockito.when(Mockito.java:1188)13 at org.mockito.Mockito.when(Mockito.java:1126)14 at MockitoTest.main(MockitoTest.java:10)15The doThrow() method of the Mockito class is used to configure the mock object to throw an exception when a method is called on the mock object. The doThrow() method is used when the method is void. The doThrow() method returns a stubber object. The

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1package com.ack.j2se.mock;2import java.util.List;3import org.junit.Test;4import org.mockito.Mockito;5public class MockitoDoReturnTest {6 public void testDoReturn() {7 List mockedList = Mockito.mock( List.class );8 Mockito.doReturn( "Hello World" ).when( mockedList ).get( 0 );9 System.out.println( mockedList.get( 0 ) );10 }11}

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1import org.mockito.Mockito;2import org.mockito.Mockito.*;3import org.mockito.MockitoAnnotations;4import org.mockito.Mock;5import org.mockito.InjectMocks;6import org.mockito.runners.MockitoJUnitRunner;7import org.junit.runner.RunWith;8import org.junit.Before;9import org.junit.Test;10import static org.mockito.Mockito.*;11import static org.junit.Assert.*;12@RunWith(MockitoJUnitRunner.class)13public class Test1 {14 private List mockList;15 private Test1 test1;16 public void setUp() {17 MockitoAnnotations.initMocks(this);18 }19 public void test() {20 when(mockList.get(0)).thenReturn("Hello");21 assertEquals("Hello", mockList.get(0));22 }23}24import org.mockito.Mockito;25import org.mockito.Mockito.*;26import org.mockito.MockitoAnnotations;27import org.mockito.Mock;28import org.mockito.InjectMocks;29import org.mockito.runners.MockitoJUnitRunner;30import org.junit.runner.RunWith;31import org.junit.Before;32import org.junit.Test;33import static org.mockito.Mockito.*;34import static org.junit.Assert.*;35@RunWith(MockitoJUnitRunner.class)36public class Test2 {37 private List mockList;38 private Test2 test2;39 public void setUp() {40 MockitoAnnotations.initMocks(this);41 }42 public void test() {43 doReturn("Hello").when(mockList).get(0);44 assertEquals("Hello", mockList.get(0));45 }46}

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1import static org.mockito.Mockito.doReturn;2import static org.mockito.Mockito.mock;3import static org.mockito.Mockito.when;4import org.junit.Test;5public class Test1 {6 public void test1() {7 MyClass test = mock(MyClass.class);8 when(test.getUniqueId()).thenReturn(43);9 System.out.println(test.getUniqueId());10 }11}12class MyClass {13 public int getUniqueId() {14 return 0;15 }16}17The method doAnswer() is used to define the return value for a method call. In the above example, the method getUniqueId() returns an integer value. The doAnswer() method is used to define the return value for a method call. In the above example, the method getUniqueId() returns an integer value. The doAnswer() method is used to define the return value for a method call. In the above example, the method getUniqueId() returns an integer value. The doAnswer() method is used to define the return value for a method call. In the above example

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1import static org.mockito.Mockito.doReturn;2import org.junit.Test;3public class MockitoDoReturnTest {4 public void testDoReturn() {5 TestClass testClass = mock(TestClass.class);6 testClass.testMethod();7 doReturn("test").when(testClass).testMethod();8 testClass.testMethod();9 }10}11Mockito Mockito is a mocking framework that is used to write unit tests for Java classes. Mockito is used to mock the objects that are... Mockito - doThrow() Method Mockito doThrow() method is used to stub the method of the mock object to throw an exception. The doThrow method is used to stub the... Mockito - doAnswer() Method Mockito doAnswer() method is used to stub the method of the mock object to return the value returned by the Answer object. The... Mockito - doNothing() Method Mockito doNothing() method is used to stub the method of the mock object to do nothing. The doNothing method is used to stub the... Mockito - doCallRealMethod() Method Mockito doCallRealMethod() method is used to stub the method of the mock object to call the real method. The doCallRealMethod method... Mockito - doNothing() Method Mockito doNothing() method is used to stub the method of the mock object to do nothing. The doNothing method is used to stub the... Mockito - doCallRealMethod() Method Mockito doCallRealMethod() method is used to stub the method of the mock object to call the real method. The doCallRealMethod method... Mockito - doAnswer() Method Mockito doAnswer() method is used to stub the method of the mock object to return the value returned by the Answer object. The... Mockito - doThrow() Method Mockito doThrow() method is used to stub the method of the mock object to throw an exception. The doThrow method is used to stub the... Mockito - doReturn() Method Mockito doReturn() method is used to stub the method of the mock object to return the value passed to

Full Screen

Full Screen

doReturn

Using AI Code Generation

copy

Full Screen

1package com.mockitotest;2import static org.mockito.Mockito.*;3import org.junit.Test;4public class TestClass {5public void test1(){6TestClass1 tc = mock(TestClass1.class);7when(tc.method1()).thenReturn("Hello");8TestClass2 tc2 = new TestClass2();9String result = tc2.method2(tc);10System.out.println(result);11}12}13package com.mockitotest;14public class TestClass2 {15public String method2(TestClass1 tc){16return tc.method1();17}18}19package com.mockitotest;20public class TestClass1 {21public String method1(){22return "Hello";23}24}

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