Procházet zdrojové kódy

Stubbed out Product

Nhu Nguyen před 6 roky
rodič
revize
9172fa5626

+ 12
- 0
pom.xml Zobrazit soubor

@@ -7,6 +7,18 @@
7 7
     <groupId>io.zipcoder</groupId>
8 8
     <artifactId>ZipcodeStore</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <build>
11
+        <plugins>
12
+            <plugin>
13
+                <groupId>org.apache.maven.plugins</groupId>
14
+                <artifactId>maven-compiler-plugin</artifactId>
15
+                <configuration>
16
+                    <source>1.8</source>
17
+                    <target>1.8</target>
18
+                </configuration>
19
+            </plugin>
20
+        </plugins>
21
+    </build>
10 22
     <dependencies>
11 23
         <dependency>
12 24
             <groupId>junit</groupId>

+ 27
- 0
src/main/java/org/zipcoder/store/Product.java Zobrazit soubor

@@ -0,0 +1,27 @@
1
+package org.zipcoder.store;
2
+
3
+public class Product {
4
+    // a string field called 'name'
5
+    private String name;
6
+
7
+    // constructor with no params
8
+    public Product() {
9
+
10
+    }
11
+
12
+    // constructor with one params
13
+    public Product(String name) {
14
+        this.name = name;
15
+    }
16
+
17
+    // getter for the field 'name'
18
+    public String getName() {
19
+        return name;
20
+    }
21
+
22
+    // setter for the field 'name'
23
+    public void setName(String name) {
24
+        this.name = name;
25
+    }
26
+
27
+}

+ 27
- 27
src/test/java/org/zipcoder/store/ProductTest.java Zobrazit soubor

@@ -11,19 +11,33 @@ public class ProductTest {
11 11
         Product product = new Product();
12 12
     }
13 13
 
14
-//    @Test
15
-//    public void testConstruction_WithName(){
16
-//        //Given
17
-//        String expectedName = "T-Shirt";
18
-//
19
-//        //When
20
-//        Product product = new Product(expectedName);
21
-//
22
-//        //Then
23
-//        String actualName = product.getName();
24
-//        Assert.assertEquals(expectedName, actualName);
25
-//    }
26
-//
14
+    @Test
15
+    public void testConstruction_WithName(){
16
+        //Given
17
+        String expectedName = "T-Shirt";
18
+
19
+        //When
20
+        Product product = new Product(expectedName);
21
+
22
+        //Then
23
+        String actualName = product.getName();
24
+        Assert.assertEquals(expectedName, actualName);
25
+    }
26
+
27
+    @Test
28
+    public void testGetSetName(){
29
+        //Given
30
+        String expectedName = "Pants";
31
+        Product product = new Product();
32
+
33
+        //When
34
+        product.setName(expectedName);
35
+
36
+        //Then
37
+        String actualName = product.getName();
38
+        Assert.assertEquals(expectedName, actualName);
39
+    }
40
+
27 41
 //    @Test
28 42
 //    public void testConstruction_WithNameAndPrice(){
29 43
 //        //Given
@@ -42,20 +56,6 @@ public class ProductTest {
42 56
 //    }
43 57
 //
44 58
 //    @Test
45
-//    public void testGetSetName(){
46
-//        //Given
47
-//        String expectedName = "Pants";
48
-//        Product product = new Product();
49
-//
50
-//        //When
51
-//        product.setName(expectedName);
52
-//
53
-//        //Then
54
-//        String actualName = product.getName();
55
-//        Assert.assertEquals(expectedName, actualName);
56
-//    }
57
-//
58
-//    @Test
59 59
 //    public void testGetSetPrice(){
60 60
 //        //Given
61 61
 //        double expectedPrice = 15.39;