Best Mockito code snippet using org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.handle
Source:InlineDelegateByteBuddyMockMakerTest.java
...31import org.mockito.Answers;32import org.mockito.exceptions.base.MockitoException;33import org.mockito.internal.creation.MockSettingsImpl;34import org.mockito.internal.creation.settings.CreationSettings;35import org.mockito.internal.handler.MockHandlerImpl;36import org.mockito.internal.stubbing.answers.Returns;37import org.mockito.internal.util.collections.Sets;38import org.mockito.mock.MockCreationSettings;39import org.mockito.mock.SerializableMode;40import org.mockito.plugins.MockMaker;41public class InlineDelegateByteBuddyMockMakerTest42 extends AbstractByteBuddyMockMakerTest<InlineByteBuddyMockMaker> {43 public InlineDelegateByteBuddyMockMakerTest() {44 super(new InlineByteBuddyMockMaker());45 }46 @Override47 protected Class<?> mockTypeOf(Class<?> type) {48 return type;49 }50 @Test51 public void should_create_mock_from_final_class() throws Exception {52 MockCreationSettings<FinalClass> settings = settingsFor(FinalClass.class);53 FinalClass proxy =54 mockMaker.createMock(settings, new MockHandlerImpl<FinalClass>(settings));55 assertThat(proxy.foo()).isEqualTo("bar");56 }57 @Test58 public void should_create_mock_from_final_spy() throws Exception {59 MockCreationSettings<FinalSpy> settings = settingsFor(FinalSpy.class);60 Optional<FinalSpy> proxy =61 mockMaker.createSpy(62 settings,63 new MockHandlerImpl<>(settings),64 new FinalSpy("value", true, (byte) 1, (short) 1, (char) 1, 1, 1L, 1f, 1d));65 assertThat(proxy)66 .hasValueSatisfying(67 spy -> {68 assertThat(spy.aString).isEqualTo("value");69 assertThat(spy.aBoolean).isTrue();70 assertThat(spy.aByte).isEqualTo((byte) 1);71 assertThat(spy.aShort).isEqualTo((short) 1);72 assertThat(spy.aChar).isEqualTo((char) 1);73 assertThat(spy.anInt).isEqualTo(1);74 assertThat(spy.aLong).isEqualTo(1L);75 assertThat(spy.aFloat).isEqualTo(1f);76 assertThat(spy.aDouble).isEqualTo(1d);77 });78 }79 @Test80 public void should_create_mock_from_non_constructable_class() throws Exception {81 MockCreationSettings<NonConstructableClass> settings =82 settingsFor(NonConstructableClass.class);83 NonConstructableClass proxy =84 mockMaker.createMock(85 settings, new MockHandlerImpl<NonConstructableClass>(settings));86 assertThat(proxy.foo()).isEqualTo("bar");87 }88 @Test89 public void should_create_mock_from_final_class_in_the_JDK() throws Exception {90 MockCreationSettings<Pattern> settings = settingsFor(Pattern.class);91 Pattern proxy = mockMaker.createMock(settings, new MockHandlerImpl<Pattern>(settings));92 assertThat(proxy.pattern()).isEqualTo("bar");93 }94 @Test95 public void should_create_mock_from_abstract_class_with_final_method() throws Exception {96 MockCreationSettings<FinalMethodAbstractType> settings =97 settingsFor(FinalMethodAbstractType.class);98 FinalMethodAbstractType proxy =99 mockMaker.createMock(100 settings, new MockHandlerImpl<FinalMethodAbstractType>(settings));101 assertThat(proxy.foo()).isEqualTo("bar");102 assertThat(proxy.bar()).isEqualTo("bar");103 }104 @Test105 public void should_create_mock_from_final_class_with_interface_methods() throws Exception {106 MockCreationSettings<FinalMethod> settings =107 settingsFor(FinalMethod.class, SampleInterface.class);108 FinalMethod proxy =109 mockMaker.createMock(settings, new MockHandlerImpl<FinalMethod>(settings));110 assertThat(proxy.foo()).isEqualTo("bar");111 assertThat(((SampleInterface) proxy).bar()).isEqualTo("bar");112 }113 @Test114 public void should_detect_non_overridden_generic_method_of_supertype() throws Exception {115 MockCreationSettings<GenericSubClass> settings = settingsFor(GenericSubClass.class);116 GenericSubClass proxy =117 mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));118 assertThat(proxy.value()).isEqualTo("bar");119 }120 @Test121 public void should_create_mock_from_hashmap() throws Exception {122 MockCreationSettings<HashMap> settings = settingsFor(HashMap.class);123 HashMap proxy = mockMaker.createMock(settings, new MockHandlerImpl<HashMap>(settings));124 assertThat(proxy.get(null)).isEqualTo("bar");125 }126 @Test127 @SuppressWarnings("unchecked")128 public void should_throw_exception_redefining_unmodifiable_class() {129 MockCreationSettings settings = settingsFor(int.class);130 try {131 mockMaker.createMock(settings, new MockHandlerImpl(settings));132 fail("Expected a MockitoException");133 } catch (MockitoException e) {134 e.printStackTrace();135 assertThat(e).hasMessageContaining("Could not modify all classes");136 }137 }138 @Test139 @SuppressWarnings("unchecked")140 public void should_throw_exception_redefining_array() {141 int[] array = new int[5];142 MockCreationSettings<? extends int[]> settings = settingsFor(array.getClass());143 try {144 mockMaker.createMock(settings, new MockHandlerImpl(settings));145 fail("Expected a MockitoException");146 } catch (MockitoException e) {147 assertThat(e).hasMessageContaining("Arrays cannot be mocked");148 }149 }150 @Test151 public void should_create_mock_from_enum() throws Exception {152 MockCreationSettings<EnumClass> settings = settingsFor(EnumClass.class);153 EnumClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<EnumClass>(settings));154 assertThat(proxy.foo()).isEqualTo("bar");155 }156 @Test157 public void should_fail_at_creating_a_mock_of_a_final_class_with_explicit_serialization()158 throws Exception {159 MockCreationSettings<FinalClass> settings =160 new CreationSettings<FinalClass>()161 .setTypeToMock(FinalClass.class)162 .setSerializableMode(SerializableMode.BASIC);163 try {164 mockMaker.createMock(settings, new MockHandlerImpl<FinalClass>(settings));165 fail("Expected a MockitoException");166 } catch (MockitoException e) {167 assertThat(e)168 .hasMessageContaining("Unsupported settings")169 .hasMessageContaining("serialization")170 .hasMessageContaining("extra interfaces");171 }172 }173 @Test174 public void should_fail_at_creating_a_mock_of_a_final_class_with_extra_interfaces()175 throws Exception {176 MockCreationSettings<FinalClass> settings =177 new CreationSettings<FinalClass>()178 .setTypeToMock(FinalClass.class)179 .setExtraInterfaces(Sets.<Class<?>>newSet(List.class));180 try {181 mockMaker.createMock(settings, new MockHandlerImpl<FinalClass>(settings));182 fail("Expected a MockitoException");183 } catch (MockitoException e) {184 assertThat(e)185 .hasMessageContaining("Unsupported settings")186 .hasMessageContaining("serialization")187 .hasMessageContaining("extra interfaces");188 }189 }190 @Test191 public void should_mock_interface() {192 MockSettingsImpl<Set> mockSettings = new MockSettingsImpl<Set>();193 mockSettings.setTypeToMock(Set.class);194 mockSettings.defaultAnswer(new Returns(10));195 Set<?> proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Set>(mockSettings));196 assertThat(proxy.size()).isEqualTo(10);197 }198 @Test199 public void should_mock_interface_to_string() {200 MockSettingsImpl<Set> mockSettings = new MockSettingsImpl<Set>();201 mockSettings.setTypeToMock(Set.class);202 mockSettings.defaultAnswer(new Returns("foo"));203 Set<?> proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Set>(mockSettings));204 assertThat(proxy.toString()).isEqualTo("foo");205 }206 /**207 * @see <a href="https://github.com/mockito/mockito/issues/2154">https://github.com/mockito/mockito/issues/2154</a>208 */209 @Test210 public void should_mock_class_to_string() {211 MockSettingsImpl<Object> mockSettings = new MockSettingsImpl<Object>();212 mockSettings.setTypeToMock(Object.class);213 mockSettings.defaultAnswer(new Returns("foo"));214 Object proxy =215 mockMaker.createMock(mockSettings, new MockHandlerImpl<Object>(mockSettings));216 assertThat(proxy.toString()).isEqualTo("foo");217 }218 @Test219 public void should_leave_causing_stack() throws Exception {220 MockSettingsImpl<ExceptionThrowingClass> settings = new MockSettingsImpl<>();221 settings.setTypeToMock(ExceptionThrowingClass.class);222 settings.defaultAnswer(Answers.CALLS_REAL_METHODS);223 Optional<ExceptionThrowingClass> proxy =224 mockMaker.createSpy(225 settings, new MockHandlerImpl<>(settings), new ExceptionThrowingClass());226 StackTraceElement[] returnedStack = null;227 try {228 proxy.get().throwException();229 } catch (IOException ex) {230 returnedStack = ex.getStackTrace();231 }232 assertNotNull("Stack trace from mockito expected", returnedStack);233 assertEquals(ExceptionThrowingClass.class.getName(), returnedStack[0].getClassName());234 assertEquals("internalThrowException", returnedStack[0].getMethodName());235 }236 @Test237 public void should_remove_recursive_self_call_from_stack_trace() throws Exception {238 StackTraceElement[] stack =239 new StackTraceElement[] {240 new StackTraceElement("foo", "", "", -1),241 new StackTraceElement(SampleInterface.class.getName(), "", "", -1),242 new StackTraceElement("qux", "", "", -1),243 new StackTraceElement("bar", "", "", -1),244 new StackTraceElement("baz", "", "", -1)245 };246 Throwable throwable = new Throwable();247 throwable.setStackTrace(stack);248 throwable = MockMethodAdvice.hideRecursiveCall(throwable, 2, SampleInterface.class);249 assertThat(throwable.getStackTrace())250 .isEqualTo(251 new StackTraceElement[] {252 new StackTraceElement("foo", "", "", -1),253 new StackTraceElement("bar", "", "", -1),254 new StackTraceElement("baz", "", "", -1)255 });256 }257 @Test258 public void should_handle_missing_or_inconsistent_stack_trace() throws Exception {259 Throwable throwable = new Throwable();260 throwable.setStackTrace(new StackTraceElement[0]);261 assertThat(MockMethodAdvice.hideRecursiveCall(throwable, 0, SampleInterface.class))262 .isSameAs(throwable);263 }264 @Test265 public void should_provide_reason_for_wrapper_class() {266 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(Integer.class);267 assertThat(mockable.nonMockableReason())268 .isEqualTo("Cannot mock wrapper types, String.class or Class.class");269 }270 @Test271 public void should_provide_reason_for_vm_unsupported() {272 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(int[].class);273 assertThat(mockable.nonMockableReason())274 .isEqualTo("VM does not support modification of given type");275 }276 @Test277 public void should_mock_method_of_package_private_class() throws Exception {278 MockCreationSettings<NonPackagePrivateSubClass> settings =279 settingsFor(NonPackagePrivateSubClass.class);280 NonPackagePrivateSubClass proxy =281 mockMaker.createMock(282 settings, new MockHandlerImpl<NonPackagePrivateSubClass>(settings));283 assertThat(proxy.value()).isEqualTo("bar");284 }285 @Test286 public void is_type_mockable_excludes_String() {287 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(String.class);288 assertThat(mockable.mockable()).isFalse();289 assertThat(mockable.nonMockableReason())290 .contains("Cannot mock wrapper types, String.class or Class.class");291 }292 @Test293 public void is_type_mockable_excludes_Class() {294 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(Class.class);295 assertThat(mockable.mockable()).isFalse();296 assertThat(mockable.nonMockableReason())297 .contains("Cannot mock wrapper types, String.class or Class.class");298 }299 @Test300 public void is_type_mockable_excludes_primitive_classes() {301 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(int.class);302 assertThat(mockable.mockable()).isFalse();303 assertThat(mockable.nonMockableReason()).contains("primitive");304 }305 @Test306 public void is_type_mockable_allows_anonymous() {307 Observer anonymous =308 new Observer() {309 @Override310 public void update(Observable o, Object arg) {}311 };312 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(anonymous.getClass());313 assertThat(mockable.mockable()).isTrue();314 assertThat(mockable.nonMockableReason()).contains("");315 }316 @Test317 public void is_type_mockable_give_empty_reason_if_type_is_mockable() {318 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(SomeClass.class);319 assertThat(mockable.mockable()).isTrue();320 assertThat(mockable.nonMockableReason()).isEqualTo("");321 }322 @Test323 public void is_type_mockable_give_allow_final_mockable_from_JDK() {324 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(Pattern.class);325 assertThat(mockable.mockable()).isTrue();326 assertThat(mockable.nonMockableReason()).isEqualTo("");327 }328 @Test329 public void test_parameters_retention() throws Exception {330 assumeTrue(ClassFileVersion.ofThisVm().isAtLeast(JAVA_V8));331 Class<?> typeWithParameters =332 new ByteBuddy()333 .subclass(Object.class)334 .defineMethod("foo", void.class, Visibility.PUBLIC)335 .withParameter(String.class, "bar")336 .intercept(StubMethod.INSTANCE)337 .make()338 .load(null)339 .getLoaded();340 MockCreationSettings<?> settings = settingsFor(typeWithParameters);341 @SuppressWarnings("unchecked")342 Object proxy = mockMaker.createMock(settings, new MockHandlerImpl(settings));343 assertThat(proxy.getClass()).isEqualTo(typeWithParameters);344 assertThat(345 new TypeDescription.ForLoadedType(typeWithParameters)346 .getDeclaredMethods()347 .filter(named("foo"))348 .getOnly()349 .getParameters()350 .getOnly()351 .getName())352 .isEqualTo("bar");353 }354 @Test355 public void test_constant_dynamic_compatibility() throws Exception {356 assumeTrue(ClassFileVersion.ofThisVm().isAtLeast(JAVA_V11));357 Class<?> typeWithCondy =358 new ByteBuddy()359 .subclass(Callable.class)360 .method(named("call"))361 .intercept(FixedValue.value(JavaConstant.Dynamic.ofNullConstant()))362 .make()363 .load(null)364 .getLoaded();365 MockCreationSettings<?> settings = settingsFor(typeWithCondy);366 @SuppressWarnings("unchecked")367 Object proxy = mockMaker.createMock(settings, new MockHandlerImpl(settings));368 assertThat(proxy.getClass()).isEqualTo(typeWithCondy);369 }370 @Test371 public void test_clear_mock_clears_handler() {372 MockCreationSettings<GenericSubClass> settings = settingsFor(GenericSubClass.class);373 GenericSubClass proxy =374 mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));375 assertThat(mockMaker.getHandler(proxy)).isNotNull();376 // when377 mockMaker.clearMock(proxy);378 // then379 assertThat(mockMaker.getHandler(proxy)).isNull();380 }381 @Test382 public void test_clear_all_mock_clears_handler() {383 MockCreationSettings<GenericSubClass> settings = settingsFor(GenericSubClass.class);384 GenericSubClass proxy1 =385 mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));386 assertThat(mockMaker.getHandler(proxy1)).isNotNull();387 settings = settingsFor(GenericSubClass.class);388 GenericSubClass proxy2 =389 mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));390 assertThat(mockMaker.getHandler(proxy1)).isNotNull();391 // when392 mockMaker.clearAllMocks();393 // then394 assertThat(mockMaker.getHandler(proxy1)).isNull();395 assertThat(mockMaker.getHandler(proxy2)).isNull();396 }...
Source:InlineByteBuddyMockMakerTest.java
...9import org.junit.Test;10import org.mockito.exceptions.base.MockitoException;11import org.mockito.internal.creation.MockSettingsImpl;12import org.mockito.internal.creation.settings.CreationSettings;13import org.mockito.internal.handler.MockHandlerImpl;14import org.mockito.internal.stubbing.answers.Returns;15import org.mockito.internal.util.collections.Sets;16import org.mockito.mock.MockCreationSettings;17import org.mockito.mock.SerializableMode;18import org.mockito.plugins.MockMaker;19import java.util.HashMap;20import java.util.List;21import java.util.Observable;22import java.util.Observer;23import java.util.Set;24import java.util.concurrent.Callable;25import java.util.regex.Pattern;26import static net.bytebuddy.ClassFileVersion.JAVA_V8;27import static net.bytebuddy.ClassFileVersion.JAVA_V11;28import static net.bytebuddy.matcher.ElementMatchers.named;29import static org.assertj.core.api.Assertions.assertThat;30import static org.assertj.core.api.Assertions.fail;31import static org.junit.Assume.assumeTrue;32public class InlineByteBuddyMockMakerTest extends AbstractByteBuddyMockMakerTest<InlineByteBuddyMockMaker> {33 public InlineByteBuddyMockMakerTest() {34 super(new InlineByteBuddyMockMaker());35 }36 @Override37 protected Class<?> mockTypeOf(Class<?> type) {38 return type;39 }40 @Test41 public void should_create_mock_from_final_class() throws Exception {42 MockCreationSettings<FinalClass> settings = settingsFor(FinalClass.class);43 FinalClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<FinalClass>(settings));44 assertThat(proxy.foo()).isEqualTo("bar");45 }46 @Test47 public void should_create_mock_from_final_class_in_the_JDK() throws Exception {48 MockCreationSettings<Pattern> settings = settingsFor(Pattern.class);49 Pattern proxy = mockMaker.createMock(settings, new MockHandlerImpl<Pattern>(settings));50 assertThat(proxy.pattern()).isEqualTo("bar");51 }52 @Test53 public void should_create_mock_from_abstract_class_with_final_method() throws Exception {54 MockCreationSettings<FinalMethodAbstractType> settings = settingsFor(FinalMethodAbstractType.class);55 FinalMethodAbstractType proxy = mockMaker.createMock(settings, new MockHandlerImpl<FinalMethodAbstractType>(settings));56 assertThat(proxy.foo()).isEqualTo("bar");57 assertThat(proxy.bar()).isEqualTo("bar");58 }59 @Test60 public void should_create_mock_from_final_class_with_interface_methods() throws Exception {61 MockCreationSettings<FinalMethod> settings = settingsFor(FinalMethod.class, SampleInterface.class);62 FinalMethod proxy = mockMaker.createMock(settings, new MockHandlerImpl<FinalMethod>(settings));63 assertThat(proxy.foo()).isEqualTo("bar");64 assertThat(((SampleInterface) proxy).bar()).isEqualTo("bar");65 }66 @Test67 public void should_detect_non_overridden_generic_method_of_supertype() throws Exception {68 MockCreationSettings<GenericSubClass> settings = settingsFor(GenericSubClass.class);69 GenericSubClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));70 assertThat(proxy.value()).isEqualTo("bar");71 }72 @Test73 public void should_create_mock_from_hashmap() throws Exception {74 MockCreationSettings<HashMap> settings = settingsFor(HashMap.class);75 HashMap proxy = mockMaker.createMock(settings, new MockHandlerImpl<HashMap>(settings));76 assertThat(proxy.get(null)).isEqualTo("bar");77 }78 @Test79 @SuppressWarnings("unchecked")80 public void should_throw_exception_redefining_unmodifiable_class() {81 MockCreationSettings settings = settingsFor(int.class);82 try {83 mockMaker.createMock(settings, new MockHandlerImpl(settings));84 fail("Expected a MockitoException");85 } catch (MockitoException e) {86 e.printStackTrace();87 assertThat(e).hasMessageContaining("Could not modify all classes");88 }89 }90 @Test91 @SuppressWarnings("unchecked")92 public void should_throw_exception_redefining_array() {93 int[] array = new int[5];94 MockCreationSettings<? extends int[]> settings = settingsFor(array.getClass());95 try {96 mockMaker.createMock(settings, new MockHandlerImpl(settings));97 fail("Expected a MockitoException");98 } catch (MockitoException e) {99 assertThat(e).hasMessageContaining("Arrays cannot be mocked");100 }101 }102 @Test103 public void should_create_mock_from_enum() throws Exception {104 MockCreationSettings<EnumClass> settings = settingsFor(EnumClass.class);105 EnumClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<EnumClass>(settings));106 assertThat(proxy.foo()).isEqualTo("bar");107 }108 @Test109 public void should_fail_at_creating_a_mock_of_a_final_class_with_explicit_serialization() throws Exception {110 MockCreationSettings<FinalClass> settings = new CreationSettings<FinalClass>()111 .setTypeToMock(FinalClass.class)112 .setSerializableMode(SerializableMode.BASIC);113 try {114 mockMaker.createMock(settings, new MockHandlerImpl<FinalClass>(settings));115 fail("Expected a MockitoException");116 } catch (MockitoException e) {117 assertThat(e)118 .hasMessageContaining("Unsupported settings")119 .hasMessageContaining("serialization")120 .hasMessageContaining("extra interfaces");121 }122 }123 @Test124 public void should_fail_at_creating_a_mock_of_a_final_class_with_extra_interfaces() throws Exception {125 MockCreationSettings<FinalClass> settings = new CreationSettings<FinalClass>()126 .setTypeToMock(FinalClass.class)127 .setExtraInterfaces(Sets.<Class<?>>newSet(List.class));128 try {129 mockMaker.createMock(settings, new MockHandlerImpl<FinalClass>(settings));130 fail("Expected a MockitoException");131 } catch (MockitoException e) {132 assertThat(e)133 .hasMessageContaining("Unsupported settings")134 .hasMessageContaining("serialization")135 .hasMessageContaining("extra interfaces");136 }137 }138 @Test139 public void should_mock_interface() {140 MockSettingsImpl<Set> mockSettings = new MockSettingsImpl<Set>();141 mockSettings.setTypeToMock(Set.class);142 mockSettings.defaultAnswer(new Returns(10));143 Set<?> proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Set>(mockSettings));144 assertThat(proxy.size()).isEqualTo(10);145 }146 @Test147 public void should_mock_interface_to_string() {148 MockSettingsImpl<Set> mockSettings = new MockSettingsImpl<Set>();149 mockSettings.setTypeToMock(Set.class);150 mockSettings.defaultAnswer(new Returns("foo"));151 Set<?> proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Set>(mockSettings));152 assertThat(proxy.toString()).isEqualTo("foo");153 }154 @Test155 public void should_remove_recursive_self_call_from_stack_trace() throws Exception {156 StackTraceElement[] stack = new StackTraceElement[]{157 new StackTraceElement("foo", "", "", -1),158 new StackTraceElement(SampleInterface.class.getName(), "", "", -1),159 new StackTraceElement("qux", "", "", -1),160 new StackTraceElement("bar", "", "", -1),161 new StackTraceElement("baz", "", "", -1)162 };163 Throwable throwable = new Throwable();164 throwable.setStackTrace(stack);165 throwable = MockMethodAdvice.hideRecursiveCall(throwable, 2, SampleInterface.class);166 assertThat(throwable.getStackTrace()).isEqualTo(new StackTraceElement[]{167 new StackTraceElement("foo", "", "", -1),168 new StackTraceElement("bar", "", "", -1),169 new StackTraceElement("baz", "", "", -1)170 });171 }172 @Test173 public void should_handle_missing_or_inconsistent_stack_trace() throws Exception {174 Throwable throwable = new Throwable();175 throwable.setStackTrace(new StackTraceElement[0]);176 assertThat(MockMethodAdvice.hideRecursiveCall(throwable, 0, SampleInterface.class)).isSameAs(throwable);177 }178 @Test179 public void should_provide_reason_for_wrapper_class() {180 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(Integer.class);181 assertThat(mockable.nonMockableReason()).isEqualTo("Cannot mock wrapper types, String.class or Class.class");182 }183 @Test184 public void should_provide_reason_for_vm_unsupported() {185 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(int[].class);186 assertThat(mockable.nonMockableReason()).isEqualTo("VM does not not support modification of given type");187 }188 @Test189 public void should_mock_method_of_package_private_class() throws Exception {190 MockCreationSettings<NonPackagePrivateSubClass> settings = settingsFor(NonPackagePrivateSubClass.class);191 NonPackagePrivateSubClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<NonPackagePrivateSubClass>(settings));192 assertThat(proxy.value()).isEqualTo("bar");193 }194 @Test195 public void is_type_mockable_excludes_String() {196 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(String.class);197 assertThat(mockable.mockable()).isFalse();198 assertThat(mockable.nonMockableReason()).contains("Cannot mock wrapper types, String.class or Class.class");199 }200 @Test201 public void is_type_mockable_excludes_Class() {202 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(Class.class);203 assertThat(mockable.mockable()).isFalse();204 assertThat(mockable.nonMockableReason()).contains("Cannot mock wrapper types, String.class or Class.class");205 }206 @Test207 public void is_type_mockable_excludes_primitive_classes() {208 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(int.class);209 assertThat(mockable.mockable()).isFalse();210 assertThat(mockable.nonMockableReason()).contains("primitive");211 }212 @Test213 public void is_type_mockable_allows_anonymous() {214 Observer anonymous = new Observer() {215 @Override216 public void update(Observable o, Object arg) {217 }218 };219 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(anonymous.getClass());220 assertThat(mockable.mockable()).isTrue();221 assertThat(mockable.nonMockableReason()).contains("");222 }223 @Test224 public void is_type_mockable_give_empty_reason_if_type_is_mockable() {225 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(SomeClass.class);226 assertThat(mockable.mockable()).isTrue();227 assertThat(mockable.nonMockableReason()).isEqualTo("");228 }229 @Test230 public void is_type_mockable_give_allow_final_mockable_from_JDK() {231 MockMaker.TypeMockability mockable = mockMaker.isTypeMockable(Pattern.class);232 assertThat(mockable.mockable()).isTrue();233 assertThat(mockable.nonMockableReason()).isEqualTo("");234 }235 @Test236 public void test_parameters_retention() throws Exception {237 assumeTrue(ClassFileVersion.ofThisVm().isAtLeast(JAVA_V8));238 Class<?> typeWithParameters = new ByteBuddy()239 .subclass(Object.class)240 .defineMethod("foo", void.class, Visibility.PUBLIC)241 .withParameter(String.class, "bar")242 .intercept(StubMethod.INSTANCE)243 .make()244 .load(null)245 .getLoaded();246 MockCreationSettings<?> settings = settingsFor(typeWithParameters);247 @SuppressWarnings("unchecked")248 Object proxy = mockMaker.createMock(settings, new MockHandlerImpl(settings));249 assertThat(proxy.getClass()).isEqualTo(typeWithParameters);250 assertThat(new TypeDescription.ForLoadedType(typeWithParameters).getDeclaredMethods().filter(named("foo"))251 .getOnly().getParameters().getOnly().getName()).isEqualTo("bar");252 }253 @Test254 public void test_constant_dynamic_compatibility() throws Exception {255 assumeTrue(ClassFileVersion.ofThisVm().isAtLeast(JAVA_V11));256 Class<?> typeWithCondy = new ByteBuddy()257 .subclass(Callable.class)258 .method(named("call"))259 .intercept(FixedValue.value(JavaConstant.Dynamic.ofNullConstant()))260 .make()261 .load(null)262 .getLoaded();263 MockCreationSettings<?> settings = settingsFor(typeWithCondy);264 @SuppressWarnings("unchecked")265 Object proxy = mockMaker.createMock(settings, new MockHandlerImpl(settings));266 assertThat(proxy.getClass()).isEqualTo(typeWithCondy);267 }268 @Test269 public void test_clear_mock_clears_handler() {270 MockCreationSettings<GenericSubClass> settings = settingsFor(GenericSubClass.class);271 GenericSubClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));272 assertThat(mockMaker.getHandler(proxy)).isNotNull();273 //when274 mockMaker.clearMock(proxy);275 //then276 assertThat(mockMaker.getHandler(proxy)).isNull();277 }278 @Test279 public void test_clear_all_mock_clears_handler() {280 MockCreationSettings<GenericSubClass> settings = settingsFor(GenericSubClass.class);281 GenericSubClass proxy1 = mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));282 assertThat(mockMaker.getHandler(proxy1)).isNotNull();283 settings = settingsFor(GenericSubClass.class);284 GenericSubClass proxy2 = mockMaker.createMock(settings, new MockHandlerImpl<GenericSubClass>(settings));285 assertThat(mockMaker.getHandler(proxy1)).isNotNull();286 //when287 mockMaker.clearAllMocks();288 //then289 assertThat(mockMaker.getHandler(proxy1)).isNull();290 assertThat(mockMaker.getHandler(proxy2)).isNull();291 }292 private static <T> MockCreationSettings<T> settingsFor(Class<T> type, Class<?>... extraInterfaces) {293 MockSettingsImpl<T> mockSettings = new MockSettingsImpl<T>();...
Source:MockMethodAdvice.java
...44 MockMethodDispatcher mockMethodDispatcher = MockMethodDispatcher.get(str, obj);45 if (mockMethodDispatcher == null || !mockMethodDispatcher.isMocked(obj) || mockMethodDispatcher.isOverridden(obj, method)) {46 return null;47 }48 return mockMethodDispatcher.handle(obj, method, objArr);49 }50 @Advice.OnMethodExit51 private static void exit(@Advice.Return(readOnly = false, typing = Assigner.Typing.DYNAMIC) Object obj, @Advice.Enter Callable<?> callable) throws Throwable {52 if (callable != null) {53 callable.call();54 }55 }56 static Throwable hideRecursiveCall(Throwable th, int i, Class<?> cls) {57 try {58 StackTraceElement[] stackTrace = th.getStackTrace();59 int i2 = 0;60 do {61 i2++;62 } while (!stackTrace[(stackTrace.length - i) - i2].getClassName().equals(cls.getName()));63 int length = (stackTrace.length - i) - i2;64 StackTraceElement[] stackTraceElementArr = new StackTraceElement[(stackTrace.length - i2)];65 System.arraycopy(stackTrace, 0, stackTraceElementArr, 0, length);66 System.arraycopy(stackTrace, i2 + length, stackTraceElementArr, length, i);67 th.setStackTrace(stackTraceElementArr);68 } catch (RuntimeException unused) {69 }70 return th;71 }72 /* JADX WARNING: type inference failed for: r8v0 */73 /* JADX WARNING: type inference failed for: r0v8, types: [org.mockito.internal.creation.bytebuddy.MockMethodAdvice$RealMethodCall] */74 /* JADX WARNING: type inference failed for: r0v9, types: [org.mockito.internal.creation.bytebuddy.MockMethodAdvice$SerializableRealMethodCall] */75 /* JADX WARNING: Multi-variable type inference failed */76 /* Code decompiled incorrectly, please refer to instructions dump. */77 public java.util.concurrent.Callable<?> handle(java.lang.Object r10, java.lang.reflect.Method r11, java.lang.Object[] r12) throws java.lang.Throwable {78 /*79 r9 = this;80 org.mockito.internal.util.concurrent.WeakConcurrentMap<java.lang.Object, org.mockito.internal.creation.bytebuddy.MockMethodInterceptor> r0 = r9.interceptors81 java.lang.Object r0 = r0.get(r10)82 r6 = r083 org.mockito.internal.creation.bytebuddy.MockMethodInterceptor r6 = (org.mockito.internal.creation.bytebuddy.MockMethodInterceptor) r684 r7 = 085 if (r6 != 0) goto L_0x000d86 return r787 L_0x000d:88 boolean r0 = r10 instanceof java.io.Serializable89 if (r0 == 0) goto L_0x001e90 org.mockito.internal.creation.bytebuddy.MockMethodAdvice$SerializableRealMethodCall r8 = new org.mockito.internal.creation.bytebuddy.MockMethodAdvice$SerializableRealMethodCall91 java.lang.String r1 = r9.identifier92 r5 = 093 r0 = r894 r2 = r1195 r3 = r1096 r4 = r1297 r0.<init>(r1, r2, r3, r4)98 goto L_0x002a99 L_0x001e:100 org.mockito.internal.creation.bytebuddy.MockMethodAdvice$RealMethodCall r8 = new org.mockito.internal.creation.bytebuddy.MockMethodAdvice$RealMethodCall101 org.mockito.internal.creation.bytebuddy.MockMethodAdvice$SelfCallInfo r1 = r9.selfCallInfo102 r5 = 0103 r0 = r8104 r2 = r11105 r3 = r10106 r4 = r12107 r0.<init>(r1, r2, r3, r4)108 L_0x002a:109 r4 = r8110 java.lang.Throwable r0 = new java.lang.Throwable111 r0.<init>()112 java.lang.StackTraceElement[] r1 = r0.getStackTrace()113 java.lang.StackTraceElement[] r1 = skipInlineMethodElement(r1)114 r0.setStackTrace(r1)115 org.mockito.internal.creation.bytebuddy.MockMethodAdvice$ReturnValueWrapper r8 = new org.mockito.internal.creation.bytebuddy.MockMethodAdvice$ReturnValueWrapper116 org.mockito.internal.debugging.LocationImpl r5 = new org.mockito.internal.debugging.LocationImpl117 r5.<init>((java.lang.Throwable) r0)118 r0 = r6119 r1 = r10120 r2 = r11121 r3 = r12122 java.lang.Object r0 = r0.doIntercept(r1, r2, r3, r4, r5)123 r8.<init>(r0)124 return r8125 */126 throw new UnsupportedOperationException("Method not decompiled: org.mockito.internal.creation.bytebuddy.MockMethodAdvice.handle(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]):java.util.concurrent.Callable");127 }128 public boolean isMock(Object obj) {129 return obj != this.interceptors.target && this.interceptors.containsKey(obj);130 }131 public boolean isMocked(Object obj) {132 return this.selfCallInfo.checkSuperCall(obj) && isMock(obj);133 }134 public boolean isOverridden(Object obj, Method method) {135 MethodGraph methodGraph;136 SoftReference softReference = this.graphs.get(obj.getClass());137 if (softReference == null) {138 methodGraph = null;139 } else {140 methodGraph = (MethodGraph) softReference.get();141 }142 if (methodGraph == null) {143 methodGraph = this.compiler.compile(new TypeDescription.ForLoadedType(obj.getClass()));144 this.graphs.put(obj.getClass(), new SoftReference(methodGraph));145 }146 MethodGraph.Node locate = methodGraph.locate(new MethodDescription.ForLoadedMethod(method).asSignatureToken());147 return !locate.getSort().isResolved() || !((MethodDescription.InDefinedShape) locate.getRepresentative().asDefined()).getDeclaringType().represents(method.getDeclaringClass());148 }149 private static class RealMethodCall implements RealMethod {150 private final Object[] arguments;151 private final MockWeakReference<Object> instanceRef;152 private final Method origin;153 private final SelfCallInfo selfCallInfo;154 public boolean isInvokable() {155 return true;156 }157 private RealMethodCall(SelfCallInfo selfCallInfo2, Method method, Object obj, Object[] objArr) {158 this.selfCallInfo = selfCallInfo2;159 this.origin = method;160 this.instanceRef = new MockWeakReference<>(obj);161 this.arguments = objArr;162 }163 public Object invoke() throws Throwable {164 if (!Modifier.isPublic(this.origin.getDeclaringClass().getModifiers() & this.origin.getModifiers())) {165 this.origin.setAccessible(true);166 }167 this.selfCallInfo.set(this.instanceRef.get());168 return MockMethodAdvice.tryInvoke(this.origin, this.instanceRef.get(), this.arguments);169 }170 }171 private static class SerializableRealMethodCall implements RealMethod {172 private final Object[] arguments;173 private final String identifier;174 private final MockReference<Object> instanceRef;175 private final SerializableMethod origin;176 public boolean isInvokable() {177 return true;178 }179 private SerializableRealMethodCall(String str, Method method, Object obj, Object[] objArr) {180 this.origin = new SerializableMethod(method);181 this.identifier = str;182 this.instanceRef = new MockWeakReference(obj);183 this.arguments = objArr;184 }185 public Object invoke() throws Throwable {186 Method javaMethod = this.origin.getJavaMethod();187 if (!Modifier.isPublic(javaMethod.getDeclaringClass().getModifiers() & javaMethod.getModifiers())) {188 javaMethod.setAccessible(true);189 }190 MockMethodAdvice mockMethodAdvice = MockMethodDispatcher.get(this.identifier, this.instanceRef.get());191 if (mockMethodAdvice instanceof MockMethodAdvice) {192 MockMethodAdvice mockMethodAdvice2 = mockMethodAdvice;193 Object replace = mockMethodAdvice2.selfCallInfo.replace(this.instanceRef.get());194 try {195 return MockMethodAdvice.tryInvoke(javaMethod, this.instanceRef.get(), this.arguments);196 } finally {197 mockMethodAdvice2.selfCallInfo.set(replace);198 }199 } else {200 throw new MockitoException("Unexpected dispatcher for advice-based super call");201 }202 }203 }204 /* access modifiers changed from: private */205 public static Object tryInvoke(Method method, Object obj, Object[] objArr) throws Throwable {206 try {207 return method.invoke(obj, objArr);208 } catch (InvocationTargetException e) {209 Throwable cause = e.getCause();210 new ConditionalStackTraceFilter().filter(hideRecursiveCall(cause, new Throwable().getStackTrace().length, method.getDeclaringClass()));211 throw cause;212 }213 }214 private static StackTraceElement[] skipInlineMethodElement(StackTraceElement[] stackTraceElementArr) {215 ArrayList arrayList = new ArrayList(stackTraceElementArr.length);216 int i = 0;217 while (i < stackTraceElementArr.length) {218 StackTraceElement stackTraceElement = stackTraceElementArr[i];219 arrayList.add(stackTraceElement);220 if (stackTraceElement.getClassName().equals(MockMethodAdvice.class.getName()) && stackTraceElement.getMethodName().equals("handle")) {221 i++;222 }223 i++;224 }225 return (StackTraceElement[]) arrayList.toArray(new StackTraceElement[arrayList.size()]);226 }227 private static class ReturnValueWrapper implements Callable<Object> {228 private final Object returned;229 private ReturnValueWrapper(Object obj) {230 this.returned = obj;231 }232 public Object call() {233 return this.returned;234 }...
Source:MockMethodDispatcher.java
...48 public static boolean isConstructorMock(String identifier, Class<?> type) {49 return DISPATCHERS.get(identifier).isConstructorMock(type);50 }51 @SuppressWarnings("unused")52 public static Object handleConstruction(53 String identifier,54 Class<?> type,55 Object object,56 Object[] arguments,57 String[] parameterTypeNames) {58 return DISPATCHERS59 .get(identifier)60 .handleConstruction(type, object, arguments, parameterTypeNames);61 }62 public abstract Callable<?> handle(Object instance, Method origin, Object[] arguments)63 throws Throwable;64 public abstract Callable<?> handleStatic(Class<?> type, Method origin, Object[] arguments)65 throws Throwable;66 public abstract Object handleConstruction(67 Class<?> type, Object object, Object[] arguments, String[] parameterTypeNames);68 public abstract boolean isMock(Object instance);69 public abstract boolean isMocked(Object instance);70 public abstract boolean isMockedStatic(Class<?> type);71 public abstract boolean isOverridden(Object instance, Method origin);72 public abstract boolean isConstructorMock(Class<?> type);73}...
handle
Using AI Code Generation
1import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;2import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.DispatcherDefaultingToRealMethod;3import org.mockito.invocation.InvocationOnMock;4import org.mockito.stubbing.Answer;5import org.mockito.stubbing.Stubber;6public class 1 {7 public static void main(String[] args) {8 Stubber stubber = null;9 stubber = stubber.doAnswer(new Answer<Object>() {10 public Object answer(InvocationOnMock invocation) throws Throwable {11 DispatcherDefaultingToRealMethod dispatcher = new DispatcherDefaultingToRealMethod();12 return dispatcher.handle(invocation);13 }14 });15 }16}17import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;18import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.DispatcherDefaultingToRealMethod;19import org.mockito.invocation.InvocationOnMock;20import org.mockito.stubbing.Answer;21import org.mockito.stubbing.Stubber;22public class 2 {23 public static void main(String[] args) {24 Stubber stubber = null;25 stubber = stubber.doAnswer(new Answer<Object>() {26 public Object answer(InvocationOnMock invocation) throws Throwable {27 MockMethodDispatcher dispatcher = new DispatcherDefaultingToRealMethod();28 return dispatcher.handle(invocation);29 }30 });31 }32}33import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;34import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.DispatcherDefaultingToRealMethod;35import org.mockito.invocation.InvocationOnMock;36import org.mockito.stubbing.Answer;37import org.mockito.stubbing.Stubber;38public class 3 {39 public static void main(String[] args) {40 Stubber stubber = null;41 stubber = stubber.doAnswer(new Answer<Object>() {42 public Object answer(InvocationOnMock invocation) throws Throwable {43 DispatcherDefaultingToRealMethod dispatcher = new MockMethodDispatcher();44 return dispatcher.handle(invocation);45 }46 });47 }48}
handle
Using AI Code Generation
1import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;2import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.DispatcherDefaultingToRealMethod;3public class 1 {4 public static void main(String[] args) {5 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();6 DispatcherDefaultingToRealMethod dispatcherDefaultingToRealMethod = mockMethodDispatcher.dispatcherDefaultingToRealMethod();7 System.out.println(dispatcherDefaultingToRealMethod.handle(null, null, null, null));8 }9}10import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;11import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher.DispatcherDefaultingToRealMethod;12public class 2 {13 public static void main(String[] args) {14 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();15 DispatcherDefaultingToRealMethod dispatcherDefaultingToRealMethod = mockMethodDispatcher.dispatcherDefaultingToRealMethod();16 System.out.println(dispatcherDefaultingToRealMethod.handle(null, null, null, null));17 }18}
handle
Using AI Code Generation
1public class MockMethodDispatcherTest {2 public static void main(String[] args) throws Exception {3 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();4 MethodHandle handle = mockMethodDispatcher.handle();5 Object[] args1 = new Object[] {"test", "test"};6 Object o = handle.invokeWithArguments(args1);7 System.out.println(o);8 }9}10public class MockMethodDispatcherTest {11 public static void main(String[] args) throws Exception {12 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();13 MethodHandle handle = mockMethodDispatcher.handle();14 Object[] args1 = new Object[] {"test", "test"};15 Object o = handle.invokeWithArguments(args1);16 System.out.println(o);17 }18}19public class MockMethodDispatcherTest {20 public static void main(String[] args) throws Exception {21 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();22 MethodHandle handle = mockMethodDispatcher.handle();23 Object[] args1 = new Object[] {"test", "test"};24 Object o = handle.invokeWithArguments(args1);25 System.out.println(o);26 }27}28public class MockMethodDispatcherTest {29 public static void main(String[] args) throws Exception {30 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();31 MethodHandle handle = mockMethodDispatcher.handle();32 Object[] args1 = new Object[] {"test", "test"};33 Object o = handle.invokeWithArguments(args1);34 System.out.println(o);35 }36}37public class MockMethodDispatcherTest {38 public static void main(String[] args) throws Exception {39 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();40 MethodHandle handle = mockMethodDispatcher.handle();41 Object[] args1 = new Object[] {"test", "test"};42 Object o = handle.invokeWithArguments(args1);43 System.out.println(o);44 }45}
handle
Using AI Code Generation
1public class 1 {2 public static void main(String[] args) throws Exception {3 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();4 MethodHandle methodHandle = mockMethodDispatcher.handle;5 methodHandle.invokeWithArguments("hello");6 }7}8public class 2 {9 public static void main(String[] args) throws Exception {10 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();11 MethodHandle methodHandle = mockMethodDispatcher.handle;12 methodHandle.invokeWithArguments("hello", 1);13 }14}15public class 3 {16 public static void main(String[] args) throws Exception {17 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();18 MethodHandle methodHandle = mockMethodDispatcher.handle;19 methodHandle.invokeWithArguments("hello", 1, 2);20 }21}22public class 4 {23 public static void main(String[] args) throws Exception {24 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();25 MethodHandle methodHandle = mockMethodDispatcher.handle;26 methodHandle.invokeWithArguments("hello", 1, 2, 3);27 }28}29public class 5 {30 public static void main(String[] args) throws Exception {31 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();32 MethodHandle methodHandle = mockMethodDispatcher.handle;33 methodHandle.invokeWithArguments("hello", 1, 2, 3, 4);34 }35}36public class 6 {37 public static void main(String[] args) throws Exception {38 MockMethodDispatcher mockMethodDispatcher = new MockMethodDispatcher();39 MethodHandle methodHandle = mockMethodDispatcher.handle;40 methodHandle.invokeWithArguments("hello", 1, 2, 3, 4, 5);41 }42}
handle
Using AI Code Generation
1package com.example;2import java.lang.reflect.Method;3import java.lang.reflect.Proxy;4import java.util.ArrayList;5import java.util.List;6import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;7public class MockMethodDispatcherExample {8 public static void main(String[] args) throws Exception {9 List<String> list = new ArrayList<>();10 List<String> proxy = (List<String>) Proxy.newProxyInstance(MockMethodDispatcherExample.class.getClassLoader(),11 new Class[] { List.class }, (proxy1, method, args1) -> {12 try {13 return MockMethodDispatcher.handle(proxy1, method, args1, list);14 } catch (Throwable e) {15 throw new RuntimeException(e);16 }17 });18 proxy.add("test");19 System.out.println(proxy.get(0));20 }21}
handle
Using AI Code Generation
1import org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher;2import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor;3import org.mockito.internal.creation.bytebuddy.MockAccess;4import org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator;5import net.bytebuddy.implementation.bind.annotation.RuntimeType;6import net.bytebuddy.implementation.bind.annotation.This;7import net.bytebuddy.implementation.bind.annotation.Origin;8import net.bytebuddy.implementation.bind.annotation.SuperCall;9import net.bytebuddy.implementation.bind.annotation.AllArguments;10import net.bytebuddy.implementation.bind.annotation.Argument;11import net.bytebuddy.implementation.bind.annotation.Super;12import net.bytebuddy.implementation.bind.annotation.SuperMethod;13import net.bytebuddy.implementation.bind.annotation.SuperType;14import net.bytebuddy.implementation.bind.annotation.DefaultCall;15import net.bytebuddy.implementation.bind.annotation.Default;16import net.bytebuddy.implementation.bind.annotation.DefaultMethod;17import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator;18import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForSuperType;19import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod;20import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation;21import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithoutImplementation;22import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation.ForStaticMethod;23import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation.ForInstanceMethod;24import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithoutImplementation.ForStaticMethod;25import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithoutImplementation.ForInstanceMethod;26import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation.ForInstanceMethod.ForAbstractMethod;27import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation.ForInstanceMethod.ForConcreteMethod;28import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation.ForStaticMethod.ForAbstractMethod;29import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithImplementation.ForStaticMethod.ForConcreteMethod;30import net.bytebuddy.implementation.bind.annotation.DefaultMethodLocator.ForDefaultMethod.WithoutImplementation.ForStaticMethod.ForAbstractMethod;31import net.bytebuddy
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!