Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package by.epam.dzianis;
- import java.util.List;
- import org.junit.After;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
- import by.epam.dzianis.dao.*;
- import by.epam.dzianis.data.MyImage;
- import static org.mockito.Mockito.*;
- public class TestREST {
- List mockedList = mock(List.class);
- MyImage myImage = mock(MyImage.class);
- IDao dao = new Dao(mockedList, myImage);
- /**
- *
- */
- @Test
- public void testDaoCreate(){
- when(myImage.getId()).thenReturn(0);
- when(mockedList.size()).thenReturn(1);
- when(mockedList.get(0)).thenReturn(myImage);
- dao.create(myImage);
- verify(mockedList).add(myImage);
- verify(mockedList).get(0);
- verify(myImage).setId(0);
- }
- /**
- *
- */
- @Test
- public void testDaoRead(){
- when(mockedList.get(0)).thenReturn(myImage);
- Assert.assertEquals(dao.read(0), myImage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement