浏览代码

added constructor, three tests, one method

Margaret Pierse 6 年前
父节点
当前提交
5af2ee7723

+ 145
- 30
.idea/workspace.xml 查看文件

@@ -2,12 +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$/.idea/libraries/Maven__junit_junit_4_12.xml" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
8
-      <change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
9
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
11 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" />
12 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" />
13 7
     </list>
@@ -19,6 +13,11 @@
19 13
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
20 14
     <option name="LAST_RESOLUTION" value="IGNORE" />
21 15
   </component>
16
+  <component name="CoverageDataManager">
17
+    <SUITE FILE_PATH="coverage/CR_MesoLabs_Inheritance_ProductManager$ProductTest_getPriceTest.ic" NAME="ProductTest.getPriceTest Coverage Results" MODIFIED="1540391443769" 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>
22 21
   <component name="FUSProjectUsageTrigger">
23 22
     <session id="1328200517">
24 23
       <usages-collector id="statistics.lifecycle.project">
@@ -29,12 +28,12 @@
29 28
       </usages-collector>
30 29
       <usages-collector id="statistics.file.extensions.edit">
31 30
         <counts>
32
-          <entry key="java" value="288" />
31
+          <entry key="java" value="1122" />
33 32
         </counts>
34 33
       </usages-collector>
35 34
       <usages-collector id="statistics.file.types.edit">
36 35
         <counts>
37
-          <entry key="JAVA" value="288" />
36
+          <entry key="JAVA" value="1122" />
38 37
         </counts>
39 38
       </usages-collector>
40 39
       <usages-collector id="statistics.spring.boot.mvc.usages" />
@@ -68,8 +67,14 @@
68 67
       <file pinned="false" current-in-tab="false">
69 68
         <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java">
70 69
           <provider selected="true" editor-type-id="text-editor">
71
-            <state relative-caret-position="105">
72
-              <caret line="7" column="28" lean-forward="true" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
70
+            <state relative-caret-position="120">
71
+              <caret line="8" column="29" lean-forward="true" selection-start-line="8" selection-start-column="29" selection-end-line="8" selection-end-column="29" />
72
+              <folding>
73
+                <element signature="e#359#360#0" expanded="true" />
74
+                <element signature="e#395#396#0" expanded="true" />
75
+                <element signature="e#431#432#0" expanded="true" />
76
+                <element signature="e#454#455#0" expanded="true" />
77
+              </folding>
73 78
             </state>
74 79
           </provider>
75 80
         </entry>
@@ -77,8 +82,8 @@
77 82
       <file pinned="false" current-in-tab="true">
78 83
         <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java">
79 84
           <provider selected="true" editor-type-id="text-editor">
80
-            <state relative-caret-position="255">
81
-              <caret line="17" column="27" selection-start-line="17" selection-start-column="27" selection-end-line="17" selection-end-column="27" />
85
+            <state relative-caret-position="366">
86
+              <caret line="44" column="47" selection-start-line="44" selection-start-column="47" selection-end-line="44" selection-end-column="47" />
82 87
               <folding>
83 88
                 <element signature="imports" expanded="true" />
84 89
               </folding>
@@ -144,10 +149,10 @@
144 149
     </option>
145 150
   </component>
146 151
   <component name="ProjectFrameBounds">
147
-    <option name="x" value="-200" />
148
-    <option name="y" value="-964" />
149
-    <option name="width" value="1920" />
150
-    <option name="height" value="810" />
152
+    <option name="x" value="50" />
153
+    <option name="y" value="23" />
154
+    <option name="width" value="1299" />
155
+    <option name="height" value="797" />
151 156
   </component>
152 157
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
153 158
   <component name="ProjectView">
@@ -157,13 +162,70 @@
157 162
     <panes>
158 163
       <pane id="PackagesPane" />
159 164
       <pane id="Scope" />
160
-      <pane id="ProjectPane" />
165
+      <pane id="ProjectPane">
166
+        <subPane>
167
+          <expand>
168
+            <path>
169
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
170
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
171
+            </path>
172
+            <path>
173
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
174
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
175
+              <item name="src" type="462c0819:PsiDirectoryNode" />
176
+            </path>
177
+            <path>
178
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
179
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
180
+              <item name="src" type="462c0819:PsiDirectoryNode" />
181
+              <item name="main" type="462c0819:PsiDirectoryNode" />
182
+            </path>
183
+            <path>
184
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
185
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
186
+              <item name="src" type="462c0819:PsiDirectoryNode" />
187
+              <item name="main" type="462c0819:PsiDirectoryNode" />
188
+              <item name="java" type="462c0819:PsiDirectoryNode" />
189
+            </path>
190
+            <path>
191
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
192
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
193
+              <item name="src" type="462c0819:PsiDirectoryNode" />
194
+              <item name="main" type="462c0819:PsiDirectoryNode" />
195
+              <item name="java" type="462c0819:PsiDirectoryNode" />
196
+              <item name="productmanager" type="462c0819:PsiDirectoryNode" />
197
+            </path>
198
+            <path>
199
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
200
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
201
+              <item name="src" type="462c0819:PsiDirectoryNode" />
202
+              <item name="test" type="462c0819:PsiDirectoryNode" />
203
+            </path>
204
+            <path>
205
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
206
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
207
+              <item name="src" type="462c0819:PsiDirectoryNode" />
208
+              <item name="test" type="462c0819:PsiDirectoryNode" />
209
+              <item name="java" type="462c0819:PsiDirectoryNode" />
210
+            </path>
211
+            <path>
212
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="b2602c69:ProjectViewProjectNode" />
213
+              <item name="CR-MesoLabs-Inheritance-ProductManager" type="462c0819:PsiDirectoryNode" />
214
+              <item name="src" type="462c0819:PsiDirectoryNode" />
215
+              <item name="test" type="462c0819:PsiDirectoryNode" />
216
+              <item name="java" type="462c0819:PsiDirectoryNode" />
217
+              <item name="productmanager" type="462c0819:PsiDirectoryNode" />
218
+            </path>
219
+          </expand>
220
+          <select />
221
+        </subPane>
222
+      </pane>
161 223
     </panes>
162 224
   </component>
163 225
   <component name="PropertiesComponent">
164 226
     <property name="WebServerToolWindowFactoryState" value="false" />
165 227
     <property name="aspect.path.notification.shown" value="true" />
166
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1540387702508" />
228
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1540391442744" />
167 229
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
168 230
     <property name="project.structure.last.edited" value="Project" />
169 231
     <property name="project.structure.proportion" value="0.0" />
@@ -182,7 +244,7 @@
182 244
       </list>
183 245
     </option>
184 246
   </component>
185
-  <component name="RunManager">
247
+  <component name="RunManager" selected="JUnit.ProductTest.getPriceTest">
186 248
     <configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Tests">
187 249
       <module name="" />
188 250
       <option name="TESTING_TYPE" value="0" />
@@ -235,6 +297,23 @@
235 297
         <option name="Make" enabled="true" />
236 298
       </method>
237 299
     </configuration>
300
+    <configuration name="ProductTest.ProductQuantityTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
301
+      <module name="productmanager" />
302
+      <extension name="coverage">
303
+        <pattern>
304
+          <option name="PATTERN" value="com.zipcodewilmington.productmanager.*" />
305
+          <option name="ENABLED" value="true" />
306
+        </pattern>
307
+      </extension>
308
+      <option name="PACKAGE_NAME" value="com.zipcodewilmington.productmanager" />
309
+      <option name="MAIN_CLASS_NAME" value="com.zipcodewilmington.productmanager.ProductTest" />
310
+      <option name="METHOD_NAME" value="ProductQuantityTest" />
311
+      <option name="TEST_OBJECT" value="method" />
312
+      <option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
313
+      <method v="2">
314
+        <option name="Make" enabled="true" />
315
+      </method>
316
+    </configuration>
238 317
     <configuration name="ProductTest.constructorQuantityTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
239 318
       <module name="productmanager" />
240 319
       <extension name="coverage">
@@ -252,6 +331,23 @@
252 331
         <option name="Make" enabled="true" />
253 332
       </method>
254 333
     </configuration>
334
+    <configuration name="ProductTest.getPriceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
335
+      <module name="productmanager" />
336
+      <extension name="coverage">
337
+        <pattern>
338
+          <option name="PATTERN" value="com.zipcodewilmington.productmanager.*" />
339
+          <option name="ENABLED" value="true" />
340
+        </pattern>
341
+      </extension>
342
+      <option name="PACKAGE_NAME" value="com.zipcodewilmington.productmanager" />
343
+      <option name="MAIN_CLASS_NAME" value="com.zipcodewilmington.productmanager.ProductTest" />
344
+      <option name="METHOD_NAME" value="getPriceTest" />
345
+      <option name="TEST_OBJECT" value="method" />
346
+      <option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
347
+      <method v="2">
348
+        <option name="Make" enabled="true" />
349
+      </method>
350
+    </configuration>
255 351
     <configuration default="true" type="JUnit" factoryName="JUnit">
256 352
       <option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
257 353
       <method v="2">
@@ -288,8 +384,15 @@
288 384
         <option name="Make" enabled="true" />
289 385
       </method>
290 386
     </configuration>
387
+    <list>
388
+      <item itemvalue="JUnit.ProductTest.constructorQuantityTest" />
389
+      <item itemvalue="JUnit.ProductTest.ProductQuantityTest" />
390
+      <item itemvalue="JUnit.ProductTest.getPriceTest" />
391
+    </list>
291 392
     <recent_temporary>
292 393
       <list>
394
+        <item itemvalue="JUnit.ProductTest.getPriceTest" />
395
+        <item itemvalue="JUnit.ProductTest.ProductQuantityTest" />
293 396
         <item itemvalue="JUnit.ProductTest.constructorQuantityTest" />
294 397
       </list>
295 398
     </recent_temporary>
@@ -304,19 +407,24 @@
304 407
       <option name="number" value="Default" />
305 408
       <option name="presentableId" value="Default" />
306 409
       <updated>1515620835041</updated>
307
-      <workItem from="1540385807136" duration="1486000" />
410
+      <workItem from="1540385807136" duration="3534000" />
308 411
     </task>
309 412
     <servers />
310 413
   </component>
414
+  <component name="TestHistory">
415
+    <history-entry file="ProductTest_ProductQuantityTest - 2018.10.24 at 10h 25m 44s.xml">
416
+      <configuration name="ProductTest.ProductQuantityTest" configurationId="JUnit" />
417
+    </history-entry>
418
+  </component>
311 419
   <component name="TimeTrackingManager">
312
-    <option name="totallyTimeSpent" value="1486000" />
420
+    <option name="totallyTimeSpent" value="3534000" />
313 421
   </component>
314 422
   <component name="ToolWindowManager">
315
-    <frame x="-200" y="-964" width="1920" height="810" extended-state="0" />
423
+    <frame x="50" y="23" width="1299" height="797" extended-state="0" />
316 424
     <editor active="true" />
317 425
     <layout>
318
-      <window_info content_ui="combo" id="Project" order="0" weight="0.25239617" />
319
-      <window_info id="Structure" order="1" visible="true" weight="0.24973376" />
426
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.3770883" />
427
+      <window_info id="Structure" order="1" weight="0.3731106" />
320 428
       <window_info id="Nl-Palette" order="2" />
321 429
       <window_info id="Favorites" order="3" side_tool="true" />
322 430
       <window_info id="Image Layers" order="4" />
@@ -324,10 +432,10 @@
324 432
       <window_info id="UI Designer" order="6" />
325 433
       <window_info id="Capture Tool" order="7" />
326 434
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
327
-      <window_info active="true" anchor="bottom" id="Messages" visible="true" weight="0.32729805" />
435
+      <window_info anchor="bottom" id="Messages" weight="0.33333334" />
328 436
       <window_info anchor="bottom" id="Message" order="0" />
329 437
       <window_info anchor="bottom" id="Find" order="1" />
330
-      <window_info anchor="bottom" id="Run" order="2" />
438
+      <window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.32907802" />
331 439
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
332 440
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
333 441
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -336,6 +444,7 @@
336 444
       <window_info anchor="bottom" id="Event Log" order="8" side_tool="true" />
337 445
       <window_info anchor="bottom" id="Version Control" order="9" />
338 446
       <window_info anchor="right" id="Database" />
