Seth 6 лет назад
Родитель
Сommit
ffd90ea0aa
10 измененных файлов: 82 добавлений и 52 удалений
  1. 65
    50
      .idea/workspace.xml
  2. 2
    1
      src/main/java/AccountApp.java
  3. 8
    0
      src/main/java/AccountServ.java
  4. 7
    1
      src/test/java/AccountServTest.java
  5. Двоичные данные
      target/classes/Account.class
  6. Двоичные данные
      target/classes/AccountApp.class
  7. Двоичные данные
      target/classes/AccountServ.class
  8. Двоичные данные
      target/classes/Console.class
  9. Двоичные данные
      target/test-classes/AccountServTest.class
  10. Двоичные данные
      target/test-classes/MockDao.class

+ 65
- 50
.idea/workspace.xml Просмотреть файл

@@ -4,7 +4,7 @@
4 4
     <list default="true" id="b71a0d05-772d-4338-8f47-61b6a36d5d57" name="Default Changelist" comment="">
5 5
       <change beforePath="$PROJECT_DIR$/src/main/java/AccountApp.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
6 6
       <change beforePath="$PROJECT_DIR$/src/main/java/AccountServ.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AccountServ.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" />
7
+      <change beforePath="$PROJECT_DIR$/src/test/java/AccountServTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/AccountServTest.java" afterDir="false" />
8 8
     </list>
9 9
     <ignored path="$PROJECT_DIR$/target/" />
10 10
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -45,12 +45,12 @@
45 45
       </usages-collector>
46 46
       <usages-collector id="statistics.file.extensions.edit">
47 47
         <counts>
48
-          <entry key="java" value="1425" />
48
+          <entry key="java" value="2021" />
49 49
         </counts>
50 50
       </usages-collector>
51 51
       <usages-collector id="statistics.file.types.edit">
52 52
         <counts>
53
-          <entry key="JAVA" value="1425" />
53
+          <entry key="JAVA" value="2021" />
54 54
         </counts>
55 55
       </usages-collector>
56 56
     </session>
@@ -69,7 +69,7 @@
69 69
       <file pinned="false" current-in-tab="false">
70 70
         <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
71 71
           <provider selected="true" editor-type-id="text-editor">
72
-            <state relative-caret-position="-1666">
72
+            <state relative-caret-position="516">
73 73
               <caret line="37" column="12" selection-start-line="37" selection-start-column="10" selection-end-line="37" selection-end-column="12" />
74 74
               <folding>
75 75
                 <element signature="imports" expanded="true" />
@@ -84,20 +84,20 @@
84 84
           </provider>
85 85
         </entry>
86 86
       </file>
87
-      <file pinned="false" current-in-tab="false">
87
+      <file pinned="false" current-in-tab="true">
88 88
         <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
89 89
           <provider selected="true" editor-type-id="text-editor">
90
-            <state relative-caret-position="480">
91
-              <caret line="35" selection-start-line="35" selection-end-line="35" />
90
+            <state relative-caret-position="285">
91
+              <caret line="25" column="5" lean-forward="true" selection-start-line="25" selection-start-column="5" selection-end-line="25" selection-end-column="5" />
92 92
             </state>
93 93
           </provider>
94 94
         </entry>
95 95
       </file>
96
-      <file pinned="false" current-in-tab="true">
96
+      <file pinned="false" current-in-tab="false">
97 97
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
98 98
           <provider selected="true" editor-type-id="text-editor">
99
-            <state relative-caret-position="188">
100
-              <caret line="45" column="24" lean-forward="true" selection-start-line="45" selection-start-column="24" selection-end-line="45" selection-end-column="24" />
99
+            <state relative-caret-position="248">
100
+              <caret line="47" column="49" selection-start-line="47" selection-start-column="49" selection-end-line="47" selection-end-column="49" />
101 101
               <folding>
102 102
                 <element signature="imports" expanded="true" />
103 103
               </folding>
@@ -108,8 +108,8 @@
108 108
       <file pinned="false" current-in-tab="false">
109 109
         <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
110 110
           <provider selected="true" editor-type-id="text-editor">
111
-            <state relative-caret-position="450">
112
-              <caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
111
+            <state relative-caret-position="255">
112
+              <caret line="17" column="28" lean-forward="true" selection-start-line="17" selection-start-column="28" selection-end-line="17" selection-end-column="28" />
113 113
               <folding>
114 114
                 <element signature="imports" expanded="true" />
115 115
                 <element signature="e#175#176#0" expanded="true" />
@@ -165,10 +165,10 @@
165 165
   <component name="IdeDocumentHistory">
166 166
     <option name="CHANGED_PATHS">
167 167
       <list>
168
-        <option value="$PROJECT_DIR$/src/test/java/AccountServTest.java" />
169 168
         <option value="$PROJECT_DIR$/src/test/java/MockDao.java" />
170
-        <option value="$PROJECT_DIR$/src/main/java/AccountServ.java" />
171 169
         <option value="$PROJECT_DIR$/src/main/java/Console.java" />
170
+        <option value="$PROJECT_DIR$/src/main/java/AccountServ.java" />
171
+        <option value="$PROJECT_DIR$/src/test/java/AccountServTest.java" />
172 172
         <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
