Browse Source

Merge pull request 'dev' (#1) from dev into master

Reviewed-on: https://gogs.informatik.hs-fulda.de/adem.berber/projjpn/pulls/1
master
adem.berber 2 years ago
parent
commit
03295d87e2
  1. BIN
      projjpn/GamesDB.accdb
  2. 67
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Birthdate.java
  3. 56
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java
  4. 2449
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  5. 88
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java
  6. 41
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java
  7. 28
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Warehouse.java
  8. 4
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/AppTest.java
  9. 63
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/BirthdateTest.java
  10. 177
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java
  11. 442
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java
  12. 89
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java
  13. 23
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/UserTest.java
  14. 63
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java

BIN
projjpn/GamesDB.accdb

67
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Birthdate.java

@ -0,0 +1,67 @@
package de.hs_fulda.ciip.projjpn;
public class Birthdate {
private int day;
private int month;
private int year;
public Birthdate(int d, int m, int y) {
day = d;
month = m;
year = y;
}
public int getDay() {
return day;
}
public int getMonth() {
return month;
}
public int getYear() {
return year;
}
/**
* @return Date Format DD.MM.YYYY
*/
public String toString() {
return day + "." + month + "." + year;
}
/**
*
* @param d Day
* @param m Month
* @param y Year
*/
public void changeBirthdate(int d, int m, int y) {
day = d;
month = m;
year = y;
}
/**
*
* @param DD
* @param MM
* @param YYYY
* @return true if date is valid.
* @return false if date is invalid.
*/
public boolean isValid(int DD, int MM, int YYYY) {
if (DD < 1 || DD > 31) {
return false;
}
if (MM < 1 || MM > 12) {
return false;
}
if (YYYY < 1990 || YYYY > 2022) {
return false;
}
return true;
}
}

56
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java

@ -0,0 +1,56 @@
package de.hs_fulda.ciip.projjpn;
import java.util.HashMap;
public class Customers {
HashMap<String, User> pool = new HashMap<String, User>();
/**
*
* @param nickname Is the particular Nickname free to use?
* @return true if nickname is Available.
* @return false if nickname is Available.
*/
public boolean nickNameAvailable(String nickname) {
User u = pool.get(nickname);
if (null == u) {
return true;
}
return false;
}
/**
*
* @param user New User to register.
* @return
*/
public User registerUser(User user) {
return pool.putIfAbsent(user.nickName, user);
}
/**
*
* @param userNickname Delete a particular User with the given nickname
* @return null or the deleted user.
*/
public User deleteUser(String userNickname) {
return pool.remove(userNickname);
}
/**
*
* @param nickname Find User by nickname
* @return
*/
public User getByNickname(String nickname) {
return pool.get(nickname);
}
/**
*
* @return Number of Users.
*/
public int getCountOfUsers() {
return pool.size();
}
}

2449
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
File diff suppressed because it is too large
View File

88
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java

@ -0,0 +1,88 @@
package de.hs_fulda.ciip.projjpn;
public class Item {
private String productTitle;
private String description;
private int availability = 0;
private float price;
/**
* Creation of blank Item.
*/
public Item() {
}
/**
* Creation of Item.
* @param titel
* @param description
* @param quantity
* @param price
*/
public Item(String titel,
String description,
int quantity,
float price) {
this.productTitle = titel;
this.description = description;
this.availability = quantity;
this.price = price;
}
/**
*
* @return true if at least one item is in stock.
*/
public boolean inStock() {
return availability > 0;
}
/**
*
* @return current number of this items
*/
public float getCurrentStock() {
return availability;
}
/**
*
* @param newAmount of items
*/
public void updateAvailability(int newAmount) {
availability = newAmount;
}
/**
*
* @param newPrice of this item.
*/
public void updatePrice(float newPrice) {
this.price = newPrice;
}
/**
*
* @return Current Price of the Item.
*/
public float getCurrentPrice() {
return price;
}
/**
*
* @return Current public Title of this Item.
*/
public String getTitel() {
return this.productTitle;
}
/**
*
* @return Current public Description of this Item.
*/
public String getDescription() {
return this.description;
}
}

41
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java

@ -0,0 +1,41 @@
package de.hs_fulda.ciip.projjpn;
public class User {
String firstName;
String lastName;
String nickName;
String eMail;
Birthdate birthdate;
public User(String firstName,
String lastName,
String nickName,
String eMail,
Birthdate birthdate) {
this.firstName = firstName;
this.lastName = lastName;
this.nickName = nickName;
this.eMail = eMail;
this.birthdate = birthdate;
}
public User(String nickName) {
this.nickName = nickName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getNickName() {
return nickName;
}
public String getEMail() {
return eMail;
}
public Birthdate getBirthdate() {
return birthdate;
}
}

28
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Warehouse.java

@ -0,0 +1,28 @@
package de.hs_fulda.ciip.projjpn;
import java.util.HashMap;
public class Warehouse {
protected HashMap<String, Item> pool = new HashMap<String, Item>();
/**
*
* @param item Item to insert.
* @return the inserted Item or null.
*/
public Item insertItem(Item item) {
return pool.putIfAbsent(item.getTitel(), item);
}
/**
*
* @return The total amount of all Items.
*/
public int getCountOfStock() {
int sumItems = 0;
for (HashMap.Entry<String, Item> set : pool.entrySet()) {
sumItems += set.getValue().getCurrentStock();
}
return sumItems;
}
}

4
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/AppTest.java

@ -35,4 +35,8 @@ public class AppTest
{
assertTrue( true );
}
public void testJenkins() {
assertTrue( true );
}
}

63
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/BirthdateTest.java

@ -0,0 +1,63 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class BirthdateTest extends TestCase {
public void testToString() {
// Given
Birthdate b = new Birthdate(1, 1, 2000);
// When
String expectedDate = "1.1.2000";
// Then
assertEquals(expectedDate, b.toString());
}
public void test_changeBirthdate() {
// Given
Birthdate b = new Birthdate(1, 1, 2000);
// Change Birthdate
b.changeBirthdate(2, 3, 2001);
// When
int expectedDay = 2;
int expectedMonth = 3;
int expectedYear = 2001;
// Then
assertEquals(2, b.getDay());
assertEquals(3, b.getMonth());
assertEquals(2001, b.getYear());
}
public void test_rejectInvalidBirthday() {
Birthdate birthdate = new Birthdate(0, 0, 0);
boolean expectedResult = false;
boolean gotResult = birthdate.isValid(0, 0, 0);
assertEquals(expectedResult, gotResult);
gotResult = birthdate.isValid(32, 13, 1990);
assertEquals(expectedResult, gotResult);
gotResult = birthdate.isValid(31, 0, 1980);
assertEquals(expectedResult, gotResult);
gotResult = birthdate.isValid(31, 13, 1980);
assertEquals(expectedResult, gotResult);
gotResult = birthdate.isValid(1, 1, 3000);
assertEquals(expectedResult, gotResult);
gotResult = birthdate.isValid(1, 1, 1900);
assertEquals(expectedResult, gotResult);
expectedResult = true;
gotResult = birthdate.isValid(1, 5, 2020);
assertEquals(expectedResult, gotResult);
}
}

177
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

@ -0,0 +1,177 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class CustomersTest extends TestCase {
public void test_nicknameIsFree() {
// Given
Customers customers = new Customers();
String availableNickname = "beastMaster64";
// When
boolean nicknameIsAvailable = customers.nickNameAvailable(availableNickname);
// Then
assertTrue(nicknameIsAvailable);
}
/**
* Register a user only when the given nickname is available.
*/
public void test_nicknameIsTaken() {
// Given
Customers customers = new Customers();
String availableNickname = "beastMaster64";
String takenNickname = "beastMaster64";
User userToRegister = new User(availableNickname);
customers.registerUser(userToRegister);
// When
boolean nicknameIsTaken = customers.nickNameAvailable(availableNickname);
// Then
assertFalse(nicknameIsTaken);
}
/**
* Register a single user and check whether it worked.
*/
public void test_registerSingleUser() {
// Given
Customers customers = new Customers();
String expectedNickNameInput = "Mougli";
User expectedNewUser = new User(expectedNickNameInput);
// Add a user
customers.registerUser(expectedNewUser);
// Get the expected User
User expectedUser = customers.getByNickname(expectedNickNameInput);
//
assertNotNull(expectedNewUser);
String expectedNickNameGotBack = expectedUser.nickName;
// When
boolean userRegistered = expectedNickNameGotBack.equals(expectedNickNameInput);
// Then
assertTrue(userRegistered);
}
/**
* Register multiple Users and then search for them in the same order.
*/
public void test_registerMultipleUsers() {
// Given
Customers customers = new Customers();
String[] expectedNickNamesInput = {"Mougli", "Tarkan", "beastMaster64", "BlaBlaPew", "MuchDoge_321"};
User[] expectedNewUsers = new User[expectedNickNamesInput.length];
for (int i = 0; i < expectedNickNamesInput.length; i++) {
// Create user
expectedNewUsers[i] = new User(expectedNickNamesInput[i]);
// Add user
customers.registerUser(expectedNewUsers[i]);
}
// Get the expected Users
User foundUser;
String expectedNickNameGotBack;
boolean userRegistered;
for (int i = 0; i < expectedNickNamesInput.length; i++) {
// Get user
foundUser = customers.getByNickname(expectedNickNamesInput[i]);
assertNotNull(foundUser);
// When
expectedNickNameGotBack = foundUser.nickName;
userRegistered = expectedNickNameGotBack.equals(expectedNickNamesInput[i]);
// Then
assertTrue(userRegistered);
}
}
/**
* Test if deletion of an allready registered customer works.
*/
public void test_removeRegisteredUser() {
// Given
Customers customers = new Customers();
String userToRemove = "beastMaster64";
User userToRegister = new User("beastMaster64");
customers.registerUser(userToRegister);
// When
boolean userExists = customers.nickNameAvailable(userToRemove);
assertFalse(userExists);
// Then
User removedUser = customers.deleteUser(userToRemove);
assertEquals(userToRemove, removedUser.nickName);
}
/**
* Register a given number of users.
*/
public void test_registerAndCountUsers() {
// Given
Customers customers = new Customers();
int expectedRegisteredUsers = 20;
int actualRegisteredUsers = -1;
String nickname;
// Prepare
for(int i = 0, j = 1; i < expectedRegisteredUsers; i++, j++) {
nickname = "beastMaster_" + j;
customers.registerUser(new User(nickname));
}
actualRegisteredUsers = customers.getCountOfUsers();
assertEquals(expectedRegisteredUsers, actualRegisteredUsers);
}
/**
* Check if the Registration of a User works as intended.
*/
public void test_createRegisterAndCheckUserData() {
// Given
Customers customers = new Customers();
String firstName = "Mia";
String lastName = "Muster";
String nickName = "harley";
String eMail = "mia@muster.de";
Birthdate birthdate = new Birthdate(30, 12, 1997);
User userToCheck = new User(firstName, lastName, nickName, eMail, birthdate);
// Register User
customers.registerUser(userToCheck);
User gotUser = customers.getByNickname(nickName);
assertNotNull(gotUser);
// When
boolean correctFirstName = "Mia".equals(gotUser.getFirstName());
boolean correctLastName = "Muster".equals(gotUser.getLastName());
boolean correctNickName = "harley".equals(gotUser.getNickName());
boolean correctEMail = "mia@muster.de".equals(gotUser.getEMail());
boolean correctBirthdate = birthdate.toString().equals(gotUser.birthdate.toString());
// Then
assertTrue(correctFirstName);
assertTrue(correctLastName);
assertTrue(correctNickName);
assertTrue(correctEMail);
assertTrue(correctBirthdate);
}
}

442
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

@ -0,0 +1,442 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class GamesTest extends TestCase {
public void test_checkConnection() {
Games testObject = new Games();
boolean expected = true;
boolean actual = testObject.checkConnection();
assertEquals(expected, actual);
}
public void test_checkGames() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkGames();
assertEquals(expected, actual);
}
public void test_checkConsoles() {
Games testObject = new Games();
String expected = "PlayStation 4, Multiplatform, Nintendo Switch, Nintendo DS, PlayStation 3, Xbox, PlayStation Portable, Nintendo 3DS, Xbox 360, PlayStation Vita";
String actual = testObject.checkConsoles();
assertEquals(expected, actual);
}
public void test_checkAllSamePublishers() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Rhythm Paradise, Super Smash Bros. Ultimate, Yakuza: Dead Souls, Jet Set Radio Future, Tomodachi Life, Beautiful Katamari, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkAllSamePublishers();
assertEquals(expected, actual);
}
public void test_checkAllDifferentPublishers() {
Games testObject = new Games();
String expected = "Atelier Totori Plus";
String actual = testObject.checkAllDifferentPublishers();
assertEquals(expected, actual);
}
public void test_checkAllSamePublishersDeveloper() {
Games testObject = new Games();
String expected = "Beautiful Katamari";
String actual = testObject.checkAllDifferentPublishersDeveloper();
assertEquals(expected, actual);
}
public void test_checkAllSameReleaseDates() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate";
String actual = testObject.checkAllSameReleaseDates();
assertEquals(expected, actual);
}
public void test_checkAllDifferentReleaseDates() {
Games testObject = new Games();
String expected = "Rhythm Paradise, Yakuza: Dead Souls, Breakdown, Persona 3 Portable, Beautiful Katamari, Atelier Totori Plus";
String actual = testObject.checkAllDifferentReleaseDates();
assertEquals(expected, actual);
}
public void test_checkGameGenres() {
Games testObject = new Games();
String expected = "JRPG, Action-Adventure, Tactical role-playing, Strategy, Rhythm, Fighting, Survival Horror, Action, Adventure, RPG, Life Simulation, Puzzle, Platformer";
String actual = testObject.checkGameGenres();
assertEquals(expected, actual);
}
public void test_checkGameGenreActionAdventure() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Breakdown";
String actual = testObject.checkGameGenreActionAdventure();
assertEquals(expected, actual);
}
public void test_checkGameGenreRPG() {
Games testObject = new Games();
String expected = "Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkGameGenreRPG();
assertEquals(expected, actual);
}
public void test_checkConsolePlayStation() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkConsolePlayStation();
assertEquals(expected, actual);
}
public void test_checkConsoleNintendo() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life";
String actual = testObject.checkConsoleNintendo();
assertEquals(expected, actual);
}
public void test_checkConsoleXbox() {
Games testObject = new Games();
String expected = "Jet Set Radio Future, Breakdown, Beautiful Katamari";
String actual = testObject.checkConsoleXbox();
assertEquals(expected, actual);
}
public void test_checkConsoleMultiplatform() {
Games testObject = new Games();
String expected = "Ratchet & Clank, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkConsoleMultiplatform();
assertEquals(expected, actual);
}
public void test_checkConsoleNintendoSwitch() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate";
String actual = testObject.checkConsoleNintendoSwitch();
assertEquals(expected, actual);
}
public void test_checkDeveloperAtlus() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Persona 3 Portable";
String actual = testObject.checkDeveloperAtlus();
assertEquals(expected, actual);
}
public void test_checkDevelopers() {
Games testObject = new Games();
String expected = "Atlus, Insomniac Games, Platinum Games, Intelligent Systems, Artdink, Nintendo SPD, Sora Ltd., Ryu Ga Gotoku Studio, Sega Sports R&D, Namco, Spike Chunsoft, Bandai Namco Games, Gust Co. Ltd., Vicarious Visions";
String actual = testObject.checkDevelopers();
assertEquals(expected, actual);
}
public void test_checkPublisherNintendo() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life";
String actual = testObject.checkPublisherNintendo();
assertEquals(expected, actual);
}
public void test_checkPublisherSega() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Jet Set Radio Future";
String actual = testObject.checkPublisherSega();
assertEquals(expected, actual);
}
public void test_checkPublishers() {
Games testObject = new Games();
String expected = "Sega, Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Electronic Arts, Namco, Numskull Games, Spike Chunsoft, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Gust Co. Ltd., Tecmo Koei America, Activision";
String actual = testObject.checkPublishers();
assertEquals(expected, actual);
}
public void test_checkPublishersEu() {
Games testObject = new Games();
String expected = "Sega, Sony Computer Entertainment, Nintendo, Electronic Arts, Numskull Games, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Activision";
String actual = testObject.checkPublishersEu();
assertEquals(expected, actual);
}
public void test_checkPublishersJp() {
Games testObject = new Games();
String expected = "Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Gust Co. Ltd., Activision";
String actual = testObject.checkPublishersJp();
assertEquals(expected, actual);
}
public void test_checkPublishersNa() {
Games testObject = new Games();
String expected = "Atlus, Sony Computer Entertainment, Nintendo, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Tecmo Koei America, Activision";
String actual = testObject.checkPublishersNa();
assertEquals(expected, actual);
}
public void test_checkReleaseDateUnknown() {
Games testObject = new Games();
String expected = "Breakdown, Atelier Totori Plus";
String actual = testObject.checkReleaseDateUnknown();
assertEquals(expected, actual);
}
public void test_checkAllSameReleaseYear() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Jet Set Radio Future, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkAllSameReleaseYear();
assertEquals(expected, actual);
}
public void test_checkAllDifferentReleaseYear() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Rhythm Paradise, Yakuza: Dead Souls, Breakdown, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus";
String actual = testObject.checkAllDifferentReleaseYear();
assertEquals(expected, actual);
}
public void test_checkAllSameReleaseMonth() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, AI: The Somnium Files";
String actual = testObject.checkAllSameReleaseMonth();
assertEquals(expected, actual);
}
public void test_checkAllDifferentReleaseMonth() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Rhythm Paradise, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkAllDifferentReleaseMonth();
assertEquals(expected, actual);
}
public void test_checkOnePlayer() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkOnePlayer();
assertEquals(expected, actual);
}
public void test_checkTwoPlayer() {
Games testObject = new Games();
String expected = "Astral Chain, Super Smash Bros. Ultimate, Jet Set Radio Future";
String actual = testObject.checkTwoPlayer();
assertEquals(expected, actual);
}
public void test_checkFourPlayer() {
Games testObject = new Games();
String expected = "Super Smash Bros. Ultimate, Jet Set Radio Future";
String actual = testObject.checkFourPlayer();
assertEquals(expected, actual);
}
public void test_checkEightPlayer() {
Games testObject = new Games();
String expected = "Super Smash Bros. Ultimate";
String actual = testObject.checkEightPlayer();
assertEquals(expected, actual);
}
public void test_checkOnePlayerOnly() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Yakuza: Dead Souls, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkOnePlayerOnly();
assertEquals(expected, actual);
}
public void test_checkUskZero() {
Games testObject = new Games();
String expected = "Rhythm Paradise, Tomodachi Life, Beautiful Katamari";
String actual = testObject.checkUskZero();
assertEquals(expected, actual);
}
public void test_checkUskSix() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkUskSix();
assertEquals(expected, actual);
}
public void test_checkUskTwelve() {
Games testObject = new Games();
String expected = "Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Jet Set Radio Future, Persona 3 Portable";
String actual = testObject.checkUskTwelve();
assertEquals(expected, actual);
}
public void test_checkUskSixteen() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Astral Chain, Breakdown, AI: The Somnium Files";
String actual = testObject.checkUskSixteen();
assertEquals(expected, actual);
}
public void test_checkUskEighteen() {
Games testObject = new Games();
String expected = "Yakuza: Dead Souls";
String actual = testObject.checkUskEighteen();
assertEquals(expected, actual);
}
public void test_checkPegiThree() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Rhythm Paradise, Tomodachi Life, Beautiful Katamari";
String actual = testObject.checkPegiThree();
assertEquals(expected, actual);
}
public void test_checkPegiSeven() {
Games testObject = new Games();
String expected = "Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkPegiSeven();
assertEquals(expected, actual);
}
public void test_checkPegiTwelve() {
Games testObject = new Games();
String expected = "Fire Emblem: Three Houses, Triangle Strategy, Super Smash Bros. Ultimate, Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkPegiTwelve();
assertEquals(expected, actual);
}
public void test_checkPegiSixteen() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Astral Chain";
String actual = testObject.checkPegiSixteen();
assertEquals(expected, actual);
}
public void test_checkPegiEighteen() {
Games testObject = new Games();
String expected = "Yakuza: Dead Souls, Breakdown, AI: The Somnium Files";
String actual = testObject.checkPegiEighteen();
assertEquals(expected, actual);
}
public void test_checkPegiUnknown() {
Games testObject = new Games();
String expected = "Jet Set Radio Future";
String actual = testObject.checkPegiUnknown();
assertEquals(expected, actual);
}
public void test_checkEsrbE() {
Games testObject = new Games();
String expected = "Rhythm Paradise, Tomodachi Life, Beautiful Katamari";
String actual = testObject.checkEsrbE();
assertEquals(expected, actual);
}
public void test_checkEsrbEten() {
Games testObject = new Games();
String expected = "Super Smash Bros. Ultimate, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkEsrbEten();
assertEquals(expected, actual);
}
public void test_checkEsrbT() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Jet Set Radio Future, Atelier Totori Plus";
String actual = testObject.checkEsrbT();
assertEquals(expected, actual);
}
public void test_checkEsrbM() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Breakdown, AI: The Somnium Files, Persona 3 Portable";
String actual = testObject.checkEsrbM();
assertEquals(expected, actual);
}
public void test_checkCeroA() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Rhythm Paradise, Super Smash Bros. Ultimate, Jet Set Radio Future, Tomodachi Life, Beautiful Katamari, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkCeroA();
assertEquals(expected, actual);
}
public void test_checkCeroB() {
Games testObject = new Games();
String expected = "Fire Emblem: Three Houses, Persona 3 Portable, Atelier Totori Plus";
String actual = testObject.checkCeroB();
assertEquals(expected, actual);
}
public void test_checkCeroC() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Astral Chain, Triangle Strategy, Breakdown";
String actual = testObject.checkCeroC();
assertEquals(expected, actual);
}
public void test_checkCeroD() {
Games testObject = new Games();
String expected = "Yakuza: Dead Souls";
String actual = testObject.checkCeroD();
assertEquals(expected, actual);
}
public void test_checkCeroZ() {
Games testObject = new Games();
String expected = "AI: The Somnium Files";
String actual = testObject.checkCeroZ();
assertEquals(expected, actual);
}
public void test_checkAcbG() {
Games testObject = new Games();
String expected = "Rhythm Paradise, Beautiful Katamari";
String actual = testObject.checkAcbG();
assertEquals(expected, actual);
}
public void test_checkAcbPg() {
Games testObject = new Games();
String expected = "Ratchet & Clank, Super Smash Bros. Ultimate, Tomodachi Life, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkAcbPg();
assertEquals(expected, actual);
}
public void test_checkAcbM() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Jet Set Radio Future";
String actual = testObject.checkAcbM();
assertEquals(expected, actual);
}
public void test_checkAcbMaFifteen() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Breakdown, AI: The Somnium Files, Persona 3 Portable";
String actual = testObject.checkAcbMaFifteen();
assertEquals(expected, actual);
}
public void test_checkAcbReighteen() {
Games testObject = new Games();
String expected = "Atelier Totori Plus";
String actual = testObject.checkAcbReighteen();
assertEquals(expected, actual);
}
public void test_printTable() {
Games testObject = new Games();
String expected = "Name, Console, Developer, Publisher EU, Publisher JP, Publisher NA, Genre, Release EU, Release JP, Release NA, Release AU, USK Rating, PEGI Rating, ESRB Rating, CERO Rating, ACB Rating, Players\n"
+ "\n"
+ "Persona 5 Royal, PlayStation 4, Atlus, Sega, Atlus, Atlus, JRPG, 31.03.2020, 31.10.2019, 31.03.2020, 31.03.2020, 16, 16, M, C, MA 15+, 1\n"
+ "Ratchet & Clank, Multiplatform, Insomniac Games, Sony Computer Entertainment, Sony Computer Entertainment, Sony Computer Entertainment, Action-Adventure, 08.11.2002, 03.12.2002, 04.11.2002, 08.11.2002, 6, 3, T, A, PG, 1\n"
+ "Astral Chain, Nintendo Switch, Platinum Games, Nintendo, Nintendo, Nintendo, Action-Adventure, 30.08.2019, 30.08.2019, 30.08.2019, 30.08.2019, 16, 16, T, C, M, 1-2\n"
+ "Fire Emblem: Three Houses, Nintendo Switch, Intelligent Systems, Nintendo, Nintendo, Nintendo, Tactical role-playing, 26.07.2019, 26.07.2019, 26.07.2019, 26.07.2019, 12, 12, T, B, M, 1\n"
+ "Triangle Strategy, Nintendo Switch, Artdink, Nintendo, Square Enix, Nintendo, Strategy, 04.03.2022, 04.03.2022, 04.03.2022, 04.03.2022, 12, 12, T, C, M, 1\n"
+ "Rhythm Paradise, Nintendo DS, Nintendo SPD, Nintendo, Nintendo, Nintendo, Rhythm, 01.05.2009, 31.07.2008, 05.04.2009, 04.06.2009, 0, 3, E, A, G, 1\n"
+ "Super Smash Bros. Ultimate, Nintendo Switch, Sora Ltd., Nintendo, Nintendo, Nintendo, Fighting, 07.12.2018, 07.12.2018, 07.12.2018, 07.12.2018, 12, 12, E10+, A, PG, 1-8\n"
+ "Yakuza: Dead Souls, PlayStation 3, Ryu Ga Gotoku Studio, Sega, Sega, Sega, Survival Horror, 16.03.2012, 09.06.2011, 13.03.2012, 15.03.2012, 18, 18, M, D, MA 15+, 1\n"
+ "Jet Set Radio Future, Xbox, Sega Sports R&D, Sega, Sega, Sega, Action, 14.03.2002, 22.02.2002, 25.02.2002, 14.03.2002, 12, Unknown, T, A, M, 1-4\n"
+ "Breakdown, Xbox, Namco, Electronic Arts, Namco, Namco, Action-Adventure, 18.06.2004, 29.01.2004, 16.03.2004, Unknown, 16, 18, M, C, MA 15+, 1\n"
+ "AI: The Somnium Files, Multiplatform, Spike Chunsoft, Numskull Games, Spike Chunsoft, Spike Chunsoft, Adventure, 20.09.2019, 19.09.2019, 17.09.2019, 20.09.2019, 16, 18, M, Z, MA 15+, 1\n"
+ "Persona 3 Portable, PlayStation Portable, Atlus, Ghostlight, Atlus, Atlus, RPG, 29.04.2011, 01.11.2009, 06.07.2010, 16.11.2011, 12, 12, M, B, MA 15+, 1\n"
+ "Tomodachi Life, Nintendo 3DS, Nintendo SPD, Nintendo, Nintendo, Nintendo, Life Simulation, 06.06.2014, 18.04.2013, 06.06.2014, 07.06.2014, 0, 3, E, A, PG, 1\n"
+ "Beautiful Katamari, Xbox 360, Bandai Namco Games, Bandai Namco Games, Bandai Namco Games, Bandai Namco Games, Puzzle, 29.02.2008, 16.10.2007, 18.10.2007, 07.03.2008, 0, 3, E, A, G, 1\n"
+ "Atelier Totori Plus, PlayStation Vita, Gust Co. Ltd., Tecmo Koei Europe, Gust Co. Ltd., Tecmo Koei America, RPG, 20.03.2013, 29.11.2012, 19.03.2013, Unknown, 6, 12, T, B, R 18+, 1\n"
+ "Crash Bandicoot N. Sane Trilogy, Multiplatform, Vicarious Visions, Activision, Activision, Activision, Platformer, 30.06.2017, 03.08.2017, 30.06.2017, 30.06.2017, 6, 7, E10+, A, PG, 1";
String actual = testObject.printTable();
assertEquals(expected, actual);
}
}

