1 /* 2 * Copyright (c) 2017 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.bugs; 6 7 import org.junit.Test; 8 9 import static org.assertj.core.api.Assertions.assertThat; 10 import static org.mockito.Mockito.spy; 11 12 public class ImplementationOfGenericAbstractMethodNotInvokedOnSpyTest { 13 public abstract class GenericAbstract<T> { method_to_implement(T value)14 protected abstract String method_to_implement(T value); 15 public_method(T value)16 public String public_method(T value) { 17 return method_to_implement(value); 18 } 19 } 20 21 public class ImplementsGenericMethodOfAbstract<T extends Number> extends GenericAbstract<T> { 22 @Override method_to_implement(T value)23 protected String method_to_implement(T value) { 24 return "concrete value"; 25 } 26 } 27 28 @Test should_invoke_method_to_implement()29 public void should_invoke_method_to_implement() { 30 GenericAbstract<Number> spy = spy(new ImplementsGenericMethodOfAbstract<Number>()); 31 32 assertThat(spy.public_method(73L)).isEqualTo("concrete value"); 33 } 34 } 35