Service:
public class UIConfigServiceImpl implements UIConfigService { @Autowired private UIConfigDAO uiConfigDAO; public List logger.debug("Inside UiConfigService"); return uiConfigDAO.getUIConfigData(configType); } } |
Junit Test:
@RunWith(MockitoJUnitRunner.class) // Run the Junit with Mockito Junit Runner public class UIConfigServiceTest { @InjectMocks // Inject Mock objects into the service. Mockito allows to inject beans where @Autowired is used without requiring setters. private UIConfigService uiConfigService = new UIConfigServiceImpl(); @Mock // Creating a mock for injected object private UIConfigDAO mock; @Test public void testGetUIConfigData() { List UserDetailType suc = new UserDetailType(); list.add(suc); Mockito.when(mock.getUIConfigData(null)).thenReturn(list); List Assert.assertNotNull(rv); Assert.assertFalse(rv.isEmpty()); } } |
No comments:
Post a Comment