173 173
       </list>
174 174
     </option>
@@ -239,7 +239,7 @@
239 239
   <component name="PropertiesComponent">
240 240
     <property name="WebServerToolWindowFactoryState" value="false" />
241 241
     <property name="aspect.path.notification.shown" value="true" />
242
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542565159357" />
242
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542566112760" />
243 243
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
244 244
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
245 245
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -260,7 +260,7 @@
260 260
       </list>
261 261
     </option>
262 262
   </component>
263
-  <component name="RunManager">
263
+  <component name="RunManager" selected="JUnit.AccountServTest.createTest">
264 264
     <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
265 265
       <option name="MAIN_CLASS_NAME" value="AccountApp" />
266 266
       <module name="SimpleAccount" />
@@ -268,8 +268,23 @@
268 268
         <option name="Make" enabled="true" />
269 269
       </method>
270 270
     </configuration>
271
+    <configuration name="AccountServTest.createTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
272
+      <module name="SimpleAccount" />
273
+      <option name="PACKAGE_NAME" value="" />
274
+      <option name="MAIN_CLASS_NAME" value="AccountServTest" />
275
+      <option name="METHOD_NAME" value="createTest" />
276
+      <option name="TEST_OBJECT" value="method" />
277
+      <method v="2">
278
+        <option name="Make" enabled="true" />
279
+      </method>
280
+    </configuration>
281
+    <list>
282
+      <item itemvalue="Application.AccountApp" />
283
+      <item itemvalue="JUnit.AccountServTest.createTest" />
284
+    </list>
271 285
     <recent_temporary>
272 286
       <list>
287
+        <item itemvalue="JUnit.AccountServTest.createTest" />
273 288
         <item itemvalue="Application.AccountApp" />
274 289
       </list>
275 290
     </recent_temporary>
@@ -287,12 +302,12 @@
287 302
       <workItem from="1542239571129" duration="6414000" />
288 303
       <workItem from="1542402275147" duration="2006000" />
289 304
       <workItem from="1542420139392" duration="4000" />
290
-      <workItem from="1542475891339" duration="6221000" />
305
+      <workItem from="1542475891339" duration="7385000" />
291 306
     </task>
292 307
     <servers />
293 308
   </component>
294 309
   <component name="TimeTrackingManager">
295
-    <option name="totallyTimeSpent" value="14645000" />
310
+    <option name="totallyTimeSpent" value="15809000" />
296 311
   </component>
297 312
   <component name="ToolWindowManager">
298 313
     <frame x="0" y="23" width="1440" height="807" extended-state="0" />
@@ -367,6 +382,23 @@
367 382
         </state>
368 383
       </provider>
369 384
     </entry>
385
+    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
386
+      <provider selected="true" editor-type-id="text-editor">
387
+        <state relative-caret-position="435">
388
+          <caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
389
+          <folding>
390
+            <element signature="e#135#136#0" expanded="true" />
391
+            <element signature="e#169#170#0" expanded="true" />
392
+            <element signature="e#213#214#0" expanded="true" />
393
+            <element signature="e#241#242#0" expanded="true" />
394
+            <element signature="e#273#274#0" expanded="true" />
395
+            <element signature="e#286#287#0" expanded="true" />
396
+            <element signature="e#331#332#0" expanded="true" />
397
+            <element signature="e#353#354#0" expanded="true" />
398
+          </folding>
399
+        </state>
400
+      </provider>
401
+    </entry>
370 402
     <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
371 403
       <provider selected="true" editor-type-id="text-editor">
372 404
         <state relative-caret-position="55">
@@ -374,16 +406,21 @@
374 406
         </state>
375 407
       </provider>
376 408
     </entry>
377
-    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
409
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
378 410
       <provider selected="true" editor-type-id="text-editor">
379
-        <state relative-caret-position="480">
380
-          <caret line="35" selection-start-line="35" selection-end-line="35" />
411
+        <state relative-caret-position="255">
412
+          <caret line="17" column="28" lean-forward="true" selection-start-line="17" selection-start-column="28" selection-end-line="17" selection-end-column="28" />
413
+          <folding>
414
+            <element signature="imports" expanded="true" />
415
+            <element signature="e#175#176#0" expanded="true" />
416
+            <element signature="e#203#204#0" expanded="true" />
417
+          </folding>
381 418
         </state>
382 419
       </provider>
383 420
     </entry>
384 421
     <entry file="file://$PROJECT_DIR$/src/test/java/MockDao.java">
385 422
       <provider selected="true" editor-type-id="text-editor">
386
-        <state relative-caret-position="-1666">
423
+        <state relative-caret-position="516">
387 424
           <caret line="37" column="12" selection-start-line="37" selection-start-column="10" selection-end-line="37" selection-end-column="12" />
388 425
           <folding>
389 426
             <element signature="imports" expanded="true" />
@@ -397,42 +434,20 @@
397 434
         </state>
398 435
       </provider>
399 436
     </entry>
400
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountServ.java">
437
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
401 438
       <provider selected="true" editor-type-id="text-editor">
