ソースを参照

Redoing my lab because I overcomplicated everything

Trinh Tong 6 年 前
コミット
c00692b149

+ 108
- 44
.idea/workspace.xml ファイルの表示

@@ -2,9 +2,6 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="268ab437-e0d5-4447-8401-9f321aad6d50" name="Default" comment="">
5
-      <change afterPath="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/InventoryTest.java" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Inventory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Inventory.java" afterDir="false" />
8 5
       <change beforePath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java" afterDir="false" />
9 6
       <change beforePath="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java" afterDir="false" />
10 7
     </list>
@@ -16,6 +13,11 @@
16 13
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
17 14
     <option name="LAST_RESOLUTION" value="IGNORE" />
18 15
   </component>
16
+  <component name="CoverageDataManager">
17
+    <SUITE FILE_PATH="coverage/CR_MesoLabs_Inheritance_ProductManager$ProductTest.ic" NAME="ProductTest Coverage Results" MODIFIED="1540417669012" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false">
18
+      <FILTER>com.zipcodewilmington.productmanager.*</FILTER>
19
+    </SUITE>
20
+  </component>
19 21
   <component name="FUSProjectUsageTrigger">
20 22
     <session id="-1746997018">
21 23
       <usages-collector id="statistics.lifecycle.project">
@@ -28,24 +30,26 @@
28 30
       <usages-collector id="statistics.file.extensions.edit">
29 31
         <counts>
30 32
           <entry key="gitignore" value="1" />
31
-          <entry key="java" value="4266" />
33
+          <entry key="java" value="5475" />
32 34
           <entry key="xml" value="1" />
33 35
         </counts>
34 36
       </usages-collector>
35 37
       <usages-collector id="statistics.file.types.edit">
36 38
         <counts>
37
-          <entry key="JAVA" value="4266" />
39
+          <entry key="JAVA" value="5475" />
38 40
           <entry key="PLAIN_TEXT" value="1" />
39 41
           <entry key="XML" value="1" />
40 42
         </counts>
41 43
       </usages-collector>
42 44
       <usages-collector id="statistics.file.extensions.open">
43 45
         <counts>
46
+          <entry key="class" value="1" />
44 47
           <entry key="java" value="4" />
45 48
         </counts>
46 49
       </usages-collector>
47 50
       <usages-collector id="statistics.file.types.open">
48 51
         <counts>
52
+          <entry key="CLASS" value="1" />
49 53
           <entry key="JAVA" value="4" />
50 54
         </counts>
51 55
       </usages-collector>
@@ -54,15 +58,6 @@
54 58
   <component name="FileEditorManager">
55 59
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
56 60
       <file pinned="false" current-in-tab="false">
57
-        <entry file="file://$PROJECT_DIR$/pom.xml">
58
-          <provider selected="true" editor-type-id="text-editor">
59
-            <state relative-caret-position="270">
60
-              <caret line="18" selection-start-line="18" selection-end-line="18" />
61
-            </state>
62
-          </provider>
63
-        </entry>
64
-      </file>
65
-      <file pinned="false" current-in-tab="false">
66 61
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/MainApplication.java">
67 62
           <provider selected="true" editor-type-id="text-editor">
68 63
             <state relative-caret-position="75">
@@ -74,8 +69,22 @@
74 69
       <file pinned="false" current-in-tab="false">
75 70
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java">
76 71
           <provider selected="true" editor-type-id="text-editor">
77
-            <state relative-caret-position="270">
78
-              <caret line="18" lean-forward="true" selection-start-line="18" selection-end-line="18" />
72
+            <state relative-caret-position="449">
73
+              <caret line="37" column="26" selection-start-line="37" selection-start-column="26" selection-end-line="37" selection-end-column="26" />
74
+              <folding>
75
+                <element signature="e#352#353#0" expanded="true" />
76
+                <element signature="e#384#385#0" expanded="true" />
77
+                <element signature="e#417#418#0" expanded="true" />
78
+                <element signature="e#447#448#0" expanded="true" />
79
+                <element signature="e#496#497#0" expanded="true" />
80
+                <element signature="e#540#541#0" expanded="true" />
81
+                <element signature="e#576#577#0" expanded="true" />
82
+                <element signature="e#611#612#0" expanded="true" />
83
+                <element signature="e#638#639#0" expanded="true" />
84
+                <element signature="e#672#673#0" expanded="true" />
85
+                <element signature="e#728#729#0" expanded="true" />
86
+                <element signature="e#761#762#0" expanded="true" />
87
+              </folding>
79 88
             </state>
80 89
           </provider>
81 90
         </entry>
@@ -83,8 +92,8 @@
83 92
       <file pinned="false" current-in-tab="true">
84 93
         <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java">
85 94
           <provider selected="true" editor-type-id="text-editor">
