import at.reisinger.*; import at.reisinger.Package; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.ArrayList; import static org.junit.jupiter.api.Assertions.assertTrue; public class UserTest { private TradingDeal tradingDeal; private Cards newCards, cards, nochNewCards; private Card newCard, card; private ArrayList cardsArrayList, cardsArrayList2, cardsArrayList3; private Stack stack; private User user; private at.reisinger.Package myPackage; @BeforeEach void setUp() { //at.reisinger.Stack card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER); newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL); cardsArrayList = new ArrayList(); cardsArrayList2 = new ArrayList(); cardsArrayList3 = new ArrayList(); cardsArrayList.add(card); cardsArrayList2.add(newCard); cards = new Cards(cardsArrayList); newCards = new Cards(cardsArrayList2); nochNewCards = new Cards(cardsArrayList3); stack = new Stack(cards, nochNewCards); //at.reisinger.Package myPackage = new Package(cards, "Name", 100); //at.reisinger.Coins Coins coins = new Coins(10); //at.reisinger.User Credentials credentials = new Credentials("username", "pw"); user = new User(credentials, "name", "nachname", "email", coins); } @Test public void test_getName() { String result = user.getName(); assertTrue(result.equals("name")); } @Test public void test_getNachname() { String result = user.getNachname(); assertTrue(result.equals("nachname")); } @Test public void test_getEmail() { String result = user.getEmail(); assertTrue(result.equals("email")); } @Test public void test_setName() { String newstring = "new"; user.setName(newstring); String result = user.getName(); assertTrue(result.equals(newstring)); } @Test public void test_setNachname() { String newstring = "new"; user.setNachname(newstring); String result = user.getNachname(); assertTrue(result.equals(newstring)); } @Test public void test_setEmail() { String newstring = "new"; user.setEmail(newstring); String result = user.getEmail(); assertTrue(result.equals(newstring)); } @Test public void test_buyPackage(){ Cards cards = null; try { cards = new Cards(user.buyPackage(myPackage)); } catch (NegativAmountException e) { e.printStackTrace(); } assertTrue(cards.equals(new Cards(myPackage.getCards()))); } }