89
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java

@ -0,0 +1,89 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class ItemTest extends TestCase {
/**
* No Items are in Stock.
* Check the inStock() Method.
*/
public void test_ItemNotInStock() {
// Given
Item item = new Item();
// When
boolean notInStock = item.inStock();
// Then
assertFalse(notInStock);
}
/**
* Stock is not Empty.
* Check the inStock() Method.
*/
public void test_ItemInStock() {
// Given
Item item = new Item();
item.updateAvailability(1);
// When
boolean inStock = item.inStock();
// Then
assertTrue(inStock);
}
/**
* One and the same type of an item costs the same.
* check getCurrentPrice()
*/
public void test_priceOfMultipleIdenticalItems() {
// Given
Item item = new Item();
int quantity = 3;
float price = 5;
item.updateAvailability(quantity);
item.updatePrice(price);
// When
float expectedPrice = quantity * price;
// Then
float actualPrice = 0;
for(int i = 0; i < quantity; i++) {
actualPrice += item.getCurrentPrice();
}
assertEquals(expectedPrice, actualPrice);
}
/**
* Check if creating a complete item with all attributes works as intended.
*/
public void test_buildCompleteItem() {
// Given
String expectedTitel = "Logitec Maus";
String expectedDescription = "Gaming Maus fuer Fortgeschrittene.";
int expectedQuantity = 10;
float expectedPrice = 69.99f;
// When
Item itemNotNull = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice);
// Then
assertNotNull(itemNotNull);
// When
boolean validDescription = itemNotNull.getDescription().equals(expectedDescription);
assertTrue(validDescription);
boolean validTitle = itemNotNull.getTitel().equals(expectedTitel);
assertTrue(validTitle);
boolean validQuantity = itemNotNull.getCurrentStock() == expectedQuantity;
assertTrue(validQuantity);
boolean validPrice = itemNotNull.getCurrentPrice() == expectedPrice;
assertTrue(validPrice);
}
}

