Pārlūkot izejas kodu

Completed lab with test.

William Brown 6 gadus atpakaļ
vecāks
revīzija
ea6636ca16

Binārs
.DS_Store Parādīt failu


+ 121
- 44
orm_lab/.idea/workspace.xml Parādīt failu

@@ -24,35 +24,47 @@
24 24
       </usages-collector>
25 25
       <usages-collector id="statistics.file.extensions.edit">
26 26
         <counts>
27
-          <entry key="java" value="4733" />
27
+          <entry key="java" value="5029" />
28 28
           <entry key="xml" value="19" />
29 29
         </counts>
30 30
       </usages-collector>
31 31
       <usages-collector id="statistics.file.types.edit">
32 32
         <counts>
33
-          <entry key="JAVA" value="4733" />
33
+          <entry key="JAVA" value="5029" />
34 34
           <entry key="XML" value="19" />
35 35
         </counts>
36 36
       </usages-collector>
37 37
       <usages-collector id="statistics.file.extensions.open">
38 38
         <counts>
39
-          <entry key="java" value="16" />
39
+          <entry key="java" value="18" />
40 40
         </counts>
41 41
       </usages-collector>
42 42
       <usages-collector id="statistics.file.types.open">
43 43
         <counts>
44
-          <entry key="JAVA" value="16" />
44
+          <entry key="JAVA" value="18" />
45 45
         </counts>
46 46
       </usages-collector>
47 47
     </session>
48 48
   </component>
49 49
   <component name="FileEditorManager">
50 50
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
51
-      <file pinned="false" current-in-tab="true">
51
+      <file pinned="false" current-in-tab="false">
52 52
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
53 53
           <provider selected="true" editor-type-id="text-editor">
54
-            <state relative-caret-position="180">
55
-              <caret line="12" column="50" selection-start-line="12" selection-start-column="50" selection-end-line="12" selection-end-column="50" />
54
+            <state relative-caret-position="-856">
55
+              <caret line="12" column="52" lean-forward="true" selection-start-line="12" selection-start-column="52" selection-end-line="12" selection-end-column="52" />
56
+              <folding>
57
+                <element signature="imports" expanded="true" />
58
+              </folding>
59
+            </state>
60
+          </provider>
61
+        </entry>
62
+      </file>
63
+      <file pinned="false" current-in-tab="true">
64
+        <entry file="file://$PROJECT_DIR$/src/test/java/AccountServiceTest.java">
65
+          <provider selected="true" editor-type-id="text-editor">
66
+            <state relative-caret-position="345">
67
+              <caret line="23" column="46" selection-start-line="23" selection-start-column="46" selection-end-line="23" selection-end-column="46" />
56 68
               <folding>
57 69
                 <element signature="imports" expanded="true" />
58 70
               </folding>
@@ -61,6 +73,24 @@
61 73
         </entry>
62 74
       </file>
63 75
       <file pinned="false" current-in-tab="false">
76
+        <entry file="file://$PROJECT_DIR$/src/main/java/MockDao.java">
77
+          <provider selected="true" editor-type-id="text-editor">
78
+            <state relative-caret-position="237">
79
+              <caret line="21" column="29" selection-start-line="21" selection-start-column="29" selection-end-line="21" selection-end-column="29" />
80
+              <folding>
81
+                <element signature="imports" expanded="true" />
82
+                <element signature="e#1579#1580#0" expanded="true" />
83
+                <element signature="e#1606#1607#0" expanded="true" />
84
+                <element signature="e#1668#1669#0" expanded="true" />
85
+                <element signature="e#1695#1696#0" expanded="true" />
86
+                <element signature="e#1757#1758#0" expanded="true" />
87
+                <element signature="e#1784#1785#0" expanded="true" />
88
+              </folding>
89
+            </state>
90
+          </provider>
91
+        </entry>
92
+      </file>
93
+      <file pinned="false" current-in-tab="false">
64 94
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountService.java">
65 95
           <provider selected="true" editor-type-id="text-editor">
66 96
             <state relative-caret-position="315">
@@ -93,6 +123,10 @@
93 123
   <component name="FindInProjectRecents">
94 124
     <findStrings>
95 125
       <find>create</find>
126
+      <find>read</find>
127
+      <find>query</find>
128
+      <find>dele</find>
129
+      <find>que</find>
96 130
     </findStrings>
97 131
   </component>
98 132
   <component name="IdeDocumentHistory">
@@ -100,12 +134,12 @@
100 134
       <list>
101 135
         <option value="$PROJECT_DIR$/pom.xml" />
102 136
         <option value="$PROJECT_DIR$/src/main/java/Account.java" />
103
-        <option value="$PROJECT_DIR$/src/main/java/MockDao.java" />
104 137
         <option value="$PROJECT_DIR$/src/test/java/MockDaoTest.java" />
105
-        <option value="$PROJECT_DIR$/src/test/java/AccountServiceTest.java" />
106 138
         <option value="$PROJECT_DIR$/src/main/java/Console.java" />
107 139
         <option value="$PROJECT_DIR$/src/main/java/AccountService.java" />
108 140
         <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
141
+        <option value="$PROJECT_DIR$/src/main/java/MockDao.java" />
142
+        <option value="$PROJECT_DIR$/src/test/java/AccountServiceTest.java" />
109 143
       </list>
110 144
     </option>
111 145
   </component>
@@ -182,7 +216,7 @@
182 216
   <component name="PropertiesComponent">
183 217
     <property name="WebServerToolWindowFactoryState" value="false" />
184 218
     <property name="aspect.path.notification.shown" value="true" />
185
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542493001699" />
219
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542494210198" />
186 220
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
187 221
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
188 222
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -202,7 +236,7 @@
202 236
       </list>
203 237
     </option>
204 238
   </component>
205
-  <component name="RunManager" selected="Application.AccountApp">
239
+  <component name="RunManager" selected="JUnit.AccountServiceTest">
206 240
     <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
207 241
       <option name="MAIN_CLASS_NAME" value="AccountApp" />
208 242
       <module name="orm_lab" />
@@ -210,6 +244,14 @@
210 244
         <option name="Make" enabled="true" />
211 245
       </method>
212 246
     </configuration>
247
+    <configuration name="AccountServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
248
+      <module name="orm_lab" />
249
+      <option name="PACKAGE_NAME" value="" />
250
+      <option name="MAIN_CLASS_NAME" value="AccountServiceTest" />
251
+      <method v="2">
252
+        <option name="Make" enabled="true" />
253
+      </method>
254
+    </configuration>
213 255
     <configuration name="AccountServiceTest.create" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
214 256
       <module name="orm_lab" />
215 257
       <option name="PACKAGE_NAME" value="" />
@@ -220,12 +262,26 @@
220 262
         <option name="Make" enabled="true" />
221 263
       </method>
222 264
     </configuration>
265
+    <configuration name="AccountServiceTest.testRead" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
266
+      <module name="orm_lab" />
267
+      <option name="PACKAGE_NAME" value="" />
268
+      <option name="MAIN_CLASS_NAME" value="AccountServiceTest" />
269
+      <option name="METHOD_NAME" value="testRead" />
270
+      <option name="TEST_OBJECT" value="method" />
271
+      <method v="2">
272
+        <option name="Make" enabled="true" />
273
+      </method>
274
+    </configuration>
223 275
     <list>
224 276
       <item itemvalue="Application.AccountApp" />
225 277
       <item itemvalue="JUnit.AccountServiceTest.create" />
278
+      <item itemvalue="JUnit.AccountServiceTest" />
279
+      <item itemvalue="JUnit.AccountServiceTest.testRead" />
226 280
     </list>
227 281
     <recent_temporary>
228 282
       <list>
283
+        <item itemvalue="JUnit.AccountServiceTest" />
284
+        <item itemvalue="JUnit.AccountServiceTest.testRead" />
229 285
         <item itemvalue="Application.AccountApp" />
230 286
         <item itemvalue="JUnit.AccountServiceTest.create" />
231 287
       </list>
@@ -247,7 +303,7 @@
247 303
       <workItem from="1542400272142" duration="475000" />
248 304
       <workItem from="1542402329700" duration="6366000" />
249 305
       <workItem from="1542419814049" duration="345000" />
250
-      <workItem from="1542492150579" duration="850000" />
306
+      <workItem from="1542492150579" duration="2049000" />
251 307
     </task>
252 308
     <servers />
253 309
   </component>
@@ -258,9 +314,30 @@
258 314
     <history-entry file="AccountServiceTest_create - 2018.11.16 at 16h 41m 40s.xml">
259 315
       <configuration name="AccountServiceTest.create" configurationId="JUnit" />
260 316
     </history-entry>
317
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 27m 57s.xml">
318
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
319
+    </history-entry>
320
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 27m 59s.xml">
321
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
322
+    </history-entry>
323
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 28m 28s.xml">
324
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
325
+    </history-entry>
326
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 29m 49s.xml">
327
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
328
+    </history-entry>
329
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 30m 55s.xml">
330
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
331
+    </history-entry>
332
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 31m 17s.xml">
333
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
334
+    </history-entry>
335
+    <history-entry file="AccountServiceTest - 2018.11.17 at 17h 31m 57s.xml">
336
+      <configuration name="AccountServiceTest" configurationId="JUnit" />
337
+    </history-entry>
261 338
   </component>
262 339
   <component name="TimeTrackingManager">
263
-    <option name="totallyTimeSpent" value="16225000" />
340
+    <option name="totallyTimeSpent" value="17424000" />
264 341
   </component>
265 342
   <component name="TodoView">
266 343
     <todo-panel id="selected-file">
@@ -272,7 +349,7 @@
272 349
     </todo-panel>
273 350
   </component>
274 351
   <component name="ToolWindowManager">
275
-    <frame x="-1920" y="-280" width="1920" height="1080" extended-state="0" />
352
+    <frame x="-1930" y="-258" width="1920" height="1058" extended-state="0" />
276 353
     <editor active="true" />
277 354
     <layout>
278 355
       <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.17944622" />
@@ -284,7 +361,7 @@
284 361
       <window_info id="Favorites" order="6" side_tool="true" />
285 362
       <window_info anchor="bottom" id="Message" order="0" />
286 363
       <window_info anchor="bottom" id="Find" order="1" />
287
-      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.31188118" />
364
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32608697" />
288 365
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
289 366
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
290 367
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -293,7 +370,7 @@
293 370
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
294 371
       <window_info anchor="bottom" id="Terminal" order="9" weight="0.33861387" />
295 372
       <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
296
-      <window_info anchor="bottom" id="Messages" order="11" weight="0.32772276" />
373
+      <window_info anchor="bottom" id="Messages" order="11" weight="0.32712215" />
297 374
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
298 375
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
299 376
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -326,16 +403,6 @@
326 403
         </state>
327 404
       </provider>
328 405
     </entry>
329
-    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServiceTest.java">
330
-      <provider selected="true" editor-type-id="text-editor">
331
-        <state relative-caret-position="60">
332
-          <caret line="10" lean-forward="true" selection-start-line="10" selection-end-line="10" />
333
-          <folding>
334
-            <element signature="imports" expanded="true" />
335
-          </folding>
336
-        </state>
337
-      </provider>
338
-    </entry>
339 406
     <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
340 407
       <provider selected="true" editor-type-id="text-editor">
341 408
         <state relative-caret-position="270">
@@ -360,26 +427,20 @@
360 427
         </state>
361 428
       </provider>
362 429
     </entry>
363
-    <entry file="file://$PROJECT_DIR$/src/main/java/MockDao.java">
430
+    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
364 431
       <provider selected="true" editor-type-id="text-editor">
365
-        <state relative-caret-position="577">
366
-          <caret line="75" column="20" lean-forward="true" selection-start-line="75" selection-start-column="20" selection-end-line="75" selection-end-column="20" />
367
-          <folding>
368
-            <element signature="imports" expanded="true" />
369
-            <element signature="e#1579#1580#0" expanded="true" />
370
-            <element signature="e#1606#1607#0" expanded="true" />
371
-            <element signature="e#1668#1669#0" expanded="true" />
372
-            <element signature="e#1695#1696#0" expanded="true" />
373
-            <element signature="e#1757#1758#0" expanded="true" />
374
-            <element signature="e#1784#1785#0" expanded="true" />
375
-          </folding>
432
+        <state relative-caret-position="870">
433
+          <caret line="58" column="29" selection-start-line="58" selection-start-column="29" selection-end-line="58" selection-end-column="29" />
376 434
         </state>
377 435
       </provider>
378 436
     </entry>
379
-    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
437
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
380 438
       <provider selected="true" editor-type-id="text-editor">
381
-        <state relative-caret-position="870">
382
-          <caret line="58" column="29" selection-start-line="58" selection-start-column="29" selection-end-line="58" selection-end-column="29" />
439
+        <state relative-caret-position="-856">
440
+          <caret line="12" column="52" lean-forward="true" selection-start-line="12" selection-start-column="52" selection-end-line="12" selection-end-column="52" />
441
+          <folding>
442
+            <element signature="imports" expanded="true" />
443
+          </folding>
383 444
         </state>
384 445
       </provider>
385 446
     </entry>
@@ -393,10 +454,26 @@
393 454
         </state>
394 455
       </provider>
395 456
     </entry>
396
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
457
+    <entry file="file://$PROJECT_DIR$/src/main/java/MockDao.java">
458
+      <provider selected="true" editor-type-id="text-editor">
459
+        <state relative-caret-position="237">
460
+          <caret line="21" column="29" selection-start-line="21" selection-start-column="29" selection-end-line="21" selection-end-column="29" />
461
+          <folding>
462
+            <element signature="imports" expanded="true" />
463
+            <element signature="e#1579#1580#0" expanded="true" />
464
+            <element signature="e#1606#1607#0" expanded="true" />
465
+            <element signature="e#1668#1669#0" expanded="true" />
466
+            <element signature="e#1695#1696#0" expanded="true" />
467
+            <element signature="e#1757#1758#0" expanded="true" />
468
+            <element signature="e#1784#1785#0" expanded="true" />
469
+          </folding>
470
+        </state>
471
+      </provider>
472
+    </entry>
473
+    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServiceTest.java">
397 474
       <provider selected="true" editor-type-id="text-editor">
398
-        <state relative-caret-position="180">
399
-          <caret line="12" column="50" selection-start-line="12" selection-start-column="50" selection-end-line="12" selection-end-column="50" />
475
+        <state relative-caret-position="345">
476
+          <caret line="23" column="46" selection-start-line="23" selection-start-column="46" selection-end-line="23" selection-end-column="46" />
400 477
           <folding>
401 478
             <element signature="imports" expanded="true" />
402 479
           </folding>

+ 8
- 5
orm_lab/src/main/java/MockDao.java Parādīt failu

@@ -17,7 +17,10 @@ public class MockDao implements Dao<Account, Integer> {
17 17
 
18 18
 
19 19
     public Account queryForId(Integer integer) throws SQLException {
20
-        return null;
20
+        Account account = new Account();
21
+        account.setPassword("password");
22
+        account.setName("root");
23
+        return account;
21 24
     }
22 25
 
23 26
     public Account queryForFirst(PreparedQuery<Account> preparedQuery) throws SQLException {
@@ -81,15 +84,15 @@ public class MockDao implements Dao<Account, Integer> {
81 84
     }
82 85
 
83 86
     public int update(Account account) throws SQLException {
84
-        return 0;
87
+        return 333;
85 88
     }
86 89
 
87 90
     public int updateId(Account account, Integer integer) throws SQLException {
88
-        return 0;
91
+        return 333;
89 92
     }
90 93
 
91 94
     public int update(PreparedUpdate<Account> preparedUpdate) throws SQLException {
92
-        return 0;
95
+        return 333;
93 96
     }
94 97
 
95 98
     public int refresh(Account account) throws SQLException {
@@ -97,7 +100,7 @@ public class MockDao implements Dao<Account, Integer> {
97 100
     }
98 101
 
99 102
     public int delete(Account account) throws SQLException {
100
-        return 0;
103
+        return 43712;
101 104
     }
102 105
 
103 106
     public int deleteById(Integer integer) throws SQLException {

+ 18
- 0
orm_lab/src/test/java/AccountServiceTest.java Parādīt failu

@@ -19,6 +19,24 @@ public class AccountServiceTest {
19 19
 
20 20
     @Test
21 21
     public void testRead() throws SQLException{
22
+        Account account1 = accountService.read(0);
23
+        Account account2 = dao.queryForId(0);
24
+        Assert.assertEquals(account1, account2);
25
+    }
22 26
 
27
+    @Test
28
+    public void testUpdate() throws SQLException{
29
+        Account account = new Account();
30
+        int expectedId = 333;
31
+        int actual = dao.update(account);
32
+        Assert.assertEquals(expectedId, actual);
33
+    }
34
+
35
+    @Test
36
+    public void testDelete() throws SQLException{
37
+        Account account = new Account();
38
+        int expectedId = 43712;
39
+        int actual = dao.delete(account);
40
+        Assert.assertEquals(expectedId, actual);
23 41
     }
24 42
 }

Binārs
orm_lab/target/classes/AccountApp.class Parādīt failu


Binārs
orm_lab/target/classes/MockDao.class Parādīt failu


Binārs
orm_lab/target/test-classes/AccountServiceTest.class Parādīt failu