Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
<groupId>io.zipcodewilmington</groupId>
<artifactId>ProductInventoryLab</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
Expand Down
71 changes: 71 additions & 0 deletions src/main/java/models/Pandas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package models;

public class Pandas {
private int id;
private String name;
private String species ;
private int age;
private int qty;
private float price;

public Pandas() {

}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSpecies() {
return species;
}

public void setSpecies(String species) {
this.species = species;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

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;
}

public Pandas(int id, String name, String species, int age, int qty, float price) {
this.id = id;
this.name = name;
this.species = species;
this.age = age;
this.qty = qty;
this.price = price;
}
}
74 changes: 74 additions & 0 deletions src/main/java/models/Toaster.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package models;

public class Toaster {
private int id;
private String name;
private String brand;
private int toastSlots;
private int qty;
private float price;

public Toaster() {

}




public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getBrand() {
return brand;
}

public void setBrand(String brand) {
this.brand = brand;
}

public int getToastSlots() {
return toastSlots;
}

public void setToastSlots(int toastSlots) {
this.toastSlots = toastSlots;
}

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;
}

public Toaster(int id, String name, String brand, int toastSlots, int qty, float price) {
this.id = id;
this.name = name;
this.brand = brand;
this.toastSlots = toastSlots;
this.qty = qty;
this.price = price;
}
}
25 changes: 25 additions & 0 deletions src/main/java/services/PandaService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package services;

import models.Pandas;
import models.Toaster;

import java.util.ArrayList;
import java.util.List;

public class PandaService {
private static int nextId = 1; // (1)

private List<Pandas> inventory = new ArrayList<>(); // (2)

public Pandas create(String name, String species, int age, int quantity, float price) {

// (2)
Pandas createdPanda = new Pandas(nextId++, name, species, age, quantity, price);

// (3)
inventory.add(createdPanda);

// (4)
return createdPanda;
}
}
24 changes: 24 additions & 0 deletions src/main/java/services/ToasterService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package services;

import models.Toaster;

import java.util.ArrayList;
import java.util.List;

public class ToasterService {
private static int nextId = 1; // (1)

private List<Toaster> inventory = new ArrayList<>(); // (2)

public Toaster create(String name, String brand, int toasterSlots, int quantity, float price) {

// (2)
Toaster createdSneaker = new Toaster(nextId++, name, brand, toasterSlots, quantity, price);

// (3)
inventory.add(createdSneaker);

// (4)
return createdSneaker;
}
}
43 changes: 43 additions & 0 deletions src/test/java/models/PandasTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package models;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import static org.junit.jupiter.api.Assertions.*;

public class PandasTest {
@Test
public void setNameTest() {
// given (1)
String expected = "OZWEEGO";

// when (2)
Pandas redpanda= new Pandas();
redpanda.setName(expected);

// then (3)
Assertions.assertEquals(expected, redpanda.getName());
}
@Test // (1)
public void constructorTest(){

int expectedId = 6;
String expectedName = "Stan Smith";
String expectedSpecies = "Adidas";
int expectedAge = 2;
int expectedQty = 10;
float expectedPrice = 80.00f;

// (3)
Toaster redpanda = new Toaster(expectedId, expectedName, expectedSpecies,
expectedAge, expectedQty,expectedPrice);

// (4)
Assertions.assertEquals(expectedId, redpanda.getId());
Assertions.assertEquals(expectedName, redpanda.getName());
Assertions.assertEquals(expectedSpecies, redpanda.getBrand());
Assertions.assertEquals(expectedAge, redpanda.getToastSlots());
Assertions.assertEquals(expectedQty, redpanda.getQty());
Assertions.assertEquals(expectedPrice, redpanda.getPrice());
}
}
45 changes: 45 additions & 0 deletions src/test/java/models/ToasterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package models;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import static org.junit.Assert.*;

public class ToasterTest {

@Test
public void setNameTest() {
// given (1)
String expected = "OZWEEGO";

// when (2)
Toaster toasty= new Toaster();
toasty.setName(expected);

// then (3)
Assertions.assertEquals(expected, toasty.getName());
}
@Test // (1)
public void constructorTest(){

int expectedId = 6;
String expectedName = "Stan Smith";
String expectedBrand = "Adidas";
int expectedSport = 2;
int expectedQty = 10;
float expectedPrice = 80.00f;

// (3)
Toaster toasty = new Toaster(expectedId, expectedName, expectedBrand,
expectedSport, expectedQty,expectedPrice);

// (4)
Assertions.assertEquals(expectedId, toasty.getId());
Assertions.assertEquals(expectedName, toasty.getName());
Assertions.assertEquals(expectedBrand, toasty.getBrand());
Assertions.assertEquals(expectedSport, toasty.getToastSlots());
Assertions.assertEquals(expectedQty, toasty.getQty());
Assertions.assertEquals(expectedPrice, toasty.getPrice());
}
}

44 changes: 44 additions & 0 deletions src/test/java/services/PandaServiceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package services;

import models.Pandas;
import models.Toaster;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import static org.junit.Assert.*;

public class PandaServiceTest {
@Test
public void createTest(){

// (1)
String expectedName = "Stan Smith";
String expectedBrand = "Adidas";
int expectedSport = 2;
int expectedQty = 10;
float expectedPrice = 80.00f;

// (2)
PandaService pandiService = new PandaService();
Pandas testPandi = pandiService.create(expectedName, expectedBrand,
expectedSport, expectedQty, expectedPrice);

// (3)
int actualId = testPandi.getId();
String actualName = testPandi.getName();
String actualBrand = testPandi.getSpecies();
int actualSport = testPandi.getAge();
int actualQty = testPandi.getQty();
float actualPrice = testPandi.getPrice();

// (4)
Assertions.assertEquals(Integer.class.getName(), new Integer(actualId).getClass().getName());
Assertions.assertEquals(expectedName, actualName);
Assertions.assertEquals(expectedBrand, actualBrand);
Assertions.assertEquals(expectedSport, actualSport);
Assertions.assertEquals(expectedQty, actualQty);
Assertions.assertEquals(expectedPrice, actualPrice);

}

}
Loading