Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. public ManageKitsService(NetworkService velosNetworkService, EmailService emailService, Environment environment, RestClient restClient, Properties properties, ManageKitsDao manageKitsDao, StudyDao studyDao) {
  2. this.NetworkService = NetworkService;
  3. this.emailService = emailService;
  4. this.environment = environment;
  5. this.restClient = restClient;
  6. this.properties = properties;
  7. this.manageKitsDao = manageKitsDao;
  8. this.studyDao = studyDao;
  9. .............
  10. ...............
  11. ...............
  12. }
  13.  
  14. private ManageKitsDao mockManageKitsDao;
  15. private RestClient mockRestClient;
  16.  
  17. @BeforeEach
  18. public void setUp() throws KitException {
  19. mockManageKitsDao = mock(ManageKitsDao.class);
  20. mockRestClient = mock(RestClient.class);
  21. ..............
  22. ................
  23. }
  24.  
  25. @Test
  26. public void itShouldRevokeAssignedKit() {
  27. when(mockManageKitsDao.getXXXX()).thenReturn(something)
  28. ...........some other mocking.............
  29. ManageKitsService manageKitsService = new ManageKitsService(mockNetworkService, mockEmailService, mockEnvironment, mockRestClient, mockProperties, mockManageKitsDao,
  30. mockStudyDao);
  31. assertThatCode(() -> {
  32. manageKitsService.revokeAssignedKit(123, kitAssignment);
  33. }).doesNotThrowAnyException();
  34. }
  35.  
  36. @RunWith(MockitoJUnitRunner::class)
  37. class MyTestClass {
  38.  
  39. @Mock
  40. private ManageKitsDao mockManageKitsDao;
  41.  
  42. @Mock
  43. private RestClient mockRestClient;
  44.  
  45. @InjectMocks
  46. private ManageKitsService manageKitsService
  47.  
  48. // Your service will automatically be instantiated with all of the mocks
  49. // Now you can just write your tests like normal, using manageKitsService
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement