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