I have the following class called A, with the method getValue():
public class A { public final int getValue() { return 3; } } The method getValue() always returns 3, then i have another class called B, i need to implement something to access to the method getValue() in the class A, but i need to return 4 instead 3.
Class B:
public class B { public static A getValueA() { return new A(); } } The main class ATest:
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; public class ATest { @Test public void testA() { A a = B.getValueA(); assertEquals( a.getValue() == 4, Boolean.TRUE ); } } I tried to override the method, but really i dont know how to get what i want. Any question post in comments.
final.