447
+      <window_info active="true" anchor="right" id="Coverage" side_tool="true" visible="true" weight="0.103420846" />
339 448
       <window_info anchor="right" id="Commander" order="0" weight="0.4" />
340 449
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
341 450
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -387,15 +496,21 @@
387 496
     </entry>
388 497
     <entry file="file://$PROJECT_DIR$/src/main/java/com/zipcodewilmington/productmanager/Product.java">
389 498
       <provider selected="true" editor-type-id="text-editor">
390
-        <state relative-caret-position="105">
391
-          <caret line="7" column="28" lean-forward="true" selection-start-line="7" selection-start-column="28" selection-end-line="7" selection-end-column="28" />
499
+        <state relative-caret-position="120">
500
+          <caret line="8" column="29" lean-forward="true" selection-start-line="8" selection-start-column="29" selection-end-line="8" selection-end-column="29" />
501
+          <folding>
502
+            <element signature="e#359#360#0" expanded="true" />
503
+            <element signature="e#395#396#0" expanded="true" />
504
+            <element signature="e#431#432#0" expanded="true" />
505
+            <element signature="e#454#455#0" expanded="true" />
506
+          </folding>
392 507
         </state>
393 508
       </provider>
394 509
     </entry>
395 510
     <entry file="file://$PROJECT_DIR$/src/test/java/com/zipcodewilmington/productmanager/ProductTest.java">
396 511
       <provider selected="true" editor-type-id="text-editor">
397
-        <state relative-caret-position="255">
398
-          <caret line="17" column="27" selection-start-line="17" selection-start-column="27" selection-end-line="17" selection-end-column="27" />
512
+        <state relative-caret-position="366">
513
+          <caret line="44" column="47" selection-start-line="44" selection-start-column="47" selection-end-line="44" selection-end-column="47" />
399 514
           <folding>
400 515
             <element signature="imports" expanded="true" />
401 516
           </folding>

+ 16
- 1
src/main/java/com/zipcodewilmington/productmanager/Product.java 查看文件

@@ -5,8 +5,23 @@ package com.zipcodewilmington.productmanager;
5 5
  */
6 6
 public class Product {
7 7
 
8
-    public Product(int quantity){
8
+    private int quantity;
9
+    private static int id = 1;
10
+    private double price;
9 11
 
12
+    public Product(int quantity, double price){
13
+        this.quantity = quantity;
14
+        this.price = price;
15
+        id = id++;
10 16
     }
11 17
 
18
+    public int getQuantity() {
19
+        return this.quantity;
20
+    }
21
+
22
+    public double getPrice() {
23
+        return this.price;
24
+    }
25
+
26
+
12 27
 }

+ 29
- 4
src/test/java/com/zipcodewilmington/productmanager/ProductTest.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.zipcodewilmington.productmanager;
2 2
 
3
+import org.junit.Before;
3 4
 import org.junit.Test;
4 5
 
5 6
 import static junit.framework.TestCase.assertEquals;
@@ -9,14 +10,38 @@ import static junit.framework.TestCase.assertEquals;
9 10
  */
10 11
 public class ProductTest {
11 12
 
13
+
12 14
     @Test
13
-    public void constructorQuantityTest() {
15
+    public void getQuantityTest() {
14 16
         //given
17
+
15 18
         int quantity = 7;
16
-        int expected = 7;
19
+        int expected = quantity;
20
+
17 21
         //when
18
-        int actual = Product(quantity);
22
+        Product product1 = new Product(quantity,1.0);
23
+        int actual = product1.getQuantity();
19 24
         //then
20
-        assertEquals(actual, expected);
25
+        assertEquals(expected, actual);
26
+    }
27
+
28
+    @Test
29
+    public void getPriceTest() {
30
+        //given
31
+        double price = 5.55;
32
+        double expected = price;
33
+        //when
34
+        Product product2 = new Product(4, price);
35
+        double actual = product2.getPrice();
36
+        //then
37
+        assertEquals(expected,actual);
38
+    }
39
+
40
+    @Testpublic void getIDtest() {
41
+        //given
42
+        int iD = 3;
43
+        int expected = iD;
44
+        //when
45
+        Product product3 = new Product(4,4.50);
21 46
     }
22 47
 }