Selaa lähdekoodia

complete. However, need to refactor due to some untestable methods

Demetrius Murray 6 vuotta sitten
vanhempi
commit
c3569523fb

+ 175
- 248
.idea/workspace.xml Näytä tiedosto

@@ -3,11 +3,12 @@
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="6579b631-ed88-494a-87f6-48ccbc3e224e" name="Default Changelist" comment="">
5 5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/src/main/java/AccountApp.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/src/main/java/Console.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Console.java" afterDir="false" />
6
+      <change beforePath="$PROJECT_DIR$/src/main/java/MockDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MockDao.java" afterDir="false" />
8 7
       <change beforePath="$PROJECT_DIR$/src/main/java/MySqlDriver.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MySqlDriver.java" afterDir="false" />
9
-      <change beforePath="$PROJECT_DIR$/target/classes/AccountApp.class" beforeDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/target/classes/Console.class" beforeDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/src/test/java/MySqlDriveTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/MySqlDriveTest.java" afterDir="false" />
9
+      <change beforePath="$PROJECT_DIR$/target/classes/Account.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/Account.class" afterDir="false" />
10
+      <change beforePath="$PROJECT_DIR$/target/classes/MySqlDriver.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/MySqlDriver.class" afterDir="false" />
11
+      <change beforePath="$PROJECT_DIR$/target/test-classes/MySqlDriveTest.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/test-classes/MySqlDriveTest.class" afterDir="false" />
11 12
     </list>
12 13
     <ignored path="$PROJECT_DIR$/out/" />
13 14
     <ignored path="$PROJECT_DIR$/target/" />
@@ -17,6 +18,12 @@
17 18
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
18 19
     <option name="LAST_RESOLUTION" value="IGNORE" />
19 20
   </component>
21
+  <component name="CoverageDataManager">
22
+    <SUITE FILE_PATH="coverage/ORMLite$MySqlDriveTest.ic" NAME="MySqlDriveTest Coverage Results" MODIFIED="1542646465281" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
23
+  </component>
24
+  <component name="CoverageViewManager">
25
+    <option name="myElementSize" value="46" />
26
+  </component>
20 27
   <component name="DatabaseView">
21 28
     <option name="SHOW_INTERMEDIATE" value="true" />
22 29
     <option name="GROUP_DATA_SOURCES" value="true" />
@@ -58,35 +65,36 @@
58 65
     <session id="971192734">
59 66
       <usages-collector id="statistics.lifecycle.project">
60 67
         <counts>
61
-          <entry key="project.closed" value="2" />
68
+          <entry key="project.closed" value="3" />
62 69
           <entry key="project.open.time.13" value="1" />
63 70
           <entry key="project.open.time.17" value="1" />
71
+          <entry key="project.open.time.5" value="1" />
64 72
           <entry key="project.open.time.6" value="1" />
65
-          <entry key="project.opened" value="3" />
73
+          <entry key="project.opened" value="4" />
66 74
         </counts>
67 75
       </usages-collector>
68 76
       <usages-collector id="statistics.file.extensions.open">
69 77
         <counts>
70 78
           <entry key="account" value="2" />
71
-          <entry key="class" value="13" />
79
+          <entry key="class" value="17" />
72 80
           <entry key="java" value="14" />
73 81
           <entry key="sql" value="4" />
74
-          <entry key="xml" value="6" />
82
+          <entry key="xml" value="7" />
75 83
         </counts>
76 84
       </usages-collector>
77 85
       <usages-collector id="statistics.file.types.open">
78 86
         <counts>
79
-          <entry key="CLASS" value="13" />
87
+          <entry key="CLASS" value="17" />
80 88
           <entry key="Database Element" value="2" />
81 89
           <entry key="JAVA" value="14" />
82 90
           <entry key="Scratch" value="4" />
83
-          <entry key="XML" value="6" />
91
+          <entry key="XML" value="7" />
84 92
         </counts>
85 93
       </usages-collector>
86 94
       <usages-collector id="statistics.file.extensions.edit">
87 95
         <counts>
88 96
           <entry key="dummy" value="2" />
89
-          <entry key="java" value="16546" />
97
+          <entry key="java" value="17403" />
90 98
           <entry key="sql" value="101" />
91 99
           <entry key="txt" value="26" />
92 100
           <entry key="xml" value="20" />
@@ -94,7 +102,7 @@
94 102
       </usages-collector>
95 103
       <usages-collector id="statistics.file.types.edit">
96 104
         <counts>
97
-          <entry key="JAVA" value="16546" />
105
+          <entry key="JAVA" value="17403" />
98 106
           <entry key="PLAIN_TEXT" value="28" />
99 107
           <entry key="Scratch" value="101" />
100 108
           <entry key="XML" value="20" />
@@ -103,13 +111,13 @@
103 111
     </session>
104 112
   </component>
105 113
   <component name="FileEditorManager">
106
-    <splitter split-orientation="horizontal" split-proportion="0.47337595">
114
+    <splitter split-orientation="horizontal" split-proportion="0.736">
107 115
       <split-first>
108 116
         <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
109 117
           <file pinned="false" current-in-tab="false">
110 118
             <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
111 119
               <provider selected="true" editor-type-id="text-editor">
112
-                <state relative-caret-position="-1032">
120
+                <state relative-caret-position="387">
113 121
                   <caret line="84" column="33" selection-start-line="84" selection-start-column="33" selection-end-line="84" selection-end-column="33" />
114 122
                   <folding>
115 123
                     <element signature="imports" expanded="true" />
@@ -119,24 +127,19 @@
119 127
             </entry>
120 128
           </file>
121 129
           <file pinned="false" current-in-tab="false">
122
-            <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
130
+            <entry file="file://$PROJECT_DIR$/pom.xml">
123 131
               <provider selected="true" editor-type-id="text-editor">
124
-                <state relative-caret-position="780">
125
-                  <caret line="66" column="5" selection-start-line="66" selection-start-column="5" selection-end-line="66" selection-end-column="5" />
126
-                  <folding>
127
-                    <element signature="imports" expanded="true" />
128
-                    <element signature="e#1834#1835#0" expanded="true" />
129
-                    <element signature="e#1908#1909#0" expanded="true" />
130
-                  </folding>
132
+                <state relative-caret-position="135">
133
+                  <caret line="30" selection-start-line="30" selection-end-line="30" />
131 134
                 </state>
132 135
               </provider>
133 136
             </entry>
134 137
           </file>
135
-          <file pinned="false" current-in-tab="true">
136
-            <entry file="file://$PROJECT_DIR$/src/test/java/MySqlDriveTest.java">
138
+          <file pinned="false" current-in-tab="false">
139
+            <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
137 140
               <provider selected="true" editor-type-id="text-editor">
