Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ManageKitsService(NetworkService velosNetworkService, EmailService emailService, Environment environment, RestClient restClient, Properties properties, ManageKitsDao manageKitsDao, StudyDao studyDao) {
- this.NetworkService = NetworkService;
- this.emailService = emailService;
- this.environment = environment;
- this.restClient = restClient;
- this.properties = properties;
- this.manageKitsDao = manageKitsDao;
- this.studyDao = studyDao;
- .............
- ...............
- ...............
- }
- private ManageKitsDao mockManageKitsDao;
- private RestClient mockRestClient;
- @BeforeEach
- public void setUp() throws KitException {
- mockManageKitsDao = mock(ManageKitsDao.class);
- mockRestClient = mock(RestClient.class);
- ..............
- ................
- }
- @Test
- public void itShouldRevokeAssignedKit() {
- when(mockManageKitsDao.getXXXX()).thenReturn(something)
- ...........some other mocking.............
- ManageKitsService manageKitsService = new ManageKitsService(mockNetworkService, mockEmailService, mockEnvironment, mockRestClient, mockProperties, mockManageKitsDao,
- mockStudyDao);
- assertThatCode(() -> {
- manageKitsService.revokeAssignedKit(123, kitAssignment);
- }).doesNotThrowAnyException();
- }
- @RunWith(MockitoJUnitRunner::class)
- class MyTestClass {
- @Mock
- private ManageKitsDao mockManageKitsDao;
- @Mock
- private RestClient mockRestClient;
- @InjectMocks
- private ManageKitsService manageKitsService
- // Your service will automatically be instantiated with all of the mocks
- // Now you can just write your tests like normal, using manageKitsService
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement