Skip to content
Open

Dev #11

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
2 changes: 2 additions & 0 deletions .idea/Product-Inventory-Lab.iml

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

1 change: 1 addition & 0 deletions .idea/compiler.xml

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

3 changes: 3 additions & 0 deletions .idea/misc.xml

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

6 changes: 4 additions & 2 deletions instructions/section-01.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ src/main
│   └── services
│   ├── SneakerService.java
│   └── WhiskeyService.java
└── resources
```
└── resource

s

Because our store is so successful, we are really moving through inventory. So I would be nice to have a class that would help maintain all the items. A class that provided the service of creating and managing the items. For my example I will create a "SneakerService" class and a "WhiskeyService" class inside the services package.

Because we are Doing Test Driven Development (TDD) we need to also have test classes for the models and the services.
Expand Down
2 changes: 1 addition & 1 deletion instructions/section-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A sneaker item from inventory
- size: float
- qty: int
- price: float

f

These will be enough properties for now. If I ever need to add or remove I can come back and make a change.

Expand Down
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@
</plugins>
</build>


<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
48 changes: 48 additions & 0 deletions src/main/java/models/Shoes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package models;

public class Shoes {

private String name;
private int quantity;
private double price;
//a.need this for testing individual setTests.
public Shoes () {
this.name = "NIKE";
this.quantity = 1000;
this.price = 20.00;
}
public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}

public int getQuantity() {
return quantity;
}

public void setPrice(double price) {
this.price = price;
}

public double getPrice() {
return price;
}
//d.need this for constructor
public Shoes(String name, int quantity, double price) {
this.name = name;
this.quantity = quantity;
this.price = price;
}


}



42 changes: 42 additions & 0 deletions src/main/java/models/TVs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package models;

public class TVs {

private String name;
private int quantity;
private Double price;

//a.need this for testing individual and combined
public TVs () {
this.name = "Samsung";
this.quantity = 500;
this.price = 29.99;
}
public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setQuantity(int quantity) {this.quantity = quantity;}

public int getQuantity() {return quantity;}

public void setPrice(Double price) {this.price = price;}

public Double getPrice() {return price;}

//d. need this for constructor
public TVs(String name, int quantity, double price) {
this.name = name;
this.quantity = quantity;
this.price = price;
}


}



16 changes: 16 additions & 0 deletions src/main/java/services/ShoesService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package services;
/*
public class ShoesService {

public class Shoes {

private String name;
private int quantity;
private double price;

public Shoes(String expectedName, double expectedPrice, int expectedQuantity) {
}

}

*/
5 changes: 5 additions & 0 deletions src/main/java/services/TVsService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package services;

public class TVsService {

}
76 changes: 76 additions & 0 deletions src/test/java/models/ShoesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package models;

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

public class ShoesTest {

@Test
public void setNameTest() {
// given (1)
Shoes shoe = new Shoes();
String expected = "NIKE";

// when (2)
Shoes testName = new Shoes(); //need this Shoes class a.public Shoes() {
//this.name = "NIKE"; this.quantity = 1000; this.price = 20.00;}
testName.setName(expected);

// then (3)
Assertions.assertEquals(expected, testName.getName());
}

@Test
public void setQuantityTest() {
//given
int expected = 1000;

// when
Shoes testQuantity = new Shoes();
testQuantity.setQuantity(expected);

// then
Assertions.assertEquals(expected, testQuantity.getQuantity());

}

@Test
public void setPrice() {
//given
double expected = 20.99;

//when
Shoes testPrice = new Shoes();
testPrice.setPrice(expected);

//then
Assertions.assertEquals(expected, testPrice.getPrice());

}
//d. need this for constructor
@Test
public void testDefaultConstructor() {
//Given
String expectedName = "NIKE";
int expectedQuantity = 1000;
double expectedPrice = 20.99;

//When
Shoes shoes = new Shoes(expectedName, expectedQuantity, expectedPrice);

//Then
String actualName = shoes.getName();
int actualQuantity = shoes.getQuantity();
double actualPrice = shoes.getPrice();

Assertions.assertEquals(expectedName, actualName);
Assertions.assertEquals(expectedQuantity, actualQuantity);
Assertions.assertEquals(expectedPrice, actualPrice);
}



}



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

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

public class TVsTest {
@Test
public void setNameTest() {
// given
TVs tvs = new TVs(); //
String expected = "Samsung";

//when
TVs testName = new TVs();
testName.setName(expected);

//then
Assertions.assertEquals(expected, testName.getName());
}

@Test
public void setQuantityTest() {
//given
int expected = 500;

//when
TVs testQuantity = new TVs();
testQuantity.setQuantity(expected);

//then
Assertions.assertEquals(expected, testQuantity.getQuantity());
}

@Test
public void setPriceTest() {
//given
double expected = 29.99;

//when
TVs testPrice = new TVs();
testPrice.setPrice((double) expected);

//then
Assertions.assertEquals(expected, testPrice.getPrice());

}
//d. need this for constructor
@Test
public void testDefaultConstructorTV() {
//Given
String expectedName = "Samsung";
int expectedQuantity = 500;
double expectedPrice = 29.99;

//When
TVs tvs = new TVs(expectedName, expectedQuantity, expectedPrice);

//Then
String actualName = tvs.getName();
int actualQuantity = tvs.getQuantity();
double actualPrice = tvs.getPrice();

Assertions.assertEquals(expectedName, actualName);
Assertions.assertEquals(expectedQuantity, actualQuantity);
Assertions.assertEquals(expectedPrice, actualPrice);
}




}

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

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

public class ShoesServicesTest {



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

public class TVsServiceTest {
}