138
-                <state relative-caret-position="180">
139
-                  <caret line="23" column="40" selection-start-line="23" selection-start-column="40" selection-end-line="23" selection-end-column="40" />
141
+                <state relative-caret-position="450">
142
+                  <caret line="34" column="5" lean-forward="true" selection-start-line="34" selection-start-column="5" selection-end-line="34" selection-end-column="5" />
140 143
                   <folding>
141 144
                     <element signature="imports" expanded="true" />
142 145
                   </folding>
@@ -144,42 +147,13 @@
144 147
               </provider>
145 148
             </entry>
146 149
           </file>
147
-          <file pinned="false" current-in-tab="false">
148
-            <entry file="file://$PROJECT_DIR$/src/main/java/MockDao.java">
150
+          <file pinned="false" current-in-tab="true">
151
+            <entry file="file://$PROJECT_DIR$/src/test/java/MySqlDriveTest.java">
149 152
               <provider selected="true" editor-type-id="text-editor">
150
-                <state relative-caret-position="301">
151
-                  <caret line="73" column="60" selection-start-line="73" selection-start-column="60" selection-end-line="73" selection-end-column="60" />
153
+                <state relative-caret-position="675">
154
+                  <caret line="45" column="7" selection-start-line="45" selection-start-column="7" selection-end-line="45" selection-end-column="7" />
152 155
                   <folding>
153 156
                     <element signature="imports" expanded="true" />
154
-                    <element signature="e#1719#1720#0" expanded="true" />
155
-                    <element signature="e#1746#1747#0" expanded="true" />
156
-                    <element signature="e#2014#2015#0" expanded="true" />
157
-                    <element signature="e#1925#1926#0" expanded="true" />
158
-                    <element signature="e#1952#1953#0" expanded="true" />
159
-                    <element signature="e#3500#3501#0" expanded="true" />
160
-                    <element signature="e#3527#3528#0" expanded="true" />
161
-                    <element signature="e#3598#3599#0" expanded="true" />
162
-                    <element signature="e#3625#3626#0" expanded="true" />
163
-                    <element signature="e#4013#4014#0" expanded="true" />
164
-                    <element signature="e#4040#4041#0" expanded="true" />
165
-                    <element signature="e#4159#4160#0" expanded="true" />
166
-                    <element signature="e#4186#4187#0" expanded="true" />
167
-                    <element signature="e#5585#5586#0" expanded="true" />
168
-                    <element signature="e#5612#5613#0" expanded="true" />
169
-                    <element signature="e#5906#5907#0" expanded="true" />
170
-                    <element signature="e#5933#5934#0" expanded="true" />
171
-                    <element signature="e#6009#6010#0" expanded="true" />
172
-                    <element signature="e#6036#6037#0" expanded="true" />
173
-                    <element signature="e#6086#6087#0" expanded="true" />
174
-                    <element signature="e#6114#6115#0" expanded="true" />
175
-                    <element signature="e#6921#6922#0" expanded="true" />
176
-                    <element signature="e#6948#6949#0" expanded="true" />
177
-                    <element signature="e#7334#7335#0" expanded="true" />
178
-                    <element signature="e#7361#7362#0" expanded="true" />
179
-                    <element signature="e#8433#8434#0" expanded="true" />
180
-                    <element signature="e#8460#8461#0" expanded="true" />
181
-                    <element signature="e#8630#8631#0" expanded="true" />
182
-                    <element signature="e#8657#8658#0" expanded="true" />
183 157
                   </folding>
184 158
                 </state>
185 159
               </provider>
@@ -189,7 +163,7 @@
189 163
             <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/9431aac8-f492-452b-bef7-9dfc00b1f123/console.sql">
190 164
               <provider selected="true" editor-type-id="text-editor">
191 165
                 <state relative-caret-position="135">
192
-                  <caret line="9" column="9" lean-forward="true" selection-start-line="9" selection-start-column="9" selection-end-line="9" selection-end-column="9" />
166
+                  <caret line="9" column="9" selection-start-line="9" selection-start-column="9" selection-end-line="9" selection-end-column="9" />
193 167
                 </state>
194 168
               </provider>
195 169
             </entry>
@@ -206,30 +180,14 @@
206 180
         </leaf>
207 181
       </split-first>
208 182
       <split-second>
209
-        <leaf>
183
+        <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
210 184
           <file pinned="false" current-in-tab="false">
211 185
             <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
212 186
               <provider selected="true" editor-type-id="text-editor">
213
-                <state relative-caret-position="179">
187
+                <state relative-caret-position="1005">
214 188
                   <caret line="83" column="56" selection-start-line="83" selection-start-column="56" selection-end-line="83" selection-end-column="56" />
215 189
                   <folding>
216 190
                     <element signature="imports" expanded="true" />
217
-                    <element signature="e#714#715#0" expanded="true" />
218
-                    <element signature="e#773#774#0" expanded="true" />
219
-                    <element signature="e#720#721#0" expanded="true" />
220
-                    <element signature="e#768#769#0" expanded="true" />
221
-                    <element signature="e#803#804#0" expanded="true" />
222
-                    <element signature="e#856#857#0" expanded="true" />
223
-                    <element signature="e#894#895#0" expanded="true" />
224
-                    <element signature="e#953#954#0" expanded="true" />
225
-                    <element signature="e#808#809#0" expanded="true" />
226
-                    <element signature="e#850#851#0" expanded="true" />
227
-                    <element signature="e#1092#1093#0" expanded="true" />
228
-                    <element signature="e#1117#1118#0" expanded="true" />
229
-                    <element signature="e#1177#1178#0" expanded="true" />
230
-                    <element signature="e#1236#1237#0" expanded="true" />
231
-                    <element signature="e#1177#1178#0" expanded="true" />
232
-                    <element signature="e#1202#1203#0" expanded="true" />
233 191
                   </folding>
234 192
                 </state>
235 193
               </provider>
@@ -238,8 +196,8 @@
238 196
           <file pinned="false" current-in-tab="true">
239 197
             <entry file="file://$PROJECT_DIR$/src/main/java/MySqlDriver.java">
240 198
               <provider selected="true" editor-type-id="text-editor">
241
-                <state relative-caret-position="-432">
242
-                  <caret line="19" column="31" selection-start-line="19" selection-start-column="31" selection-end-line="19" selection-end-column="31" />
199
+                <state relative-caret-position="134">
200
+                  <caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
243 201
                   <folding>
244 202
                     <element signature="imports" expanded="true" />
245 203
                   </folding>
@@ -248,6 +206,15 @@
248 206
             </entry>
249 207
           </file>
250 208
           <file pinned="false" current-in-tab="false">
209
+            <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/dao/BaseDaoImpl.class">
210
+              <provider selected="true" editor-type-id="text-editor">
211
+                <state relative-caret-position="-287">
212
+                  <caret line="43" column="12" lean-forward="true" selection-start-line="43" selection-start-column="12" selection-end-line="43" selection-end-column="12" />
213
+                </state>
214
+              </provider>
215
+            </entry>
216
+          </file>
217
+          <file pinned="false" current-in-tab="false">
251 218
             <entry file="das://9431aac8-f492-452b-bef7-9dfc00b1f123/schema/orm_lab/table/account">
252 219
               <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
253 220
                 <state>
@@ -279,6 +246,12 @@
279 246
       <find>databasetyp</find>
280 247
       <find>updateBy</find>
281 248
       <find>toStrin</find>
249
+      <find>queryBuil</find>
250
+      <find>queryBuilder</find>
251
+      <find>query</find>
252
+      <find>querybuil</find>
253
+      <find>querybuild</find>
254
+      <find>connectionS</find>
282 255
     </findStrings>
283 256
   </component>
284 257
   <component name="Git.Settings">
@@ -293,12 +266,12 @@
293 266
         <option value="$PROJECT_DIR$/pom.xml" />
294 267
         <option value="$PROJECT_DIR$/src/main/java/Service.java" />
295 268
         <option value="$PROJECT_DIR$/src/main/java/DatabaseConnection.java" />
296
-        <option value="$PROJECT_DIR$/src/main/java/Account.java" />
297
-        <option value="$PROJECT_DIR$/src/main/java/MockDao.java" />
298
-        <option value="$PROJECT_DIR$/src/test/java/MySqlDriveTest.java" />
299
-        <option value="$PROJECT_DIR$/src/main/java/MySqlDriver.java" />
300 269
         <option value="$PROJECT_DIR$/src/main/java/Console.java" />
301 270
         <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
271
+        <option value="$PROJECT_DIR$/src/main/java/Account.java" />
272
+        <option value="$PROJECT_DIR$/src/main/java/MySqlDriver.java" />
273
+        <option value="$PROJECT_DIR$/src/test/java/MySqlDriveTest.java" />
274
+        <option value="$PROJECT_DIR$/src/main/java/MockDao.java" />
302 275
       </list>
303 276
     </option>
304 277
   </component>
@@ -315,11 +288,9 @@
315 288
       </MavenImportingSettings>
316 289
     </option>
317 290
   </component>
318
-  <component name="ProjectFrameBounds" fullScreen="true">
319
-    <option name="x" value="-333" />
320
-    <option name="y" value="-1080" />
321
-    <option name="width" value="1920" />
322
-    <option name="height" value="1080" />
291
+  <component name="ProjectFrameBounds" extendedState="6" fullScreen="true">
292
+    <option name="width" value="1280" />
293
+    <option name="height" value="800" />
323 294
   </component>
324 295
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
325 296
   <component name="ProjectView">
@@ -327,7 +298,6 @@
327 298
       <foldersAlwaysOnTop value="true" />
328 299
     </navigator>
329 300
     <panes>
330
-      <pane id="Scope" />
331 301
       <pane id="PackagesPane" />
332 302
       <pane id="ProjectPane">
333 303
         <subPane>
@@ -376,13 +346,14 @@
376 346
           <select />
377 347
         </subPane>
378 348
       </pane>
349
+      <pane id="Scope" />
379 350
     </panes>
380 351
   </component>
381 352
   <component name="PropertiesComponent">
382 353
     <property name="DatabaseDriversLRU" value="mysql" />
383 354
     <property name="WebServerToolWindowFactoryState" value="false" />
384 355
     <property name="aspect.path.notification.shown" value="true" />
385
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542501272481" />
356
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542662579787" />
386 357
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="Arquillian JUnit4" />
387 358
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrarySuperClass.Arquillian JUnit4" value="" />
388 359
     <property name="database.console.LAST_STATE" value="false" />
@@ -391,6 +362,7 @@
391 362
     <property name="project.structure.last.edited" value="Modules" />
392 363
     <property name="project.structure.proportion" value="0.15" />
393 364
     <property name="project.structure.side.proportion" value="0.2" />
365
+    <property name="run.code.analysis.last.selected.profile" value="pProject Default" />
394 366
   </component>
395 367
   <component name="RecentsManager">
396 368
     <key name="CreateTestDialog.RecentsKey">
@@ -413,46 +385,49 @@
413 385
     </option>
414 386
   </component>
415 387
   <component name="RunManager" selected="JUnit.MySqlDriveTest">
416
-    <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
417
-      <option name="MAIN_CLASS_NAME" value="AccountApp" />
388
+    <configuration name="MySqlDriveTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
418 389
       <module name="ORMLite" />
390
+      <option name="PACKAGE_NAME" value="" />
391
+      <option name="MAIN_CLASS_NAME" value="MySqlDriveTest" />
419 392
       <method v="2">
420 393
         <option name="Make" enabled="true" />
421 394
       </method>
422 395
     </configuration>
423
-    <configuration name="MySqlDriveTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
396
+    <configuration name="MySqlDriveTest.testDeleteId" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
424 397
       <module name="ORMLite" />
425 398
       <option name="PACKAGE_NAME" value="" />
426 399
       <option name="MAIN_CLASS_NAME" value="MySqlDriveTest" />
400
+      <option name="METHOD_NAME" value="testDeleteId" />
401
+      <option name="TEST_OBJECT" value="method" />
427 402
       <method v="2">
428 403
         <option name="Make" enabled="true" />
429 404
       </method>
430 405
     </configuration>
431
-    <configuration name="MySqlDriveTest.testUpdate" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
406
+    <configuration name="MySqlDriveTest.testDeleteName" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
432 407
       <module name="ORMLite" />
433 408
       <option name="PACKAGE_NAME" value="" />
434 409
       <option name="MAIN_CLASS_NAME" value="MySqlDriveTest" />
435
-      <option name="METHOD_NAME" value="testUpdate" />
410
+      <option name="METHOD_NAME" value="testDeleteName" />
436 411
       <option name="TEST_OBJECT" value="method" />
437 412
       <method v="2">
438 413
         <option name="Make" enabled="true" />
439 414
       </method>
440 415
     </configuration>
441
-    <configuration name="MySqlDriveTest.updateName" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
416
+    <configuration name="MySqlDriveTest.testQueryId" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
442 417
       <module name="ORMLite" />
443 418
       <option name="PACKAGE_NAME" value="" />
444 419
       <option name="MAIN_CLASS_NAME" value="MySqlDriveTest" />
445
-      <option name="METHOD_NAME" value="updateName" />
420
+      <option name="METHOD_NAME" value="testQueryId" />
446 421
       <option name="TEST_OBJECT" value="method" />
447 422
       <method v="2">
448 423
         <option name="Make" enabled="true" />
449 424
       </method>
450 425
     </configuration>
451
-    <configuration name="MySqlDriveTest.updatePassword" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
426
+    <configuration name="MySqlDriveTest.testQueryName" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
452 427
       <module name="ORMLite" />
453 428
       <option name="PACKAGE_NAME" value="" />
454 429
       <option name="MAIN_CLASS_NAME" value="MySqlDriveTest" />
455
-      <option name="METHOD_NAME" value="updatePassword" />
430
+      <option name="METHOD_NAME" value="testQueryName" />
456 431
       <option name="TEST_OBJECT" value="method" />
457 432
       <method v="2">
458 433
         <option name="Make" enabled="true" />
@@ -460,18 +435,18 @@
460 435
     </configuration>
461 436
     <list>
462 437
       <item itemvalue="JUnit.MySqlDriveTest" />
463
-      <item itemvalue="JUnit.MySqlDriveTest.updateName" />
464
-      <item itemvalue="JUnit.MySqlDriveTest.testUpdate" />
465
-      <item itemvalue="JUnit.MySqlDriveTest.updatePassword" />
466
-      <item itemvalue="Application.AccountApp" />
438
+      <item itemvalue="JUnit.MySqlDriveTest.testDeleteId" />
439
+      <item itemvalue="JUnit.MySqlDriveTest.testDeleteName" />
440
+      <item itemvalue="JUnit.MySqlDriveTest.testQueryId" />
441
+      <item itemvalue="JUnit.MySqlDriveTest.testQueryName" />
467 442
     </list>
468 443
     <recent_temporary>
469 444
       <list>
470 445
         <item itemvalue="JUnit.MySqlDriveTest" />
471
-        <item itemvalue="Application.AccountApp" />
472
-        <item itemvalue="JUnit.MySqlDriveTest.updatePassword" />
473
-        <item itemvalue="JUnit.MySqlDriveTest.updateName" />
474
-        <item itemvalue="JUnit.MySqlDriveTest.testUpdate" />
446
+        <item itemvalue="JUnit.MySqlDriveTest.testQueryName" />
447
+        <item itemvalue="JUnit.MySqlDriveTest.testQueryId" />
448
+        <item itemvalue="JUnit.MySqlDriveTest.testDeleteId" />
449
+        <item itemvalue="JUnit.MySqlDriveTest.testDeleteName" />
475 450
       </list>
476 451
     </recent_temporary>
477 452
   </component>
@@ -487,44 +462,45 @@
487 462
       <updated>1542309696171</updated>
488 463
       <workItem from="1542309702788" duration="18534000" />
489 464
       <workItem from="1542335736358" duration="6697000" />
490
-      <workItem from="1542378639704" duration="27119000" />
465
+      <workItem from="1542378639704" duration="28281000" />
466
+      <workItem from="1542580772331" duration="6247000" />
491 467
     </task>
492 468
     <servers />
493 469
   </component>
494 470
   <component name="TestHistory">
495
-    <history-entry file="MySqlDriveTest_testRead - 2018.11.16 at 18h 08m 25s.xml">
496
-      <configuration name="MySqlDriveTest.testRead" configurationId="JUnit" />
471
+    <history-entry file="MySqlDriveTest_testDeleteId - 2018.11.19 at 09h 10m 54s.xml">
472
+      <configuration name="MySqlDriveTest.testDeleteId" configurationId="JUnit" />
497 473
     </history-entry>
498
-    <history-entry file="MySqlDriveTest - 2018.11.16 at 18h 10m 58s.xml">
499
-      <configuration name="MySqlDriveTest" configurationId="JUnit" />
474
+    <history-entry file="MySqlDriveTest_testDeleteId - 2018.11.19 at 09h 16m 21s.xml">
475
+      <configuration name="MySqlDriveTest.testDeleteId" configurationId="JUnit" />
500 476
     </history-entry>
501
-    <history-entry file="MySqlDriveTest - 2018.11.16 at 18h 12m 27s.xml">
502
-      <configuration name="MySqlDriveTest" configurationId="JUnit" />
477
+    <history-entry file="MySqlDriveTest_testDeleteName - 2018.11.19 at 09h 16m 54s.xml">
478
+      <configuration name="MySqlDriveTest.testDeleteName" configurationId="JUnit" />
503 479
     </history-entry>
504
-    <history-entry file="MySqlDriveTest_updateName - 2018.11.16 at 18h 12m 32s.xml">
505
-      <configuration name="MySqlDriveTest.updateName" configurationId="JUnit" />
480
+    <history-entry file="MySqlDriveTest - 2018.11.19 at 11h 48m 53s.xml">
481
+      <configuration name="MySqlDriveTest" configurationId="JUnit" />
506 482
     </history-entry>
507
-    <history-entry file="MySqlDriveTest_testUpdate - 2018.11.16 at 18h 15m 32s.xml">
508
-      <configuration name="MySqlDriveTest.testUpdate" configurationId="JUnit" />
483
+    <history-entry file="MySqlDriveTest - 2018.11.19 at 11h 54m 22s.xml">
484
+      <configuration name="MySqlDriveTest" configurationId="JUnit" />
509 485
     </history-entry>
510
-    <history-entry file="MySqlDriveTest_updateName - 2018.11.16 at 18h 15m 34s.xml">
511
-      <configuration name="MySqlDriveTest.updateName" configurationId="JUnit" />
486
+    <history-entry file="MySqlDriveTest - 2018.11.19 at 11h 54m 29s.xml">
487
+      <configuration name="MySqlDriveTest" configurationId="JUnit" />
512 488
     </history-entry>
513
-    <history-entry file="MySqlDriveTest_updateName - 2018.11.16 at 18h 21m 38s.xml">
514
-      <configuration name="MySqlDriveTest.updateName" configurationId="JUnit" />
489
+    <history-entry file="MySqlDriveTest_testDeleteId - 2018.11.19 at 12h 01m 47s.xml">
490
+      <configuration name="MySqlDriveTest.testDeleteId" configurationId="JUnit" />
515 491
     </history-entry>
516
-    <history-entry file="MySqlDriveTest_updateName - 2018.11.16 at 18h 34m 23s.xml">
517
-      <configuration name="MySqlDriveTest.updateName" configurationId="JUnit" />
492
+    <history-entry file="MySqlDriveTest_testQueryId - 2018.11.19 at 12h 01m 53s.xml">
493
+      <configuration name="MySqlDriveTest.testQueryId" configurationId="JUnit" />
518 494
     </history-entry>
519
-    <history-entry file="MySqlDriveTest_updatePassword - 2018.11.16 at 18h 34m 27s.xml">
520
-      <configuration name="MySqlDriveTest.updatePassword" configurationId="JUnit" />
495
+    <history-entry file="MySqlDriveTest_testQueryName - 2018.11.19 at 13h 23m 22s.xml">
496
+      <configuration name="MySqlDriveTest.testQueryName" configurationId="JUnit" />
521 497
     </history-entry>
522
-    <history-entry file="MySqlDriveTest_updatePassword - 2018.11.16 at 18h 38m 37s.xml">
523
-      <configuration name="MySqlDriveTest.updatePassword" configurationId="JUnit" />
498
+    <history-entry file="MySqlDriveTest - 2018.11.19 at 14h 32m 09s.xml">
499
+      <configuration name="MySqlDriveTest" configurationId="JUnit" />
524 500
     </history-entry>
525 501
   </component>
526 502
   <component name="TimeTrackingManager">
527
-    <option name="totallyTimeSpent" value="52350000" />
503
+    <option name="totallyTimeSpent" value="59759000" />
528 504
   </component>
529 505
   <component name="TodoView">
530 506
     <todo-panel id="selected-file">
@@ -536,10 +512,10 @@
536 512
     </todo-panel>
537 513
   </component>
538 514
   <component name="ToolWindowManager">
539
-    <frame x="-333" y="-1080" width="1920" height="1080" extended-state="0" />
515
+    <frame x="0" y="0" width="1280" height="800" extended-state="6" />
540 516
     <editor active="true" />
541 517
     <layout>
542
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.12193823" />
518
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.09127625" />
543 519
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
544 520
       <window_info id="Image Layers" order="2" />
545 521
       <window_info id="Designer" order="3" />
@@ -548,7 +524,7 @@
548 524
       <window_info id="Favorites" order="6" side_tool="true" />
549 525
       <window_info anchor="bottom" id="Message" order="0" />
550 526
       <window_info anchor="bottom" id="Find" order="1" weight="0.32928064" />
551
-      <window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.45187438" />
527
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.17397454" />
552 528
       <window_info anchor="bottom" id="Debug" order="3" weight="0.39918947" />
553 529
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
554 530
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -556,9 +532,9 @@
556 532
       <window_info anchor="bottom" id="Database Console" order="7" weight="0.2234795" />
557 533
       <window_info anchor="bottom" id="Version Control" order="8" show_stripe_button="false" />
558 534
       <window_info anchor="bottom" id="Database Changes" order="9" />
559
-      <window_info anchor="bottom" id="Terminal" order="10" weight="0.14994934" />
535
+      <window_info anchor="bottom" id="Terminal" order="10" weight="0.10030395" />
560 536
       <window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
561
-      <window_info anchor="bottom" id="Messages" order="12" weight="0.32928064" />
537
+      <window_info anchor="bottom" id="Messages" order="12" weight="0.3281471" />
562 538
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
563 539
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
564 540
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -568,6 +544,7 @@
568 544
       <window_info anchor="right" id="Theme Preview" order="6" />
569 545
       <window_info anchor="right" id="Palette&#9;" order="7" />
570 546
       <window_info anchor="right" id="Maven Projects" order="8" />
547
+      <window_info anchor="right" id="Coverage" order="9" side_tool="true" weight="0.17124394" />
571 548
     </layout>
572 549
   </component>
573 550
   <component name="TypeScriptGeneratedFilesManager">
@@ -619,33 +596,8 @@
619 596
       </provider>
620 597
     </entry>
621 598
     <entry file="file://$PROJECT_DIR$/src/test/java/MySqlDriverTest2.java" />
622
-    <entry file="file://$PROJECT_DIR$/pom.xml">
623
-      <provider selected="true" editor-type-id="text-editor">
624
-        <state relative-caret-position="412">
625
-          <caret line="30" selection-start-line="30" selection-end-line="30" />
626
-        </state>
627
-      </provider>
628
-    </entry>
629
-    <entry file="file://$PROJECT_DIR$/src/main/java/DatabaseConnection.java">
630
-      <provider selected="true" editor-type-id="text-editor">
631
-        <state relative-caret-position="255">
632
-          <caret line="17" selection-start-line="17" selection-end-line="17" />
633
-          <folding>
634
-            <element signature="imports" expanded="true" />
635
-          </folding>
636
-        </state>
637
-      </provider>
638
-    </entry>
639
-    <entry file="file://$PROJECT_DIR$/src/main/java/Service.java">
640
-      <provider selected="true" editor-type-id="text-editor">
641
-        <state relative-caret-position="-112">
642
-          <caret line="7" column="32" selection-start-line="7" selection-start-column="32" selection-end-line="7" selection-end-column="32" />
643
-          <folding>
644
-            <element signature="imports" expanded="true" />
645
-          </folding>
646
-        </state>
647
-      </provider>
648
-    </entry>
599
+    <entry file="file://$PROJECT_DIR$/src/main/java/DatabaseConnection.java" />
600
+    <entry file="file://$PROJECT_DIR$/src/main/java/Service.java" />
649 601
     <entry file="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/org/junit/internal/runners/model/EachTestNotifier.class">
650 602
       <provider selected="true" editor-type-id="text-editor">
651 603
         <state relative-caret-position="330">
@@ -664,14 +616,6 @@
664 616
       <provider selected="true" editor-type-id="text-editor">
665 617
         <state relative-caret-position="173">
666 618
           <caret line="226" column="16" selection-start-line="226" selection-start-column="16" selection-end-line="226" selection-end-column="16" />
667
-          <folding>
668
-            <element signature="e#2111#2112#0" expanded="true" />
669
-            <element signature="e#2155#2156#0" expanded="true" />
670
-            <element signature="e#5951#6086#0" expanded="true" />
671
-            <element signature="e#6085#6086#0" expanded="true" />
672
-            <element signature="e#6484#6648#0" expanded="true" />
673
-            <element signature="e#6647#6648#0" expanded="true" />
674
-          </folding>
675 619
         </state>
676 620
       </provider>
677 621
     </entry>
@@ -682,13 +626,6 @@
682 626
         </state>
683 627
       </provider>
684 628
     </entry>
685
-    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/dao/Dao.class">
686
-      <provider selected="true" editor-type-id="text-editor">
687
-        <state relative-caret-position="90">
688
-          <caret line="26" column="17" selection-start-line="26" selection-start-column="17" selection-end-line="26" selection-end-column="17" />
689
-        </state>
690
-      </provider>
691
-    </entry>
692 629
     <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/table/TableInfo.class">
693 630
       <provider selected="true" editor-type-id="text-editor">
694 631
         <state relative-caret-position="315">
@@ -717,64 +654,30 @@
717 654
         </state>
718 655
       </provider>
719 656
     </entry>
