JUnit

Mock Activiti TaskService, TaskQuery, NativeTaskQuery in Junit

In this tutorial we will how to mock Activiti TaskService, TaskQuery, NativeTaskQuery in Junit test class. Suppose you have Spring service class where you are doing some business flow for your application. So you are using activiti’s TaskService to create list of activiti Tasks using the method createNativeTaskQuery(). You may need to create also TaskQuery […]

Mock Drools ObjectFactory, KieSession and StatelessKieSession using Junit

This tutorial example will show you how to mock ObjectFactory<KieSession>, KieSession and KieStatelessSession using Junit. KieSession is the most common way to interact with the engine in Drools. A KieSession allows the application to establish an iterative conversation with the engine, where the state of the session is kept across invocations. The reasoning process may […]

Mock ObjectMapper.readValue() using Junit Mockito

Introduction This example will show you how to mock ObjectMapper.readValue() using Junit Mockito. When we write Junit test cases or classes, we generally do not test on real object that are injected into the class that has to be tested using Junit to avoid any test case failure at some point, instead we want to […]

Mock an Autowired @Value field in Spring with Junit Mockito

Introduction The below example will show you how to mock an Autowired @Value field in Spring with Junit Mockito. Generally we read some configuration values from properties file into Spring bean or component class using @Value annotated attributes but when we want to test such service or component class using Junit test class then it […]

Junit Testing of File Upload and Download in Spring REST Controllers

Introduction Here in this tutorial we will see examples on Junit testing of file upload and download in Spring REST Controllers. We have seen how to write Junit test cases on Spring REST Controllers in my previous tutorial but I did not show how to write Junit testing of file upload and download in Spring […]

Scroll to top