/
MergeConflictServiceImplTest.java
56 lines (45 loc) · 1.84 KB
/
MergeConflictServiceImplTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package org.openmrs.module.sync2.api.service.impl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openmrs.module.sync2.api.dao.MergeConflictDao;
import org.openmrs.module.sync2.api.model.MergeConflict;
import org.openmrs.module.sync2.api.mother.MergeConflictMother;
public class MergeConflictServiceImplTest {
private static final int MERGE_CONFLICT_ID = 1;
private MergeConflict mergeConflict;
@Mock
private MergeConflictDao mergeConflictDao;
@InjectMocks
private MergeConflictServiceImpl mergeConflictService;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mergeConflict = MergeConflictMother.createInstance(MERGE_CONFLICT_ID);
Mockito.when(mergeConflictDao.getById(MERGE_CONFLICT_ID)).thenReturn(mergeConflict);
Mockito.when(mergeConflictDao.getByUuid(MergeConflictMother.UUID)).thenReturn(mergeConflict);
Mockito.when(mergeConflictDao.save((MergeConflict) Mockito.any())).thenReturn(mergeConflict);
}
@Test
public void save_shouldSaveObject() {
MergeConflict expected = MergeConflictMother.createInstance(MERGE_CONFLICT_ID);
MergeConflict actual = mergeConflictService.save(mergeConflict);
Assert.assertEquals(expected, actual);
}
@Test
public void getById_shouldFetchCorrectObject() {
MergeConflict expected = MergeConflictMother.createInstance(MERGE_CONFLICT_ID);
MergeConflict actual = mergeConflictService.getById(MERGE_CONFLICT_ID);
Assert.assertEquals(expected, actual);
}
@Test
public void getByUuid_shouldFetchCorrectObject() {
MergeConflict expected = MergeConflictMother.createInstance(MERGE_CONFLICT_ID);
MergeConflict actual = mergeConflictService.getByUuid(MergeConflictMother.UUID);
Assert.assertEquals(expected, actual);
}
}