720
-    <entry file="file://$PROJECT_DIR$/src/main/java/MockDao.java">
721
-      <provider selected="true" editor-type-id="text-editor">
722
-        <state relative-caret-position="301">
723
-          <caret line="73" column="60" selection-start-line="73" selection-start-column="60" selection-end-line="73" selection-end-column="60" />
724
-          <folding>
725
-            <element signature="imports" expanded="true" />
726
-            <element signature="e#1719#1720#0" expanded="true" />
727
-            <element signature="e#1746#1747#0" expanded="true" />
728
-            <element signature="e#2014#2015#0" expanded="true" />
729
-            <element signature="e#1925#1926#0" expanded="true" />
730
-            <element signature="e#1952#1953#0" expanded="true" />
731
-            <element signature="e#3500#3501#0" expanded="true" />
732
-            <element signature="e#3527#3528#0" expanded="true" />
733
-            <element signature="e#3598#3599#0" expanded="true" />
734
-            <element signature="e#3625#3626#0" expanded="true" />
735
-            <element signature="e#4013#4014#0" expanded="true" />
736
-            <element signature="e#4040#4041#0" expanded="true" />
737
-            <element signature="e#4159#4160#0" expanded="true" />
738
-            <element signature="e#4186#4187#0" expanded="true" />
739
-            <element signature="e#5585#5586#0" expanded="true" />
740
-            <element signature="e#5612#5613#0" expanded="true" />
741
-            <element signature="e#5906#5907#0" expanded="true" />
742
-            <element signature="e#5933#5934#0" expanded="true" />
743
-            <element signature="e#6009#6010#0" expanded="true" />
744
-            <element signature="e#6036#6037#0" expanded="true" />
745
-            <element signature="e#6086#6087#0" expanded="true" />
746
-            <element signature="e#6114#6115#0" expanded="true" />
747
-            <element signature="e#6921#6922#0" expanded="true" />
748
-            <element signature="e#6948#6949#0" expanded="true" />
749
-            <element signature="e#7334#7335#0" expanded="true" />
750
-            <element signature="e#7361#7362#0" expanded="true" />
751
-            <element signature="e#8433#8434#0" expanded="true" />
752
-            <element signature="e#8460#8461#0" expanded="true" />
753
-            <element signature="e#8630#8631#0" expanded="true" />
754
-            <element signature="e#8657#8658#0" expanded="true" />
755
-          </folding>
756
-        </state>
757
-      </provider>
758
-    </entry>
759 657
     <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/9431aac8-f492-452b-bef7-9dfc00b1f123/console.sql">
760 658
       <provider selected="true" editor-type-id="text-editor">
761 659
         <state relative-caret-position="135">
762
-          <caret line="9" column="9" lean-forward="true" selection-start-line="9" selection-start-column="9" selection-end-line="9" selection-end-column="9" />
660
+          <caret line="9" column="9" selection-start-line="9" selection-start-column="9" selection-end-line="9" selection-end-column="9" />
763 661
         </state>
764 662
       </provider>
765 663
     </entry>
766
-    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
664
+    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
767 665
       <provider selected="true" editor-type-id="text-editor">
768
-        <state relative-caret-position="780">
769
-          <caret line="66" column="5" selection-start-line="66" selection-start-column="5" selection-end-line="66" selection-end-column="5" />
666
+        <state relative-caret-position="1005">
667
+          <caret line="83" column="56" selection-start-line="83" selection-start-column="56" selection-end-line="83" selection-end-column="56" />
770 668
           <folding>
771 669
             <element signature="imports" expanded="true" />
772
-            <element signature="e#1834#1835#0" expanded="true" />
773
-            <element signature="e#1908#1909#0" expanded="true" />
774 670
           </folding>
775 671
         </state>
776 672
       </provider>
777 673
     </entry>
674
+    <entry file="file://$PROJECT_DIR$/pom.xml">
675
+      <provider selected="true" editor-type-id="text-editor">
676
+        <state relative-caret-position="135">
677
+          <caret line="30" selection-start-line="30" selection-end-line="30" />
678
+        </state>
679
+      </provider>
680
+    </entry>
778 681
     <entry file="das://9431aac8-f492-452b-bef7-9dfc00b1f123/schema/orm_lab/table/account">
779 682
       <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
780 683
         <state>
@@ -782,56 +685,80 @@
782 685
         </state>
783 686
       </provider>
784 687
     </entry>
785
-    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
688
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
786 689
       <provider selected="true" editor-type-id="text-editor">
787
-        <state relative-caret-position="179">
788
-          <caret line="83" column="56" selection-start-line="83" selection-start-column="56" selection-end-line="83" selection-end-column="56" />
690
+        <state relative-caret-position="387">
691
+          <caret line="84" column="33" selection-start-line="84" selection-start-column="33" selection-end-line="84" selection-end-column="33" />
692
+          <folding>
693
+            <element signature="imports" expanded="true" />
694
+          </folding>
695
+        </state>
696
+      </provider>
697
+    </entry>
698
+    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
699
+      <provider selected="true" editor-type-id="text-editor">
700
+        <state relative-caret-position="450">
701
+          <caret line="34" column="5" lean-forward="true" selection-start-line="34" selection-start-column="5" selection-end-line="34" selection-end-column="5" />
789 702
           <folding>
790 703
             <element signature="imports" expanded="true" />
791
-            <element signature="e#714#715#0" expanded="true" />
792
-            <element signature="e#773#774#0" expanded="true" />
793
-            <element signature="e#720#721#0" expanded="true" />
794
-            <element signature="e#768#769#0" expanded="true" />
795
-            <element signature="e#803#804#0" expanded="true" />
796
-            <element signature="e#856#857#0" expanded="true" />
797
-            <element signature="e#894#895#0" expanded="true" />
798
-            <element signature="e#953#954#0" expanded="true" />
799
-            <element signature="e#808#809#0" expanded="true" />
800
-            <element signature="e#850#851#0" expanded="true" />
801
-            <element signature="e#1092#1093#0" expanded="true" />
802
-            <element signature="e#1117#1118#0" expanded="true" />
803
-            <element signature="e#1177#1178#0" expanded="true" />
804
-            <element signature="e#1236#1237#0" expanded="true" />
805
-            <element signature="e#1177#1178#0" expanded="true" />
806
-            <element signature="e#1202#1203#0" expanded="true" />
807 704
           </folding>
808 705
         </state>
809 706
       </provider>
810 707
     </entry>
708
+    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/stmt/DeleteBuilder.class">
709
+      <provider selected="true" editor-type-id="text-editor">
710
+        <state relative-caret-position="90">
711
+          <caret line="14" column="13" selection-start-line="14" selection-start-column="13" selection-end-line="14" selection-end-column="13" />
712
+        </state>
713
+      </provider>
714
+    </entry>
715
+    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/stmt/QueryBuilder.class">
716
+      <provider selected="true" editor-type-id="text-editor">
717
+        <state relative-caret-position="-9717">
718
+          <caret line="22" column="13" selection-start-line="22" selection-start-column="13" selection-end-line="22" selection-end-column="13" />
719
+        </state>
720
+      </provider>
721
+    </entry>
722
+    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/dao/BaseDaoImpl.class">
723
+      <provider selected="true" editor-type-id="text-editor">
724
+        <state relative-caret-position="-287">
725
+          <caret line="43" column="12" lean-forward="true" selection-start-line="43" selection-start-column="12" selection-end-line="43" selection-end-column="12" />
726
+        </state>
727
+      </provider>
728
+    </entry>
729
+    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-core/4.48/ormlite-core-4.48.jar!/com/j256/ormlite/dao/Dao.class">
730
+      <provider selected="true" editor-type-id="text-editor">
731
+        <state relative-caret-position="65">
732
+          <caret line="45" column="14" selection-start-line="45" selection-start-column="4" selection-end-line="45" selection-end-column="14" />
733
+        </state>
734
+      </provider>
735
+    </entry>
811 736
     <entry file="file://$PROJECT_DIR$/src/main/java/MySqlDriver.java">
812 737
       <provider selected="true" editor-type-id="text-editor">
813
-        <state relative-caret-position="-432">
814
-          <caret line="19" column="31" selection-start-line="19" selection-start-column="31" selection-end-line="19" selection-end-column="31" />
738
+        <state relative-caret-position="134">
739
+          <caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
815 740
           <folding>
816 741
             <element signature="imports" expanded="true" />
817 742
           </folding>
818 743
         </state>
819 744
       </provider>
820 745
     </entry>
821
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
746
+    <entry file="file://$PROJECT_DIR$/src/main/java/MockDao.java">
822 747
       <provider selected="true" editor-type-id="text-editor">
823
-        <state relative-caret-position="-1032">
824
-          <caret line="84" column="33" selection-start-line="84" selection-start-column="33" selection-end-line="84" selection-end-column="33" />
748
+        <state relative-caret-position="-3811">
749
+          <caret line="68" column="71" selection-start-line="68" selection-start-column="71" selection-end-line="68" selection-end-column="71" />
825 750
           <folding>
826 751
             <element signature="imports" expanded="true" />
752
+            <element signature="e#1987#1988#0" expanded="true" />
753
+            <element signature="e#2014#2015#0" expanded="true" />
827 754
           </folding>
828 755
         </state>
829 756
       </provider>
830 757
     </entry>
831 758
     <entry file="file://$PROJECT_DIR$/src/test/java/MySqlDriveTest.java">
832 759
       <provider selected="true" editor-type-id="text-editor">
833
-        <state relative-caret-position="180">
834
-          <caret line="23" column="40" selection-start-line="23" selection-start-column="40" selection-end-line="23" selection-end-column="40" />
760
+        <state relative-caret-position="675">
761
+          <caret line="45" column="7" selection-start-line="45" selection-start-column="7" selection-end-line="45" selection-end-column="7" />
835 762
           <folding>
836 763
             <element signature="imports" expanded="true" />
837 764
           </folding>

+ 14
- 14
src/main/java/AccountApp.java Näytä tiedosto