23
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/UserTest.java

@ -0,0 +1,23 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class UserTest extends TestCase {
/**
* Create User with a valid Birthday and check whether it worked as intended.
*/
public void test_initAndGetBirthdayOfUser() {
// Given
Customers customers = new Customers();
String firstName = "Mia";
String lastName = "Muster";
String nickName = "harley";
String eMail = "mia@muster.de";
int DD = 30, MM = 12, YYYY = 1997;
String expectedBirthdate = new Birthdate(DD, MM, YYYY).toString();
User userToCheck = new User(firstName, lastName, nickName, eMail, new Birthdate(DD, MM, YYYY));
String gotBirthdate = userToCheck.getBirthdate().toString();
boolean gotExpectedBirthdayBack = gotBirthdate.equals(expectedBirthdate);
}
}

63
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java

@ -0,0 +1,63 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class WarehouseTest extends TestCase {
/**
* Check if the insertion of an Item works properly.
*/
public void test_insertItemInWarehouse() {
// Given
Warehouse warehouse = new Warehouse();
String expectedTitel = "Logitec Maus";
String expectedDescription = "Gaming Maus fuer Fortgeschrittene.";
int expectedQuantity = 10;
float expectedPrice = 69.69f;
// When
Item expectedItem = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice);
assertNotNull(expectedItem);
warehouse.insertItem(expectedItem);
Item gotItem = warehouse.pool.get(expectedTitel);
// Then
assertEquals(expectedTitel, gotItem.getTitel());
}
/**
* Test the total Sum of Items in the whole Warehouse.
*/
public void test_growingCountOfItemsInWarehouse() {
// Given
Warehouse warehouse = new Warehouse();
int unitsPerItemType = 3;
int expectedSize = 13;
for (int i = 0; i < expectedSize; i++) {
Item item = new Item("ItemDummy" + i, "DescriptionDummy" + i, unitsPerItemType, 12.0f);
warehouse.insertItem(item);
}
int expectedSum = expectedSize * unitsPerItemType;
int actualSumOfAllItems = warehouse.getCountOfStock();
// Then
assertEquals(expectedSum, actualSumOfAllItems);
}
/**
* Empty Warehouse means there are a total of zero Items.
*/
public void test_emptyWarehouse() {
// Given
Warehouse warehouse = new Warehouse();
// When
int expectedSum = 0;
// Then
int actualSumOfAllItems = warehouse.getCountOfStock();
assertEquals(expectedSum, actualSumOfAllItems);
}
}
Loading…
Cancel
Save