diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4b661a5..accd629 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 43c1af2..2d2ec6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,6 +8,7 @@
ProductInventoryLab
1.0-SNAPSHOT
+
@@ -22,4 +23,19 @@
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.4.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.4.2
+ test
+
+
+
\ No newline at end of file
diff --git a/src/main/java/models/Sneaker.java b/src/main/java/models/Sneaker.java
new file mode 100644
index 0000000..643144d
--- /dev/null
+++ b/src/main/java/models/Sneaker.java
@@ -0,0 +1,82 @@
+package models;
+
+public class Sneaker {
+ private Integer id;
+ private String name;
+ private String brand;
+ private String sport;
+ private int size;
+ private int qty;
+ private float price;
+
+ public Sneaker(){
+ this(0, null, null, null, 0, 0, 0);
+ }
+
+ public Sneaker(Integer id, String name, String brand, String sport, int size, int qty, float price) {
+ this.id = id;
+ this.name = name;
+ this.brand = brand;
+ this.sport = sport;
+ this.size = size;
+ this.qty = qty;
+ this.price = price;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getSport() {
+ return sport;
+ }
+
+ public void setSport(String sport) {
+ this.sport = sport;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public int getQty() {
+ return qty;
+ }
+
+ public void setQty(int qty) {
+ this.qty = qty;
+ }
+
+ public float getPrice() {
+ return price;
+ }
+
+ public void setPrice(float price) {
+ this.price = price;
+ }
+}
diff --git a/src/main/java/models/Whiskey.java b/src/main/java/models/Whiskey.java
new file mode 100644
index 0000000..d26b56b
--- /dev/null
+++ b/src/main/java/models/Whiskey.java
@@ -0,0 +1,82 @@
+package models;
+
+public class Whiskey {
+ private Integer id;
+ private String name;
+ private String brand;
+ private String location;
+ private int size;
+ private int qty;
+ private float price;
+
+ public Whiskey(){
+ this(0, null, null, null, 0, 0, 0);
+ }
+
+ public Whiskey(Integer id, String name, String brand, String location, int size, int qty, float price) {
+ this.id = id;
+ this.name = name;
+ this.brand = brand;
+ this.location = location;
+ this.size = size;
+ this.qty = qty;
+ this.price = price;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public int getQty() {
+ return qty;
+ }
+
+ public void setQty(int qty) {
+ this.qty = qty;
+ }
+
+ public float getPrice() {
+ return price;
+ }
+
+ public void setPrice(float price) {
+ this.price = price;
+ }
+}
diff --git a/src/main/java/services/SneakerService.java b/src/main/java/services/SneakerService.java
new file mode 100644
index 0000000..16a800d
--- /dev/null
+++ b/src/main/java/services/SneakerService.java
@@ -0,0 +1,58 @@
+package services;
+
+import models.Sneaker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SneakerService {
+ private static Integer nextId = 1;
+
+ public List getInventory() {
+ return inventory;
+ }
+
+ private List inventory = new ArrayList<>();
+
+ public Sneaker create(String name, String brand, String sport, int size, int quantity, float price) {
+
+ Sneaker createdSneaker = new Sneaker(nextId++, name, brand, sport, size, quantity, price);
+
+ inventory.add(createdSneaker);
+
+ return createdSneaker;
+ }
+
+
+
+ //read
+ public Sneaker findSneaker(Integer id) {
+ for (Sneaker s : inventory){
+ if (id.equals(s.getId())){
+ return s;
+ }
+ }
+ return null;
+ }
+
+ //read all
+ public Sneaker[] findAll() {
+ Sneaker[] array = new Sneaker[inventory.size()];
+ array = inventory.toArray(array);
+ return array;
+ }
+
+ //delete
+ public boolean delete(Integer id) {
+ // should remove the object with this id from the ArrayList if exits and return true.
+ // Otherwise return false
+
+ for (Sneaker s : inventory){
+ if (id.equals(s.getId())){
+ inventory.remove(s);
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/services/WhiskeyService.java b/src/main/java/services/WhiskeyService.java
new file mode 100644
index 0000000..efad4f8
--- /dev/null
+++ b/src/main/java/services/WhiskeyService.java
@@ -0,0 +1,60 @@
+package services;
+
+import models.Sneaker;
+import models.Whiskey;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class WhiskeyService {
+
+ private static Integer nextId = 1;
+
+ public List getInventory() {
+ return inventory;
+ }
+
+ private List inventory = new ArrayList<>();
+
+ public Whiskey create(String name, String brand, String location, int size, int quantity, float price) {
+
+ Whiskey createdWhiskey = new Whiskey(nextId++, name, brand, location, size, quantity, price);
+
+ inventory.add(createdWhiskey);
+
+ return createdWhiskey;
+ }
+
+
+
+ //read
+ public Whiskey findWhiskey(Integer id) {
+ for (Whiskey w : inventory){
+ if (id.equals(w.getId())){
+ return w;
+ }
+ }
+ return null;
+ }
+
+ //read all
+ public Whiskey[] findAll() {
+ Whiskey[] array = new Whiskey[inventory.size()];
+ array = inventory.toArray(array);
+ return array;
+ }
+
+ //delete
+ public boolean delete(Integer id) {
+ // should remove the object with this id from the ArrayList if exits and return true.
+ // Otherwise return false
+
+ for (Whiskey w : inventory){
+ if (id.equals(w.getId())){
+ inventory.remove(w);
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/test/java/models/SneakerTest.java b/src/test/java/models/SneakerTest.java
new file mode 100644
index 0000000..bbb1b48
--- /dev/null
+++ b/src/test/java/models/SneakerTest.java
@@ -0,0 +1,122 @@
+package models;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class SneakerTest {
+
+ Sneaker testSneaker = new Sneaker();
+ @Test
+ public void setNameTest() {
+ // given (1)
+ String expected = "OZWEEGO";
+
+ // when (2)
+ testSneaker.setName(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getName());
+ }
+
+ @Test
+ public void setBrandTest() {
+ // given (1)
+ String expected = "Adidas";
+
+ // when (2)
+ testSneaker.setBrand(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getBrand());
+ }
+
+ @Test
+ public void setIdTest() {
+ // given (1)
+ Integer expected = 1;
+
+ // when (2)
+ testSneaker.setId(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getId());
+ }
+
+ @Test
+ public void setSportTest() {
+ // given (1)
+ String expected = "Tennis";
+
+ // when (2)
+ testSneaker.setSport(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getSport());
+ }
+
+ @Test
+ public void setSizeTest() {
+ // given (1)
+ int expected = 10;
+
+ // when (2)
+ testSneaker.setSize(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getSize());
+ }
+
+ @Test
+ public void setQtyTest() {
+ // given (1)
+ int expected = 20;
+
+ // when (2)
+ testSneaker.setQty(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getQty());
+ }
+
+ @Test
+ public void setPriceTest() {
+ // given (1)
+ float expected = 84.99F;
+
+ // when (2)
+ testSneaker.setPrice(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testSneaker.getPrice());
+ }
+
+ @Test // (1)
+ public void constructorTest(){
+
+ // (2)
+ int expectedId = 6;
+ String expectedName = "Stan Smith";
+ String expectedBrand = "Adidas";
+ String expectedSport = "Tennnis";
+ int expectedSize = 10;
+ int expectedQty = 10;
+ float expectedPrice = 80.00f;
+
+ // (3)
+ Sneaker testSneaker = new Sneaker(expectedId, expectedName, expectedBrand,
+ expectedSport, expectedSize, expectedQty,expectedPrice);
+
+ // (4)
+ Assertions.assertEquals(expectedId, testSneaker.getId());
+ Assertions.assertEquals(expectedName, testSneaker.getName());
+ Assertions.assertEquals(expectedBrand, testSneaker.getBrand());
+ Assertions.assertEquals(expectedSport, testSneaker.getSport());
+ Assertions.assertEquals(expectedSize, testSneaker.getSize());
+ Assertions.assertEquals(expectedQty, testSneaker.getQty());
+ Assertions.assertEquals(expectedPrice, testSneaker.getPrice());
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/models/WhiskeyTest.java b/src/test/java/models/WhiskeyTest.java
new file mode 100644
index 0000000..890b2e8
--- /dev/null
+++ b/src/test/java/models/WhiskeyTest.java
@@ -0,0 +1,121 @@
+package models;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class WhiskeyTest {
+ Whiskey testWhiskey = new Whiskey();
+ @Test
+ public void setNameTest() {
+ // given (1)
+ String expected = "Original";
+
+ // when (2)
+ testWhiskey.setName(expected);
+
+ // then (3)
+ assertEquals(expected, testWhiskey.getName());
+ }
+
+ @Test
+ public void setBrandTest() {
+ // given (1)
+ String expected = "Jameson";
+
+ // when (2)
+ testWhiskey.setBrand(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testWhiskey.getBrand());
+ }
+
+ @Test
+ public void setIdTest() {
+ // given (1)
+ Integer expected = 1;
+
+ // when (2)
+ testWhiskey.setId(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testWhiskey.getId());
+ }
+
+ @Test
+ public void setLocationTest() {
+ // given (1)
+ String expected = "Ireland";
+
+ // when (2)
+ testWhiskey.setLocation(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testWhiskey.getLocation());
+ }
+
+ @Test
+ public void setSizeTest() {
+ // given (1)
+ int expected = 750;
+
+ // when (2)
+ testWhiskey.setSize(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testWhiskey.getSize());
+ }
+
+ @Test
+ public void setQtyTest() {
+ // given (1)
+ int expected = 20;
+
+ // when (2)
+ testWhiskey.setQty(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testWhiskey.getQty());
+ }
+
+ @Test
+ public void setPriceTest() {
+ // given (1)
+ float expected = 27.99F;
+
+ // when (2)
+ testWhiskey.setPrice(expected);
+
+ // then (3)
+ Assertions.assertEquals(expected, testWhiskey.getPrice());
+ }
+
+ @Test // (1)
+ public void constructorTest(){
+
+ // (2)
+ int expectedId = 6;
+ String expectedName = "Black";
+ String expectedBrand = "Johnnie Walker";
+ String expectedLocation = "Scotland";
+ int expectedSize = 750;
+ int expectedQty = 10;
+ float expectedPrice = 47.99f;
+
+ // (3)
+ Whiskey testWhiskey = new Whiskey(expectedId, expectedName, expectedBrand,
+ expectedLocation, expectedSize, expectedQty,expectedPrice);
+
+ // (4)
+ Assertions.assertEquals(expectedId, testWhiskey.getId());
+ Assertions.assertEquals(expectedName, testWhiskey.getName());
+ Assertions.assertEquals(expectedBrand, testWhiskey.getBrand());
+ Assertions.assertEquals(expectedLocation, testWhiskey.getLocation());
+ Assertions.assertEquals(expectedSize, testWhiskey.getSize());
+ Assertions.assertEquals(expectedQty, testWhiskey.getQty());
+ Assertions.assertEquals(expectedPrice, testWhiskey.getPrice());
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/services/SneakerServiceTest.java b/src/test/java/services/SneakerServiceTest.java
new file mode 100644
index 0000000..af26b04
--- /dev/null
+++ b/src/test/java/services/SneakerServiceTest.java
@@ -0,0 +1,115 @@
+package services;
+
+import models.Sneaker;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class SneakerServiceTest {
+ @Test
+ public void createTest(){
+
+ // Given
+ String expectedName = "Stan Smith";
+ String expectedBrand = "Adidas";
+ String expectedSport = "Tennis";
+ int expectedSize = 10;
+ int expectedQty = 10;
+ float expectedPrice = 80.00f;
+
+ SneakerService sneakerService = new SneakerService();
+ Sneaker testSneaker = sneakerService.create(expectedName, expectedBrand,
+ expectedSport, expectedSize, expectedQty, expectedPrice);
+
+ // When
+ int actualId = testSneaker.getId();
+ String actualName = testSneaker.getName();
+ String actualBrand = testSneaker.getBrand();
+ String actualSport = testSneaker.getSport();
+ int actualSize = testSneaker.getSize();
+ int actualQty = testSneaker.getQty();
+ float actualPrice = testSneaker.getPrice();
+
+ // Then
+ Assertions.assertEquals(Integer.class.getName(), new Integer(actualId).getClass().getName());
+ Assertions.assertEquals(expectedName, actualName);
+ Assertions.assertEquals(expectedBrand, actualBrand);
+ Assertions.assertEquals(expectedSport, actualSport);
+ Assertions.assertEquals(expectedSize, actualSize);
+ Assertions.assertEquals(expectedQty, actualQty);
+ Assertions.assertEquals(expectedPrice, actualPrice);
+
+ }
+
+ @Test
+ void findSneakerTest() {
+ SneakerService sneakerService = new SneakerService();
+ Sneaker expected = sneakerService.create("Stan Smith", "Adidas",
+ "Tennis", 10, 10, 80.00f);
+
+ Sneaker actual = sneakerService.findSneaker(expected.getId());
+
+ Assertions.assertEquals(expected, actual);
+
+ }
+
+ @Test
+ void findSneakerTest2() {
+ SneakerService s = new SneakerService();
+ Sneaker sneaker1 = s.create("Stan Smith", "Adidas",
+ "Tennis", 10, 10, 80.00f);
+ Sneaker sneaker2 = s.create("Gao Go", "Nike",
+ "Running", 7, 20, 90.00f);
+ Sneaker sneaker3 = s.create("Dad Shoe", "New Balance",
+ "Basketball", 9, 5, 100.00f);
+
+ Sneaker actual = s.findSneaker(sneaker2.getId());
+
+ Assertions.assertEquals(sneaker2, actual);
+
+ }
+
+ @Test
+ void findAllTest() {
+
+ }
+
+ @Test
+ void deleteTest() {
+ SneakerService s = new SneakerService();
+ Sneaker sneaker1 = s.create("Stan Smith", "Adidas",
+ "Tennis", 10, 10, 80.00f);
+ Sneaker sneaker2 = s.create("Gao Go", "Nike",
+ "Running", 7, 20, 90.00f);
+ Sneaker sneaker3 = s.create("Dad Shoe", "New Balance",
+ "Basketball", 9, 5, 100.00f);
+
+ int expected = 2;
+ boolean test = s.delete(sneaker1.getId());
+
+ int actual = s.getInventory().size();
+
+ Assertions.assertEquals(true, test);
+ Assertions.assertEquals(expected, actual);
+
+ }
+
+ @Test
+ void deleteTest2() {
+ SneakerService s = new SneakerService();
+ Sneaker sneaker1 = s.create("Stan Smith", "Adidas",
+ "Tennis", 10, 10, 80.00f);
+ Sneaker sneaker2 = s.create("Gao Go", "Nike",
+ "Running", 7, 20, 90.00f);
+
+ int expected = 1;
+ boolean test = s.delete(sneaker2.getId());
+
+ int actual = s.getInventory().size();
+
+ Assertions.assertEquals(true, test);
+ Assertions.assertEquals(expected, actual);
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/services/WhiskeyServiceTest.java b/src/test/java/services/WhiskeyServiceTest.java
new file mode 100644
index 0000000..3cd3976
--- /dev/null
+++ b/src/test/java/services/WhiskeyServiceTest.java
@@ -0,0 +1,120 @@
+package services;
+
+import models.Sneaker;
+import models.Whiskey;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class WhiskeyServiceTest {
+
+ @Test
+ public void createTest(){
+
+ // Given
+ int expectedId = 6;
+ String expectedName = "Black";
+ String expectedBrand = "Johnnie Walker";
+ String expectedLocation = "Scotland";
+ int expectedSize = 750;
+ int expectedQty = 10;
+ float expectedPrice = 47.99f;
+
+ WhiskeyService whiskeyService = new WhiskeyService();
+ Whiskey testWhiskey = whiskeyService.create(expectedName, expectedBrand,
+ expectedLocation, expectedSize, expectedQty, expectedPrice);
+
+ // When
+ int actualId = testWhiskey.getId();
+ String actualName = testWhiskey.getName();
+ String actualBrand = testWhiskey.getBrand();
+ String actualSport = testWhiskey.getLocation();
+ int actualSize = testWhiskey.getSize();
+ int actualQty = testWhiskey.getQty();
+ float actualPrice = testWhiskey.getPrice();
+
+ // Then
+ Assertions.assertEquals(Integer.class.getName(), new Integer(actualId).getClass().getName());
+ Assertions.assertEquals(expectedName, actualName);
+ Assertions.assertEquals(expectedBrand, actualBrand);
+ Assertions.assertEquals(expectedLocation, actualSport);
+ Assertions.assertEquals(expectedSize, actualSize);
+ Assertions.assertEquals(expectedQty, actualQty);
+ Assertions.assertEquals(expectedPrice, actualPrice);
+
+ }
+
+ @Test
+ void findSneakerTest() {
+ WhiskeyService whiskeyService = new WhiskeyService();
+ Whiskey expected = whiskeyService.create("Blue", "Johnnie Walker",
+ "Scotland", 750, 10, 47.99f);
+
+ Whiskey actual = whiskeyService.findWhiskey(expected.getId());
+
+ Assertions.assertEquals(expected, actual);
+
+ }
+
+ @Test
+ void findSneakerTest2() {
+ WhiskeyService w = new WhiskeyService();
+ Whiskey whiskey1 = w.create("Blue", "Johnnie Walker",
+ "Scotland", 750, 10, 47.99f);
+ Whiskey whiskey2 = w.create("Original", "Jameson",
+ "Ireland", 1000, 20, 32.99f);
+ Whiskey whiskey3 = w.create("Straight", "Jim Beam",
+ "Kentucky", 1500, 5, 38.99f);
+
+ Whiskey actual = w.findWhiskey(whiskey2.getId());
+
+ Assertions.assertEquals(whiskey2, actual);
+
+ }
+
+ @Test
+ void findAllTest() {
+
+ }
+
+ @Test
+ void deleteTest() {
+ WhiskeyService w = new WhiskeyService();
+ Whiskey whiskey1 = w.create("Blue", "Johnnie Walker",
+ "Scotland", 750, 10, 47.99f);
+ Whiskey whiskey2 = w.create("Original", "Jameson",
+ "Ireland", 1000, 20, 32.99f);
+ Whiskey whiskey3 = w.create("Straight", "Jim Beam",
+ "Kentucky", 1500, 5, 38.99f);
+
+ int expected = 2;
+ boolean test = w.delete(whiskey1.getId());
+
+ int actual = w.getInventory().size();
+
+ Assertions.assertEquals(true, test);
+ Assertions.assertEquals(expected, actual);
+
+ }
+
+ @Test
+ void deleteTest2() {
+ WhiskeyService w = new WhiskeyService();
+ Whiskey whiskey1 = w.create("Blue", "Johnnie Walker",
+ "Scotland", 750, 10, 47.99f);
+ Whiskey whiskey2 = w.create("Original", "Jameson",
+ "Ireland", 1000, 20, 32.99f);
+
+
+ int expected = 1;
+ boolean test = w.delete(whiskey2.getId());
+
+ int actual = w.getInventory().size();
+
+ Assertions.assertEquals(true, test);
+ Assertions.assertEquals(expected, actual);
+
+ }
+
+}
\ No newline at end of file