86
-            <state relative-caret-position="270">
87
-              <caret line="18" column="17" selection-start-line="18" selection-start-column="17" selection-end-line="18" selection-end-column="17" />
95
+            <state relative-caret-position="816">
96
+              <caret line="58" column="8" selection-start-line="58" selection-start-column="8" selection-end-line="58" selection-end-column="8" />
88 97
               <folding>
89 98
                 <element signature="imports" expanded="true" />
90 99
               </folding>
@@ -104,8 +113,8 @@
104 113
       <file pinned="false" current-in-tab="false">
105 114
         <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/InventoryTest.java">
106 115
           <provider selected="true" editor-type-id="text-editor">
107
-            <state relative-caret-position="30">
108
-              <caret line="2" column="26" selection-start-line="2" selection-start-column="26" selection-end-line="2" selection-end-column="26" />
116
+            <state relative-caret-position="270">
117
+              <caret line="18" selection-start-line="18" selection-end-line="18" />
109 118
             </state>
110 119
           </provider>
111 120
         </entry>
@@ -151,6 +160,7 @@
151 160
         <option value="$PROJECT_DIR$/.gitignore" />
152 161
         <option value="$PROJECT_DIR$/pom.xml" />
153 162
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Inventory.java" />
163
+        <option value="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/InventoryTest.java" />
154 164
         <option value="$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java" />
155 165
         <option value="$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java" />
156 166
       </list>
@@ -231,6 +241,14 @@
231 241
             </path>
232 242
             <path>
233 243
               <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
244
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
245
+              <item name="src" type="462c0819:PsiDirectoryNode" />
246
+              <item name="test" type="462c0819:PsiDirectoryNode" />
247
+              <item name="java" type="462c0819:PsiDirectoryNode" />
248
+              <item name="productmanager" type="462c0819:PsiDirectoryNode" />
249
+            </path>
250
+            <path>
251
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
234 252
               <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
235 253
             </path>
236 254
           </expand>
@@ -242,7 +260,7 @@
242 260
   <component name="PropertiesComponent">
243 261
     <property name="WebServerToolWindowFactoryState" value="false" />
244 262
     <property name="aspect.path.notification.shown" value="true" />
245
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1540415463997" />
263
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1540417667291" />
246 264
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
247 265
     <property name="project.structure.last.edited" value="Modules" />
248 266
     <property name="project.structure.proportion" value="0.0" />
@@ -351,6 +369,23 @@
351 369
         <option name="Make" enabled="true" />
352 370
       </method>
353 371
     </configuration>
372
+    <configuration name="ProductTest.testSetID" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
373
+      <module name="productmanager" />
374
+      <extension name="coverage">
375
+        <pattern>
376
+          <option name="PATTERN" value="com.zipcodewilmington.productmanager.*" />
377
+          <option name="ENABLED" value="true" />
378
+        </pattern>
379
+      </extension>
380
+      <option name="PACKAGE_NAME" value="com.zipcodewilmington.productmanager" />
381
+      <option name="MAIN_CLASS_NAME" value="com.zipcodewilmington.productmanager.ProductTest" />
382
+      <option name="METHOD_NAME" value="testSetID" />
383
+      <option name="TEST_OBJECT" value="method" />
384
+      <option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
385
+      <method v="2">
386
+        <option name="Make" enabled="true" />
387
+      </method>
388
+    </configuration>
354 389
     <configuration default="true" type="JUnit" factoryName="JUnit">
355 390
       <option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
356 391
       <method v="2">
@@ -390,10 +425,12 @@
390 425
     <list>
391 426
       <item itemvalue="JUnit.ProductTest.testAddProduct" />
392 427
       <item itemvalue="JUnit.ProductTest" />
428
+      <item itemvalue="JUnit.ProductTest.testSetID" />
393 429
     </list>
394 430
     <recent_temporary>
395 431
       <list>
396 432
         <item itemvalue="JUnit.ProductTest" />
433
+        <item itemvalue="JUnit.ProductTest.testSetID" />
397 434
         <item itemvalue="JUnit.ProductTest.testAddProduct" />
398 435
       </list>
399 436
     </recent_temporary>
@@ -410,7 +447,7 @@
410 447
       <updated>1515620835041</updated>
411 448
       <workItem from="1540329189897" duration="13000" />
412 449
       <workItem from="1540382573342" duration="34000" />
413
-      <workItem from="1540384510969" duration="13545000" />
450
+      <workItem from="1540384510969" duration="15100000" />
414 451
     </task>
415 452
     <servers />
416 453
   </component>
@@ -418,15 +455,21 @@
418 455
     <history-entry file="ProductTest_testAddProduct - 2018.10.24 at 16h 14m 45s.xml">
