This extends Part 1: Unit testing with JUnit, Mockito & Spring by mocking the DAO layer with the Mockito framework. Step 1: Service and DAO layer interfaces and implementations Service Layer
|
1 2 3 4 5 |
package com.mytutorial; public interface SimpleService { abstract String processUser(int id); } |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
package com.mytutorial; import javax.inject.Inject; import javax.inject.Named; @Named public class SimpleServiceImpl implements SimpleService { @Inject SimpleDao dao; public String processUser(int id) { String name = dao.getNameById(id); return "Hello " + name; } } |
DAO Layer This layer will be mocked…