Retrieving JsonParser Settings

This post explains how to get json parser default settings. import java.io.File; import java.io.IOException; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser.Feature; public class ProcessingDemo2 { public static void main(String[] args) throws JsonParseException, IOException { File file = new File(“jsondata.json”); JsonFactory jsonFactory = new JsonFactory(); JsonParser jsonParser = jsonFactory.createParser(file); for(Feature feature : Feature.values()) { System.out.println(feature.name()… Continue reading Retrieving JsonParser Settings

Verifying the order of multiple method invocations in a single instance

When multiple methods of single instance are invoked in an order in a class. We can verify the order of those method invocations using Mockito’s InOrder functionality. Consider the below code Class2 package package4; public class Class2 { public void method1() { System.out.println(“Class2 method1”); } public void method2() { System.out.println(“Class2 method2”); } public void method3()… Continue reading Verifying the order of multiple method invocations in a single instance

Different ways of using thenReturn

This post shows 3 different ways of using thenReturn. 1) First way involves configuring the mock object to return only one return value as shown below when(class1.method1()).thenReturn(2); The above code instructs Mockito to return 2, whenever we call class1.method1 (once or more than once, the return value will always be 2) 2) Second way involves… Continue reading Different ways of using thenReturn

Verifying the order of multiple instances method invocation

This post explains how to verify the order in which multiple instances are called. For example lets consider the below class Class2 package package5; public class Class2 { public void method1() { System.out.println(“Class2 method1”); } } Class3 package package5; public class Class3 { public void method1() { System.out.println(“Class3 method1”); } } Class4 package package5; public… Continue reading Verifying the order of multiple instances method invocation