@@ -13,7 +13,7 @@ public class AccountApp {
13 13
     private String username = "root";
14 14
     private String password = "qwerty";
15 15
     static final Console console = new Console(System.in, System.out);
16
-    private MySqlDriver mySqlDriver;
16
+    private AccountService accountService;
17 17
 
18 18
     public static void main(String[] args) throws Exception {
19 19
         // turn our static method into an instance of Main
@@ -26,7 +26,7 @@ public class AccountApp {
26 26
         try {
27 27
             connectionSource = new JdbcConnectionSource(DATABASE_URL, username, password);
28 28
             setupDao(connectionSource);
29
-            mySqlDriver = new MySqlDriver(accountDao);
29
+            accountService = new AccountService(accountDao);
30 30
 
31 31
             console.welcome();
32 32
             boolean open = true;
@@ -56,7 +56,7 @@ public class AccountApp {
56 56
             newAccount();
57 57
         } else if (input.equals("update")) {
58 58
             try {
59
-                Account acct = mySqlDriver.selectAccount(console.getId());
59
+                Account acct = accountService.selectAccount(console.getId());
60 60
                 updateBy(acct);
61 61
             } catch (IndexOutOfBoundsException np) {
62 62
                 console.accountDNE();
@@ -72,7 +72,7 @@ public class AccountApp {
72 72
         String name = console.getName();
73 73
         String p = console.getPassword();
74 74
         Account account = new Account(name, p);
75
-        mySqlDriver.create(account);
75
+        accountService.create(account);
76 76
     }
77 77
 
78 78
     private void updateBy(Account accounts) throws Exception{
@@ -91,12 +91,12 @@ public class AccountApp {
91 91
     private void updateName(Account account) throws SQLException{
92 92
         String name = console.getName();
93 93
         account.setName(name);
94
-        mySqlDriver.updateName(account, name);
94
+        accountService.updateName(account, name);
95 95
     }
96 96
     private void updatePassword(Account account) throws SQLException {
97 97
         String pw = console.getPassword();
98 98
         account.setPassword(pw);
99
-        mySqlDriver.update(account);
99
+        accountService.update(account);
100 100
     }
101 101
 
102 102
     private List<Account> query() throws SQLException{
@@ -118,7 +118,7 @@ public class AccountApp {
118 118
     }
119 119
 
120 120
     private List<Account> queryAll() throws SQLException {
121
-        return mySqlDriver.query();
121
+        return accountService.query();
122 122
     }
123 123
 
124 124
     private List<Account> queryBy() throws SQLException {
@@ -126,15 +126,15 @@ public class AccountApp {
126 126
 
127 127
         if (String.valueOf(input).trim().equals("name")) {
128 128
             String in = console.getName();
129
-            return mySqlDriver.queryName(in);
129
+            return accountService.queryName(in);
130 130
 
131 131
         } else if (String.valueOf(input).trim().equals("id")) {
132 132
             String in = console.getId();
133
-            return mySqlDriver.queryId(in);
133
+            return accountService.queryId(in);
134 134
 
135 135
         } else if (String.valueOf(input).trim().equals("password")) {
136 136
             String in = console.getPassword();
137
-            return mySqlDriver.queryPassword(in);
137
+            return accountService.queryPassword(in);
138 138
 
139 139
         } else if (String.valueOf(input).trim().equals("back")) {
140 140
             return null;
@@ -149,7 +149,7 @@ public class AccountApp {
149 149
 
150 150
         if (String.valueOf(input).trim().equals("all")) {
151 151
             if (console.areYouSure_delete().equals("YES"))
152
-                return mySqlDriver.deleteAll(queryAll());
152
+                return accountService.deleteAll(queryAll());
153 153
         } else if (String.valueOf(input).trim().equals("by")) {
154 154
             return deleteBy();
155 155
         }
@@ -162,15 +162,15 @@ public class AccountApp {
162 162
 
163 163
         if (String.valueOf(input).trim().equals("name")) {
164 164
             String in = console.getName();
165
-            return mySqlDriver.deleteName(in);
165
+            return accountService.deleteName(in);
166 166
 
167 167
         } else if (String.valueOf(input).trim().equals("id")) {
168 168
             String in = console.getId();
169
-            return mySqlDriver.deleteId(in);
169
+            return accountService.deleteId(in);
170 170
 
171 171
         } else if (String.valueOf(input).trim().equals("password")) {
172 172
             String in = console.getPassword();
173
-            return mySqlDriver.deletePassword(in);
173
+            return accountService.deletePassword(in);
174 174
 
175 175
         } else if (String.valueOf(input).trim().equals("back")) {
176 176
             return 0;

src/main/java/MySqlDriver.java → src/main/java/AccountService.java Näytä tiedosto

@@ -6,10 +6,10 @@ import com.j256.ormlite.stmt.UpdateBuilder;
6 6
 import java.sql.SQLException;
7 7
 import java.util.List;
8 8
 
9
-public class MySqlDriver {
9
+public class AccountService {
10 10
     private Dao<Account,Integer> accountDao;
11 11
 
12
-    public MySqlDriver(Dao accountDao){
12
+    public AccountService(Dao accountDao){
13 13
         this.accountDao = accountDao;
14 14
     }
15 15
 
@@ -80,21 +80,33 @@ public class MySqlDriver {
80 80
     }
81 81
 
82 82
     public int deleteId(String input) throws SQLException {
83
-        DeleteBuilder<Account, Integer> db = accountDao.deleteBuilder();
84
-        db.where().eq(Account.ID_FIELD_NAME, input);
85
-        return db.delete();
83
+        try {
84
+            DeleteBuilder<Account, Integer> db = accountDao.deleteBuilder();
85
+            db.where().eq(Account.ID_FIELD_NAME, input);
86
+            return db.delete();
87
+        } catch (NullPointerException e) {
88
+            return -1;
89
+        }
86 90
     }
87 91
 
88 92
     public int deleteName(String input) throws SQLException {
89
-        DeleteBuilder<Account, Integer> db = accountDao.deleteBuilder();
90
-        db.where().eq(Account.NAME_FIELD_NAME, input);
91
-        return db.delete();
93
+        try {
94
+            DeleteBuilder<Account, Integer> db = accountDao.deleteBuilder();
95
+            db.where().eq(Account.NAME_FIELD_NAME, input);
96
+            return db.delete();
97
+        } catch (NullPointerException e) {
98
+            return -1;
99
+        }
92 100
     }
93 101
 
94 102
     public int deletePassword(String input) throws SQLException {
95
-        DeleteBuilder<Account, Integer> db = accountDao.deleteBuilder();
96
-        db.where().eq(Account.PASSWORD_FIELD_NAME, input);
97
-        return db.delete();
103
+        try {
104
+            DeleteBuilder<Account, Integer> db = accountDao.deleteBuilder();
105
+            db.where().eq(Account.PASSWORD_FIELD_NAME, input);
106
+            return db.delete();
107
+        } catch (NullPointerException e) {
108
+            return -1;
109
+        }
98 110
     }
99 111
 
100 112
     public int deleteAll(List<Account> accounts) throws SQLException {

+ 2
- 3
src/main/java/MockDao.java Näytä tiedosto

@@ -1,4 +1,5 @@
1 1
 import com.j256.ormlite.dao.*;
2
+import com.j256.ormlite.db.MysqlDatabaseType;
2 3
 import com.j256.ormlite.field.DataType;
3 4
 import com.j256.ormlite.field.FieldType;
4 5
 import com.j256.ormlite.stmt.*;
@@ -16,7 +17,6 @@ import java.util.concurrent.Callable;
16 17
 
17 18
 public class MockDao implements Dao<Account, Integer> {
18 19
 
19
-
20 20
     @Override
21 21
     public Account queryForId(Integer integer) throws SQLException {
22 22
         return null;
@@ -66,8 +66,7 @@ public class MockDao implements Dao<Account, Integer> {
66 66
     }
67 67
 
68 68
     @Override
69
-    public QueryBuilder<Account, Integer> queryBuilder() {
70
-        return null;
69
+    public QueryBuilder<Account, Integer> queryBuilder() { return null;
71 70
     }
72 71
 
73 72
     @Override

src/test/java/MySqlDriveTest.java → src/test/java/AccountServiceTest.java Näytä tiedosto

@@ -6,10 +6,9 @@ import java.sql.SQLException;
6 6
 import java.util.ArrayList;
7 7
 import java.util.List;
8 8
 
9
-public class MySqlDriveTest {
10
-    List<Account> testAccts = new ArrayList<>();
9
+public class AccountServiceTest {
11 10
     MockDao mockDao = new MockDao();
12
-    MySqlDriver service;
11
+    AccountService service;
13 12
     Account plankton;
14 13
 
15 14
     @Test
@@ -26,6 +25,12 @@ public class MySqlDriveTest {
26 25
     }
27 26
 
28 27
     @Test
28
+    public void testQuery() throws SQLException {
29
+        int actual = service.query().size();
30
+        Assert.assertEquals(1, actual);
31
+    }
32
+
33
+    @Test
29 34
     public void testUpdate() throws Exception {
30 35
         int actual = service.update(plankton);
31 36
         Assert.assertEquals(1, actual);
@@ -44,14 +49,40 @@ public class MySqlDriveTest {
44 49
     }
45 50
 
46 51
     @Test
47
-    public void testDestroy() throws SQLException {
52
+    public void testDelete() throws SQLException {
48 53
         int actual = service.delete(plankton);
49 54
         Assert.assertEquals(1, actual);
50 55
     }
51 56
 
57
+    @Test
58
+    public void testDeleteId() throws SQLException {
59
+        int actual = service.deleteId("1");
60
+        Assert.assertEquals(-1, actual);
61
+    }
62
+
63
+    @Test
64
+    public void testDeleteName() throws SQLException {
65
+        int actual = service.deleteName("Plankton");
66
+        Assert.assertEquals(-1, actual);
67
+    }
68
+
69
+    @Test
70
+    public void testDeletePassword() throws SQLException {
71
+        int actual = service.deletePassword("bikiniBottom");
72
+        Assert.assertEquals(-1, actual);
73
+    }
74
+
75
+    @Test
76
+    public void testDeleteAll() throws SQLException {
77
+        List<Account> l = new ArrayList<>();
78
+        l.add(plankton);
79
+        int actual = service.deleteAll(l);
80
+        Assert.assertEquals(1, actual);
81
+    }
82
+
52 83
     @Before
53 84
     public void setup() {
54
-        service = new MySqlDriver(mockDao);
85
+        service = new AccountService(mockDao);
55 86
         plankton = new Account("Plankton","bikiniBottom");
56 87
     }
57 88
 }

BIN
target/classes/Account.class Näytä tiedosto


BIN
target/classes/MockDao.class Näytä tiedosto


BIN
target/classes/MySqlDriver.class Näytä tiedosto


BIN
target/test-classes/MySqlDriveTest.class Näytä tiedosto