-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathItemCardUpdateTest.java
More file actions
41 lines (30 loc) · 1.23 KB
/
ItemCardUpdateTest.java
File metadata and controls
41 lines (30 loc) · 1.23 KB
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
package com.queststore.Services;
import com.queststore.DAO.CardDAO;
import com.queststore.DAO.DaoException;
import com.queststore.Model.Card;
import com.queststore.Model.CardTypes;
import com.queststore.Model.Categories;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ItemCardUpdateTest {
@Test
public void updateCardInDB() throws DaoException {
CardDAO cardDAOMock = mock(CardDAO.class);
ItemCardUpdate itemCardUpdate = new ItemCardUpdate(cardDAOMock);
List<String> items = new ArrayList<>();
items.add("1");
items.add("dupa");
items.add("1");
items.add("dupa");
Card card = new Card(Integer.parseInt(items.get(0)), items.get(1), items.get(3), new Categories(1, "easy"), null,
Integer.parseInt(items.get(2)), new CardTypes(2, "artifact"), true);
List<Card> listOfCards = new ArrayList<>();
listOfCards.add(card);
when(cardDAOMock.getCardsOfType(cardDAOMock.getCardTypeById(2))).thenReturn(listOfCards);
assertEquals(listOfCards, itemCardUpdate.updateCardInDB(items));
}
}