fix tests

This commit is contained in:
Anton Romanov 2019-06-22 11:58:01 +04:00
parent 36c4e52e37
commit 24f447aed7
5 changed files with 23 additions and 24 deletions

View File

@ -130,6 +130,6 @@ dependencies {
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.3.1'
testCompile group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '3.3.1'
testCompile group: 'com.google.guava', name: 'guava', version: '21.0'
//testCompile group: 'com.google.guava', name: 'guava', version: '21.0'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
}

View File

@ -5,8 +5,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.junit4.SpringRunner;
import ru.ulstu.conference.model.Conference;
import ru.ulstu.conference.model.ConferenceDto;
import ru.ulstu.conference.model.ConferenceFilterDto;
@ -31,7 +31,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@RunWith(SpringRunner.class)
public class ConferenceServiceTest {
@Mock
@ -124,7 +124,7 @@ public class ConferenceServiceTest {
@Test
public void getExistConferenceById() {
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
when(conferenceRepository.getOne(ID)).thenReturn(conferenceWithId);
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
when(userService.getCurrentUser()).thenReturn(user);
@ -185,8 +185,8 @@ public class ConferenceServiceTest {
@Test
public void delete() {
when(conferenceRepository.exists(ID)).thenReturn(true);
when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId);
when(conferenceRepository.existsById(ID)).thenReturn(true);
when(conferenceRepository.getOne(ID)).thenReturn(conferenceWithId);
assertTrue(conferenceService.delete(ID));
}

View File

@ -7,7 +7,7 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.test.context.junit4.SpringRunner;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.grant.model.Grant;
@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@RunWith(SpringRunner.class)
public class GrantServiceTest {
@Mock
@ -123,7 +123,7 @@ public class GrantServiceTest {
@Test
public void getExistGrantById() {
when(grantRepository.findOne(ID)).thenReturn(grantWithId);
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
GrantDto newGrantDto = new GrantDto(grantWithId);
GrantDto result = grantService.getExistGrantById(ID);
@ -179,7 +179,7 @@ public class GrantServiceTest {
@Test
public void delete() throws IOException {
when(grantRepository.findOne(ID)).thenReturn(grantWithId);
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
assertTrue(grantService.delete(grantWithId.getId()));
}
@ -195,7 +195,7 @@ public class GrantServiceTest {
@Test
public void findById() {
when(grantRepository.findOne(ID)).thenReturn(grantWithId);
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
Grant findGrant = grantService.findById(ID);
assertEquals(grantWithId.getId(), findGrant.getId());
@ -203,7 +203,7 @@ public class GrantServiceTest {
@Test
public void attachPaper() {
when(grantRepository.findOne(ID)).thenReturn(grantWithId);
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
when(paperService.findAllSelect(Collections.singletonList(ID))).thenReturn(paperDtos);
GrantDto newGrantDto = new GrantDto(grantWithId);
@ -219,7 +219,7 @@ public class GrantServiceTest {
@Test
public void filterEmptyDeadlines() {
when(grantRepository.findOne(ID)).thenReturn(grantWithId);
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
GrantDto newGrantDto = new GrantDto(grantWithId);
newGrantDto.setDeadlines(newGrantDto.getDeadlines().stream()

View File

@ -5,7 +5,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.test.context.junit4.SpringRunner;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.file.model.FileData;
@ -29,7 +29,7 @@ import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@RunWith(SpringRunner.class)
public class ProjectServiceTest {
@Mock
@ -118,8 +118,8 @@ public class ProjectServiceTest {
@Test
public void delete() throws IOException {
when(projectRepository.exists(ID)).thenReturn(true);
when(projectRepository.findOne(ID)).thenReturn(project);
when(projectRepository.existsById(ID)).thenReturn(true);
when(projectRepository.getOne(ID)).thenReturn(project);
assertTrue(projectService.delete(ID));
}
@ -134,7 +134,7 @@ public class ProjectServiceTest {
@Test
public void findById() {
when(projectRepository.findOne(ID)).thenReturn(project);
when(projectRepository.getOne(ID)).thenReturn(project);
assertEquals(project, projectService.findById(ID));
}

View File

@ -5,8 +5,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.junit4.SpringRunner;
import ru.ulstu.core.util.DateUtils;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.deadline.service.DeadlineService;
@ -32,7 +32,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@RunWith(SpringRunner.class)
public class TaskServiceTest {
@Mock
@ -113,7 +113,6 @@ public class TaskServiceTest {
@Test
public void findAll() {
when(taskRepository.findAll(SORT)).thenReturn(tasks);
assertEquals(Collections.singletonList(task), taskService.findAll());
}
@ -153,8 +152,8 @@ public class TaskServiceTest {
@Test
public void delete() throws IOException {
when(taskRepository.exists(ID)).thenReturn(true);
when(taskRepository.findOne(ID)).thenReturn(task);
when(taskRepository.existsById(ID)).thenReturn(true);
when(taskRepository.getOne(ID)).thenReturn(task);
when(schedulerRepository.findOneByTask(task)).thenReturn(null);
assertTrue(taskService.delete(ID));