402
-        <state relative-caret-position="450">
403
-          <caret line="30" lean-forward="true" selection-start-line="30" selection-end-line="30" />
439
+        <state relative-caret-position="248">
440
+          <caret line="47" column="49" selection-start-line="47" selection-start-column="49" selection-end-line="47" selection-end-column="49" />
404 441
           <folding>
405 442
             <element signature="imports" expanded="true" />
406
-            <element signature="e#175#176#0" expanded="true" />
407
-            <element signature="e#203#204#0" expanded="true" />
408
-          </folding>
409
-        </state>
410
-      </provider>
411
-    </entry>
412
-    <entry file="file://$PROJECT_DIR$/src/main/java/Console.java">
413
-      <provider selected="true" editor-type-id="text-editor">
414
-        <state relative-caret-position="435">
415
-          <caret line="29" column="30" selection-start-line="29" selection-start-column="30" selection-end-line="29" selection-end-column="30" />
416
-          <folding>
417
-            <element signature="e#135#136#0" expanded="true" />
418
-            <element signature="e#169#170#0" expanded="true" />
419
-            <element signature="e#213#214#0" expanded="true" />
420
-            <element signature="e#241#242#0" expanded="true" />
421
-            <element signature="e#273#274#0" expanded="true" />
422
-            <element signature="e#286#287#0" expanded="true" />
423
-            <element signature="e#331#332#0" expanded="true" />
424
-            <element signature="e#353#354#0" expanded="true" />
425 443
           </folding>
426 444
         </state>
427 445
       </provider>
428 446
     </entry>
429
-    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
447
+    <entry file="file://$PROJECT_DIR$/src/test/java/AccountServTest.java">
430 448
       <provider selected="true" editor-type-id="text-editor">
431
-        <state relative-caret-position="188">
432
-          <caret line="45" column="24" lean-forward="true" selection-start-line="45" selection-start-column="24" selection-end-line="45" selection-end-column="24" />
433
-          <folding>
434
-            <element signature="imports" expanded="true" />
435
-          </folding>
449
+        <state relative-caret-position="285">
450
+          <caret line="25" column="5" lean-forward="true" selection-start-line="25" selection-start-column="5" selection-end-line="25" selection-end-column="5" />
436 451
         </state>
437 452
       </provider>
438 453
     </entry>

+ 2
- 1
src/main/java/AccountApp.java Просмотреть файл

@@ -39,12 +39,13 @@ import com.j256.ormlite.support.ConnectionSource;
39 39
          * Read and write some example data.
40 40
          */
41 41
         private void processData() throws Exception {
42
+           AccountServ services = new AccountServ();
42 43
            boolean end = false;
43 44
             console.print("Welcome to your account manager");
44 45
                 while(!end){
45 46
                    int input = console.prntTakeInt("Please enter your selection: ");
46 47
                     if (input == 1) {
47
-
48
+                        services.createAccount();
48 49
                     } else if(input == 2) {
49 50
 
50 51
                     } else if(input == 3) {

+ 8
- 0
src/main/java/AccountServ.java Просмотреть файл

@@ -5,11 +5,19 @@ import java.sql.SQLException;
5 5
 public class AccountServ {
6 6
 
7 7
     private Dao<Account, Integer> dao;
8
+    private Console console = new Console();
8 9
 
9 10
     public AccountServ() {
10 11
         this.dao = dao;
11 12
     }
12 13
 
14
+    public void createAccount() throws SQLException {
15
+        String name = console.prntTakeStr("Please enter new account name");
16
+        String pswrd = console.prntTakeStr("Please enter new account password");
17
+        Account account = new Account(name, pswrd);
18
+        dao.create(account);
19
+    }
20
+
13 21
     public int create(Account account) throws SQLException {
14 22
         return dao.create(account);
15 23
     }

+ 7
- 1
src/test/java/AccountServTest.java Просмотреть файл

@@ -1,8 +1,11 @@
1 1
 import com.j256.ormlite.dao.Dao;
2 2
 import com.j256.ormlite.stmt.query.In;
3
+import org.junit.Assert;
3 4
 import org.junit.Before;
4 5
 import org.junit.Test;
5 6
 
7
+import java.sql.SQLException;
8
+
6 9
 public class AccountServTest {
7 10
 
8 11
     Dao<Account, Integer> dao;
@@ -15,8 +18,11 @@ public class AccountServTest {
15 18
     }
16 19
 
17 20
     @Test
18
-    public void createTest(){
21
+    public void createTest() throws SQLException {
22
+        int expected = 100;
23
+        int actual = dao.create(account);
19 24
 
25
+        Assert.assertEquals(expected, actual);
20 26
     }
21 27
 
22 28
     @Test

Двоичные данные
target/classes/Account.class Просмотреть файл


Двоичные данные
target/classes/AccountApp.class Просмотреть файл


Двоичные данные
target/classes/AccountServ.class Просмотреть файл


Двоичные данные
target/classes/Console.class Просмотреть файл


Двоичные данные
target/test-classes/AccountServTest.class Просмотреть файл


Двоичные данные
target/test-classes/MockDao.class Просмотреть файл