419 456
       <configuration name="ProductTest.testAddProduct" configurationId="JUnit" />
420 457
     </history-entry>
458
+    <history-entry file="ProductTest_testSetID - 2018.10.24 at 17h 43m 44s.xml">
459
+      <configuration name="ProductTest.testSetID" configurationId="JUnit" />
460
+    </history-entry>
461
+    <history-entry file="ProductTest - 2018.10.24 at 17h 45m 31s.xml">
462
+      <configuration name="ProductTest" configurationId="JUnit" />
463
+    </history-entry>
421 464
   </component>
422 465
   <component name="TimeTrackingManager">
423
-    <option name="totallyTimeSpent" value="13592000" />
466
+    <option name="totallyTimeSpent" value="15147000" />
424 467
   </component>
425 468
   <component name="ToolWindowManager">
426 469
     <frame x="20" y="49" width="1440" height="877" extended-state="0" />
427 470
     <editor active="true" />
428 471
     <layout>
429
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26037195" />
472
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26037195" />
430 473
       <window_info id="Structure" order="1" weight="0.25" />
431 474
       <window_info id="Nl-Palette" order="2" />
432 475
       <window_info id="Favorites" order="3" side_tool="true" />
@@ -434,10 +477,10 @@
434 477
       <window_info id="Designer" order="5" />
435 478
       <window_info id="UI Designer" order="6" />
436 479
       <window_info id="Capture Tool" order="7" />
437
-      <window_info anchor="bottom" id="Messages" visible="true" weight="0.3299363" />
480
+      <window_info anchor="bottom" id="Messages" weight="0.3299363" />
438 481
       <window_info anchor="bottom" id="Message" order="0" />
439 482
       <window_info anchor="bottom" id="Find" order="1" />
440
-      <window_info anchor="bottom" id="Run" order="2" weight="0.3299363" />
483
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3299363" />
441 484
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
442 485
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
443 486
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -475,13 +518,6 @@
475 518
         </state>
476 519
       </provider>
477 520
     </entry>
478
-    <entry file="file://$PROJECT_DIR$/pom.xml">
479
-      <provider selected="true" editor-type-id="text-editor">
480
-        <state relative-caret-position="270">
481
-          <caret line="18" selection-start-line="18" selection-end-line="18" />
482
-        </state>
483
-      </provider>
484
-    </entry>
485 521
     <entry file="file://$PROJECT_DIR$/.gitignore">
486 522
       <provider selected="true" editor-type-id="text-editor">
487 523
         <state relative-caret-position="105">
@@ -489,20 +525,27 @@
489 525
         </state>
490 526
       </provider>
491 527
     </entry>
492
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/MainApplication.java">
528
+    <entry file="file://$PROJECT_DIR$/src/test/java/InventoryTest.java">
529
+      <provider selected="true" editor-type-id="text-editor" />
530
+    </entry>
531
+    <entry file="file://$PROJECT_DIR$/pom.xml">
493 532
       <provider selected="true" editor-type-id="text-editor">
494
-        <state relative-caret-position="75">
495
-          <caret line="5" column="30" selection-start-line="5" selection-start-column="30" selection-end-line="5" selection-end-column="30" />
533
+        <state relative-caret-position="255">
534
+          <caret line="17" lean-forward="true" selection-start-line="17" selection-end-line="17" />
496 535
         </state>
497 536
       </provider>
498 537
     </entry>
499
-    <entry file="file://$PROJECT_DIR$/src/test/java/InventoryTest.java">
500
-      <provider selected="true" editor-type-id="text-editor" />
538
+    <entry file="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/org/junit/Test.class">
539
+      <provider selected="true" editor-type-id="text-editor">
540
+        <state relative-caret-position="120">
541
+          <caret line="14" column="18" selection-start-line="14" selection-start-column="18" selection-end-line="14" selection-end-column="18" />
542
+        </state>
543
+      </provider>
501 544
     </entry>
502 545
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/InventoryTest.java">
503 546
       <provider selected="true" editor-type-id="text-editor">
504
-        <state relative-caret-position="30">
505
-          <caret line="2" column="26" selection-start-line="2" selection-start-column="26" selection-end-line="2" selection-end-column="26" />
547
+        <state relative-caret-position="270">
548
+          <caret line="18" selection-start-line="18" selection-end-line="18" />
506 549
         </state>
507 550
       </provider>
508 551
     </entry>
@@ -515,15 +558,36 @@
515 558
     </entry>
516 559
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java">
517 560
       <provider selected="true" editor-type-id="text-editor">
