How to call real method using mock object

This post explains how to call real methods of an instance when writing junit test cases using mockito. import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.when; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class Class1Test { @Mock private Class1 class1; @Test public void testMethod1() { //Stubbed the method1 of Class1 to return some random…… Continue reading How to call real method using mock object

How to read a json file in java

Create a txt file named jsondata.txt with the below data { “firstName”: “Duke”, “lastName”: “Java”, “age”: 18, “streetAddress”: “100 Internet Dr”, “city”: “JavaTown”, “state”: “JA”, “postalCode”: “12345”, “phoneNumbers”: [ { “Mobile”: “111-111-1111” }, { “Home”: “222-222-2222” } ] } Below is the java code which will read the above text file Main Code package objectmodel;…… Continue reading How to read a json file in java