518
-        <state relative-caret-position="270">
519
-          <caret line="18" lean-forward="true" selection-start-line="18" selection-end-line="18" />
561
+        <state relative-caret-position="449">
562
+          <caret line="37" column="26" selection-start-line="37" selection-start-column="26" selection-end-line="37" selection-end-column="26" />
563
+          <folding>
564
+            <element signature="e#352#353#0" expanded="true" />
565
+            <element signature="e#384#385#0" expanded="true" />
566
+            <element signature="e#417#418#0" expanded="true" />
567
+            <element signature="e#447#448#0" expanded="true" />
568
+            <element signature="e#496#497#0" expanded="true" />
569
+            <element signature="e#540#541#0" expanded="true" />
570
+            <element signature="e#576#577#0" expanded="true" />
571
+            <element signature="e#611#612#0" expanded="true" />
572
+            <element signature="e#638#639#0" expanded="true" />
573
+            <element signature="e#672#673#0" expanded="true" />
574
+            <element signature="e#728#729#0" expanded="true" />
575
+            <element signature="e#761#762#0" expanded="true" />
576
+          </folding>
577
+        </state>
578
+      </provider>
579
+    </entry>
580
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/MainApplication.java">
581
+      <provider selected="true" editor-type-id="text-editor">
582
+        <state relative-caret-position="75">
583
+          <caret line="5" column="30" selection-start-line="5" selection-start-column="30" selection-end-line="5" selection-end-column="30" />
520 584
         </state>
521 585
       </provider>
522 586
     </entry>
523 587
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java">
524 588
       <provider selected="true" editor-type-id="text-editor">
525
-        <state relative-caret-position="270">
526
-          <caret line="18" column="17" selection-start-line="18" selection-start-column="17" selection-end-line="18" selection-end-column="17" />
589
+        <state relative-caret-position="816">
590
+          <caret line="58" column="8" selection-start-line="58" selection-start-column="8" selection-end-line="58" selection-end-column="8" />
527 591
           <folding>
528 592
             <element signature="imports" expanded="true" />
529 593
           </folding>

+ 23
- 0
src/main/java/com/zipcodewilmington/productmanager/Product.java ファイルの表示

@@ -14,5 +14,28 @@ public class Product {
14 14
         this.price = price;
15 15
     }
16 16
 
17
+    public void setId(String userId) {
18
+        this.id = userId;
19
+    }
20
+
21
+    public String getId() {
22
+        return this.id;
23
+    }
24
+
25
+    public void setQuantity(int userQuantity) {
26
+        this.quantity = userQuantity;
27
+    }
28
+
29
+    public int getQuantity() {
30
+        return this.quantity;
31
+    }
32
+
33
+    public void setPrice(double userPrice) {
34
+        this.price = userPrice;
35
+    }
36
+
37
+    public double getPrice() {
38
+        return this.price;
39
+    }
17 40
 
18 41
 }

+ 3
- 0
src/test/java/com/zipcodewilmington/productmanager/InventoryTest.java ファイルの表示

@@ -6,6 +6,9 @@ public class InventoryTest {
6 6
 
7 7
     @Test
8 8
     public void testAddProduct() {
9
+        // Add to list
10
+        // Check the list for it
11
+        // return true
9 12
 
10 13
 
11 14
 

+ 31
- 3
src/test/java/com/zipcodewilmington/productmanager/ProductTest.java ファイルの表示

@@ -9,25 +9,53 @@ import org.junit.Test;
9 9
  */
10 10
 public class ProductTest {
11 11
 
12
+    Product testProduct = new Product("milk", 10, 2.50);
13
+
12 14
     @Test
13 15
     public void testID() {
14 16
 
17
+        // Given
18
+        String expectedId = "milk";
19
+
20
+        // When
21
+        testProduct.setId(expectedId);
22
+        String actualId = testProduct.getId();
15 23
 
24
+        // Then
25
+        Assert.assertEquals(expectedId, actualId);
16 26
     }
17 27
 
28
+
18 29
     @Test
19 30
     public void testQuantity() {
20 31
 
32
+        // Given
33
+        int expectedQuantity = 10;
34
+
35
+        // When
36
+        testProduct.setQuantity(expectedQuantity);
37
+        int actualQuantity = testProduct.getQuantity();
38
+
39
+        // Then
40
+        Assert.assertEquals(expectedQuantity, actualQuantity);
41
+
21 42
 
22 43
 
23 44
     }
24 45
 
25 46
     @Test
26 47
     public void testPrice() {
48
+        // price format as well?
49
+        // double do delta for fluctuation
50
+        // Given
51
+        double expectedPrice = 2.50;
27 52
 
53
+        // When
54
+        testProduct.setPrice(expectedPrice);
55
+        double actualPrice = testProduct.getPrice();
28 56
 
29
-        
30
-    }
31
-
57
+        // Then
58
+        Assert.assertEquals(expectedPrice, actualPrice, 0.05);
32 59
 
60
+    }
33 61
 }