Tan115 commited on
Commit
07c2d26
·
verified ·
1 Parent(s): 1b558aa

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +7 -0
  2. 10 - Methods in Java/001 Methods in Java Overview.mp4 +3 -0
  3. 10 - Methods in Java/002 Parameter Passing Mechanism in Java.mp4 +3 -0
  4. 10 - Methods in Java/003 Recursive methods.mp4 +3 -0
  5. 10 - Methods in Java/004 Variable Length Arguments.mp4 +3 -0
  6. 10 - Methods in Java/016 Homework review Methods.mp4 +3 -0
  7. 100 - GPT + Slack + Jira + Gmail Integration/002 Generate Tickets in Jira & Send Email from Slack via Chat Interface.mp4 +3 -0
  8. 101 - Manage a Scrum Team with ChatGPT/001 Managing Scrum & Risk Management with Custom Bot, Slack & GPT.mp4 +3 -0
  9. 30 - Java Reflection API/001 Source-code-of-example-from-the-lesson.url +2 -0
  10. 30 - Java Reflection API/002 Annotations_en.srt +1072 -0
  11. 30 - Java Reflection API/002 Homework-Solution.url +2 -0
  12. 30 - Java Reflection API/002 Homework.url +2 -0
  13. 30 - Java Reflection API/002 Source-code-of-examples-from-the-lesson.url +2 -0
  14. 30 - Java Reflection API/external-links.txt +12 -0
  15. 31 - JDK API/001 Source-code-from-the-lesson.url +2 -0
  16. 31 - JDK API/001 StringBuilder & StringBuffer_en.srt +760 -0
  17. 31 - JDK API/002 Source-code-examples-from-the-lesson.url +2 -0
  18. 31 - JDK API/002 java.util.Optional - Optional in Java_en.srt +1476 -0
  19. 31 - JDK API/003 Reactive Programming in Java Flow API, Reactive Streams_en.srt +996 -0
  20. 31 - JDK API/003 Source-code-examples-from-the-lesson.url +2 -0
  21. 31 - JDK API/004 Quiz JDK API - Check yourself.html +69 -0
  22. 31 - JDK API/external-links.txt +9 -0
  23. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/001 Modules in Java Modular Application Example_en.srt +1576 -0
  24. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/001 Source-code-examples-from-the-lesson-Modular-Project.url +2 -0
  25. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 -Example-Migration-Guide-by-Oracle.url +2 -0
  26. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 Migration of Java Apps Example of migration to a modular application_en.srt +1524 -0
  27. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 Modular-application-example-with-bash-scripts.url +2 -0
  28. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 Non-modular-application-example-with-bash-scripts.url +2 -0
  29. 32 - Java Platform Module System Modules in Java & Migration of Java Apps/external-links.txt +12 -0
  30. 33 - Testing for Software Engineers/001 Testing for software engineers Overview_en.srt +1308 -0
  31. 34 - Unit Testing & JUnit 5/001 Unit Testing & JUnit Overview_en.srt +1372 -0
  32. 34 - Unit Testing & JUnit 5/002 JUnit 5 examples VS JUnit 4 + Equivalence class partitioning_en.srt +1144 -0
  33. 34 - Unit Testing & JUnit 5/002 JUnit-Documentation.url +2 -0
  34. 34 - Unit Testing & JUnit 5/002 Source-code-of-MoneyTransactionService.url +2 -0
  35. 34 - Unit Testing & JUnit 5/002 Source-code-of-MoneyTransactionServiceTest.url +2 -0
  36. 34 - Unit Testing & JUnit 5/003 JUnit 5 API (Advanced) & Test Code Coverage_en.srt +1128 -0
  37. 34 - Unit Testing & JUnit 5/003 Source-code-of-test-1.url +2 -0
  38. 34 - Unit Testing & JUnit 5/003 Source-code-of-test-2.url +2 -0
  39. 34 - Unit Testing & JUnit 5/004 JUnit 5 API (Advanced p. 2) & Hamcrest Library_en.srt +1124 -0
  40. 34 - Unit Testing & JUnit 5/004 Source-code-of-Advanced-JUnit-Examples.url +2 -0
  41. 34 - Unit Testing & JUnit 5/004 Source-code-of-Hamcrest-Library-Examples.url +2 -0
  42. 34 - Unit Testing & JUnit 5/004 Source-code-of-Test-Suites.url +2 -0
  43. 34 - Unit Testing & JUnit 5/external-links.txt +24 -0
  44. 35 - Integration testing & Mockito/001 Integration Testing in Java_en.srt +700 -0
  45. 35 - Integration testing & Mockito/002 Byte-Buddy-agent-library.url +2 -0
  46. 35 - Integration testing & Mockito/002 Byte-Buddy-library.url +2 -0
  47. 35 - Integration testing & Mockito/002 Mockito Part 1_en.srt +1196 -0
  48. 35 - Integration testing & Mockito/002 Mockito-JUnit-Jupiter.url +2 -0
  49. 35 - Integration testing & Mockito/002 Mockito-core-library.url +2 -0
  50. 35 - Integration testing & Mockito/002 Objenesis-library.url +2 -0
.gitattributes CHANGED
@@ -73,3 +73,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
73
  09[[:space:]]-[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops)[[:space:]]in[[:space:]]Java/006[[:space:]]Jump[[:space:]]Statements[[:space:]]-[[:space:]]Break[[:space:]]and[[:space:]]Continue.mp4 filter=lfs diff=lfs merge=lfs -text
74
  09[[:space:]]-[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops)[[:space:]]in[[:space:]]Java/007[[:space:]]Labels[[:space:]]in[[:space:]]Java.mp4 filter=lfs diff=lfs merge=lfs -text
75
  09[[:space:]]-[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops)[[:space:]]in[[:space:]]Java/011[[:space:]]Homework[[:space:]]review[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops).mp4 filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
73
  09[[:space:]]-[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops)[[:space:]]in[[:space:]]Java/006[[:space:]]Jump[[:space:]]Statements[[:space:]]-[[:space:]]Break[[:space:]]and[[:space:]]Continue.mp4 filter=lfs diff=lfs merge=lfs -text
74
  09[[:space:]]-[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops)[[:space:]]in[[:space:]]Java/007[[:space:]]Labels[[:space:]]in[[:space:]]Java.mp4 filter=lfs diff=lfs merge=lfs -text
75
  09[[:space:]]-[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops)[[:space:]]in[[:space:]]Java/011[[:space:]]Homework[[:space:]]review[[:space:]]Iteration[[:space:]]Statements[[:space:]](Loops).mp4 filter=lfs diff=lfs merge=lfs -text
76
+ 10[[:space:]]-[[:space:]]Methods[[:space:]]in[[:space:]]Java/001[[:space:]]Methods[[:space:]]in[[:space:]]Java[[:space:]]Overview.mp4 filter=lfs diff=lfs merge=lfs -text
77
+ 10[[:space:]]-[[:space:]]Methods[[:space:]]in[[:space:]]Java/003[[:space:]]Recursive[[:space:]]methods.mp4 filter=lfs diff=lfs merge=lfs -text
78
+ 10[[:space:]]-[[:space:]]Methods[[:space:]]in[[:space:]]Java/004[[:space:]]Variable[[:space:]]Length[[:space:]]Arguments.mp4 filter=lfs diff=lfs merge=lfs -text
79
+ 10[[:space:]]-[[:space:]]Methods[[:space:]]in[[:space:]]Java/002[[:space:]]Parameter[[:space:]]Passing[[:space:]]Mechanism[[:space:]]in[[:space:]]Java.mp4 filter=lfs diff=lfs merge=lfs -text
80
+ 10[[:space:]]-[[:space:]]Methods[[:space:]]in[[:space:]]Java/016[[:space:]]Homework[[:space:]]review[[:space:]]Methods.mp4 filter=lfs diff=lfs merge=lfs -text
81
+ 101[[:space:]]-[[:space:]]Manage[[:space:]]a[[:space:]]Scrum[[:space:]]Team[[:space:]]with[[:space:]]ChatGPT/001[[:space:]]Managing[[:space:]]Scrum[[:space:]]&[[:space:]]Risk[[:space:]]Management[[:space:]]with[[:space:]]Custom[[:space:]]Bot,[[:space:]]Slack[[:space:]]&[[:space:]]GPT.mp4 filter=lfs diff=lfs merge=lfs -text
82
+ 100[[:space:]]-[[:space:]]GPT[[:space:]]+[[:space:]]Slack[[:space:]]+[[:space:]]Jira[[:space:]]+[[:space:]]Gmail[[:space:]]Integration/002[[:space:]]Generate[[:space:]]Tickets[[:space:]]in[[:space:]]Jira[[:space:]]&[[:space:]]Send[[:space:]]Email[[:space:]]from[[:space:]]Slack[[:space:]]via[[:space:]]Chat[[:space:]]Interface.mp4 filter=lfs diff=lfs merge=lfs -text
10 - Methods in Java/001 Methods in Java Overview.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:627a31a23e2811b65840db0629a054ddc13f14f3a877e264d29c67769ffc0d31
3
+ size 38302045
10 - Methods in Java/002 Parameter Passing Mechanism in Java.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a317e8b4d649b65e1182aac23e829430c7491bb6d9049972ca8053090548fa1b
3
+ size 61515873
10 - Methods in Java/003 Recursive methods.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b79a2d8b1a9611e02b4a2af70a144b03c73ac10daf48b171c447bc13d039a6be
3
+ size 22474004
10 - Methods in Java/004 Variable Length Arguments.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:500960247a70e5e1815e9620c00473673fec3ec3e8eb554fce153dc47e34e89f
3
+ size 38829454
10 - Methods in Java/016 Homework review Methods.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ec3836738219c901096ee674e66f44e2e9f960253bb06daff4d22f79662f2e9
3
+ size 8842296
100 - GPT + Slack + Jira + Gmail Integration/002 Generate Tickets in Jira & Send Email from Slack via Chat Interface.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21ad7a31a0e9fd6236fffe7d2bf533cb8682f6ae66f22b9680c36882ecf26e21
3
+ size 378985718
101 - Manage a Scrum Team with ChatGPT/001 Managing Scrum & Risk Management with Custom Bot, Slack & GPT.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbc23537524bf7d13d3b47c5531f3c16825d31cc175e7d2950490ee42919cfcb
3
+ size 114695073
30 - Java Reflection API/001 Source-code-of-example-from-the-lesson.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/src/com/itbulls/learnit/javacore/reflection/Demo.java
30 - Java Reflection API/002 Annotations_en.srt ADDED
@@ -0,0 +1,1072 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:06,000
3
+ Hello, Jim.
4
+
5
+ 2
6
+ 00:00:06,000 --> 00:00:12,000
7
+ Today we're going to learn with you what annotations are, how to work with them and how to create new
8
+
9
+ 3
10
+ 00:00:12,000 --> 00:00:12,000
11
+ ones.
12
+
13
+ 4
14
+ 00:00:12,000 --> 00:00:18,000
15
+ Before we start this lesson, I must say that it is critically important you watching previous lesson
16
+
17
+ 5
18
+ 00:00:18,000 --> 00:00:20,000
19
+ about Reflection API.
20
+
21
+ 6
22
+ 00:00:20,000 --> 00:00:26,000
23
+ If you skip that one, please make sure you watch it, because in this lesson, we are going to use
24
+
25
+ 7
26
+ 00:00:26,000 --> 00:00:29,000
27
+ Réflexion API to work with annotations.
28
+
29
+ 8
30
+ 00:00:29,000 --> 00:00:35,000
31
+ Basically, there is not so much as a ways for us to take advantage from annotations without knowing
32
+
33
+ 9
34
+ 00:00:35,000 --> 00:00:36,000
35
+ the Reflection API.
36
+
37
+ 10
38
+ 00:00:37,000 --> 00:00:39,000
39
+ In this lesson, we're going to learn everything.
40
+
41
+ 11
42
+ 00:00:39,000 --> 00:00:45,000
43
+ The related to annotations will start from the definition of annotation, make you understand what annotations
44
+
45
+ 12
46
+ 00:00:45,000 --> 00:00:47,000
47
+ are on the standard banner.
48
+
49
+ 13
50
+ 00:00:47,000 --> 00:00:53,000
51
+ We are going to discuss use cases when annotations may be applied and for what purposes.
52
+
53
+ 14
54
+ 00:00:53,000 --> 00:00:57,000
55
+ After that, we will start reviewing of the source code examples.
56
+
57
+ 15
58
+ 00:00:57,000 --> 00:01:02,000
59
+ I will explain you what targets annotation is and what retention annotation is.
60
+
61
+ 16
62
+ 00:01:02,000 --> 00:01:09,000
63
+ We are going to create our own custom annotation and you are going to understand how to create it and
64
+
65
+ 17
66
+ 00:01:09,000 --> 00:01:09,000
67
+ process it.
68
+
69
+ 18
70
+ 00:01:10,000 --> 00:01:15,000
71
+ And at the end of the lesson, I will also explain you how to create repeatable annotations.
72
+
73
+ 19
74
+ 00:01:15,000 --> 00:01:16,000
75
+ Let's stop.
76
+
77
+ 20
78
+ 00:01:17,000 --> 00:01:20,000
79
+ And the first question that we have to answer sounds like this.
80
+
81
+ 21
82
+ 00:01:21,000 --> 00:01:22,000
83
+ What is annotation?
84
+
85
+ 22
86
+ 00:01:22,000 --> 00:01:27,000
87
+ Annotation as a form of metadata provides data about programs.
88
+
89
+ 23
90
+ 00:01:27,000 --> 00:01:30,000
91
+ It is not part of the program itself.
92
+
93
+ 24
94
+ 00:01:30,000 --> 00:01:35,000
95
+ Annotations have no direct effect on the operation of the court.
96
+
97
+ 25
98
+ 00:01:35,000 --> 00:01:38,000
99
+ They annotate the understands this definition.
100
+
101
+ 26
102
+ 00:01:39,000 --> 00:01:40,000
103
+ The know what is metadata.
104
+
105
+ 27
106
+ 00:01:41,000 --> 00:01:50,000
107
+ Metadata is a data that provides information about other data or similar data about data in program,
108
+
109
+ 28
110
+ 00:01:50,000 --> 00:01:57,000
111
+ and we can annotate types, colossus and interfaces, fields, masses, parameters, constructors,
112
+
113
+ 29
114
+ 00:01:57,000 --> 00:02:01,000
115
+ local variables, packages, modules and others.
116
+
117
+ 30
118
+ 00:02:01,000 --> 00:02:04,000
119
+ We can even annotate annotation itself.
120
+
121
+ 31
122
+ 00:02:05,000 --> 00:02:11,000
123
+ Basically, there might be cases when you need to provide more information about your code and use this
124
+
125
+ 32
126
+ 00:02:11,000 --> 00:02:18,000
127
+ information on different stages on the level of the source code during compilation and at this stage
128
+
129
+ 33
130
+ 00:02:18,000 --> 00:02:18,000
131
+ of the runtime.
132
+
133
+ 34
134
+ 00:02:19,000 --> 00:02:25,000
135
+ Late in the lesson we are going to learn this case are some examples I will show you where notation
136
+
137
+ 35
138
+ 00:02:25,000 --> 00:02:29,000
139
+ can be applied and how long it will be retained.
140
+
141
+ 36
142
+ 00:02:29,000 --> 00:02:36,000
143
+ You already understood what metadata is and what annotation is, but probably it is still not clear
144
+
145
+ 37
146
+ 00:02:36,000 --> 00:02:42,000
147
+ for you how this can be helpful and when we need to use annotations in which cases.
148
+
149
+ 38
150
+ 00:02:42,000 --> 00:02:45,000
151
+ The first one is information for the compiler.
152
+
153
+ 39
154
+ 00:02:46,000 --> 00:02:53,000
155
+ Annotations can be used by the compiler to detect errors or suppress warnings, for example, such popular
156
+
157
+ 40
158
+ 00:02:53,000 --> 00:02:54,000
159
+ annotation as override.
160
+
161
+ 41
162
+ 00:02:55,000 --> 00:03:02,000
163
+ I am sure you used it already is on purpose or it just added it instead of you overwrite annotation
164
+
165
+ 42
166
+ 00:03:02,000 --> 00:03:05,000
167
+ discarded by the compiler during the compilation.
168
+
169
+ 43
170
+ 00:03:05,000 --> 00:03:09,000
171
+ And there is a specific purpose of this net information.
172
+
173
+ 44
174
+ 00:03:09,000 --> 00:03:14,000
175
+ As you remember, annotation tells us that this method should override method from parent type.
176
+
177
+ 45
178
+ 00:03:15,000 --> 00:03:22,000
179
+ Thus, there are specific requirements to access modify which that matter signature and the list of
180
+
181
+ 46
182
+ 00:03:22,000 --> 00:03:23,000
183
+ potential exceptions.
184
+
185
+ 47
186
+ 00:03:23,000 --> 00:03:32,000
187
+ There is a logical place in juju that analyzes this matter information basically for all methods marked
188
+
189
+ 48
190
+ 00:03:32,000 --> 00:03:34,000
191
+ with overrides, this logic is applied.
192
+
193
+ 49
194
+ 00:03:35,000 --> 00:03:37,000
195
+ Compile time and deployment time.
196
+
197
+ 50
198
+ 00:03:37,000 --> 00:03:45,000
199
+ Processing software tools can process annotation information to generate code, XML files and so forth.
200
+
201
+ 51
202
+ 00:03:45,000 --> 00:03:51,000
203
+ For example, such book in the library and do as number in case you have never worked with.
204
+
205
+ 52
206
+ 00:03:51,000 --> 00:03:51,000
207
+ No.
208
+
209
+ 53
210
+ 00:03:52,000 --> 00:03:53,000
211
+ I will tell you about it.
212
+
213
+ 54
214
+ 00:03:53,000 --> 00:03:59,000
215
+ It generates getters and setters for you and also helps you with generating other things.
216
+
217
+ 55
218
+ 00:04:00,000 --> 00:04:05,000
219
+ This mechanism also built on top of annotations and reflection API.
220
+
221
+ 56
222
+ 00:04:05,000 --> 00:04:12,000
223
+ Basically, you can annotate type was information about methods if you need to be generated, for example.
224
+
225
+ 57
226
+ 00:04:12,000 --> 00:04:19,000
227
+ And when you compile your application and upload classes into Java, those masses that you want it to
228
+
229
+ 58
230
+ 00:04:19,000 --> 00:04:21,000
231
+ be generated are there on place.
232
+
233
+ 59
234
+ 00:04:22,000 --> 00:04:23,000
235
+ Is that clear?
236
+
237
+ 60
238
+ 00:04:24,000 --> 00:04:27,000
239
+ And that's a use case of using annotations is runtime processing.
240
+
241
+ 61
242
+ 00:04:28,000 --> 00:04:31,000
243
+ Some annotations are available to be excellent at runtime.
244
+
245
+ 62
246
+ 00:04:32,000 --> 00:04:35,000
247
+ You can set configuration to retain annotations.
248
+
249
+ 63
250
+ 00:04:35,000 --> 00:04:39,000
251
+ Zero zero runtime I will show you is this an example?
252
+
253
+ 64
254
+ 00:04:39,000 --> 00:04:41,000
255
+ But let's understand why do we need this?
256
+
257
+ 65
258
+ 00:04:42,000 --> 00:04:48,000
259
+ You may need to keep annotations during the runtime to build some logic around this meta information.
260
+
261
+ 66
262
+ 00:04:48,000 --> 00:04:50,000
263
+ You're in the program execution.
264
+
265
+ 67
266
+ 00:04:50,000 --> 00:04:53,000
267
+ Your homework will be related to this case.
268
+
269
+ 68
270
+ 00:04:53,000 --> 00:04:58,000
271
+ I believe that we have learned enough basics to start review and examples.
272
+
273
+ 69
274
+ 00:04:58,000 --> 00:05:02,000
275
+ Anyway, I will explain examples as we go and the true.
276
+
277
+ 70
278
+ 00:05:02,000 --> 00:05:08,000
279
+ Who believes that understanding of this topic will be easier with source code and the real good examples,
280
+
281
+ 71
282
+ 00:05:08,000 --> 00:05:14,000
283
+ rather than with slides for the sake of the demo and this lesson, I created a separate package and
284
+
285
+ 72
286
+ 00:05:14,000 --> 00:05:15,000
287
+ separate them a file.
288
+
289
+ 73
290
+ 00:05:16,000 --> 00:05:19,000
291
+ You can find them a file in annotations package.
292
+
293
+ 74
294
+ 00:05:20,000 --> 00:05:21,000
295
+ Let's start from basics.
296
+
297
+ 75
298
+ 00:05:22,000 --> 00:05:24,000
299
+ Let's discuss annotation format.
300
+
301
+ 76
302
+ 00:05:24,000 --> 00:05:29,000
303
+ Each annotation is started with at sign, followed by some meaningful name.
304
+
305
+ 77
306
+ 00:05:30,000 --> 00:05:36,000
307
+ Z Sign character indicates as a compiler that what follows is an annotation.
308
+
309
+ 78
310
+ 00:05:36,000 --> 00:05:41,000
311
+ The annotation can include elements which can be named and zem values.
312
+
313
+ 79
314
+ 00:05:41,000 --> 00:05:48,000
315
+ For those elements, elements may contain additional information like in this case, you can see that
316
+
317
+ 80
318
+ 00:05:48,000 --> 00:05:50,000
319
+ are used to suppress warnings.
320
+
321
+ 81
322
+ 00:05:50,000 --> 00:05:54,000
323
+ Annotation and element value has value types.
324
+
325
+ 82
326
+ 00:05:54,000 --> 00:06:01,000
327
+ This is basically for compiler to remove warnings for parameterized, at least in case I would Corman's
328
+
329
+ 83
330
+ 00:06:01,000 --> 00:06:02,000
331
+ this annotation.
332
+
333
+ 84
334
+ 00:06:02,000 --> 00:06:08,000
335
+ There will be warnings you as a compilation that I am using parameter types without parameter Ryzens.
336
+
337
+ 85
338
+ 00:06:09,000 --> 00:06:17,000
339
+ You see this OK and other possible syntax of the similar annotation in case there is only one element
340
+
341
+ 86
342
+ 00:06:17,000 --> 00:06:19,000
343
+ is declared inside the annotation.
344
+
345
+ 87
346
+ 00:06:20,000 --> 00:06:25,000
347
+ You can omit element key and just put value like in this example.
348
+
349
+ 88
350
+ 00:06:25,000 --> 00:06:32,000
351
+ It is also possible to use multiple annotations at once and from Java version eight zero even supports
352
+
353
+ 89
354
+ 00:06:32,000 --> 00:06:34,000
355
+ of repeatable annotations.
356
+
357
+ 90
358
+ 00:06:34,000 --> 00:06:40,000
359
+ As you can see in this example, a little bit later in our lesson, one will comp the creation of our
360
+
361
+ 91
362
+ 00:06:40,000 --> 00:06:41,000
363
+ custom annotations.
364
+
365
+ 92
366
+ 00:06:41,000 --> 00:06:44,000
367
+ I will explain you how to create repeatable annotations.
368
+
369
+ 93
370
+ 00:06:45,000 --> 00:06:47,000
371
+ Let's open the source code of any annotation.
372
+
373
+ 94
374
+ 00:06:48,000 --> 00:06:51,000
375
+ For example, let's look at suppress warnings annotation.
376
+
377
+ 95
378
+ 00:06:52,000 --> 00:06:55,000
379
+ As you can see, there is no end in logic and code here.
380
+
381
+ 96
382
+ 00:06:56,000 --> 00:07:00,000
383
+ There is no any algorithm or data processing or anything else.
384
+
385
+ 97
386
+ 00:07:01,000 --> 00:07:10,000
387
+ Some students ask me then how annotations work, how overwrite annotation works, and all this basically
388
+
389
+ 98
390
+ 00:07:10,000 --> 00:07:15,000
391
+ annotations are nothing more than just an information and what you can do.
392
+
393
+ 99
394
+ 00:07:15,000 --> 00:07:16,000
395
+ Learn this information.
396
+
397
+ 100
398
+ 00:07:17,000 --> 00:07:21,000
399
+ This is up to you, and this logic is programmed in a separate place.
400
+
401
+ 101
402
+ 00:07:21,000 --> 00:07:24,000
403
+ OK, that was annotations basics.
404
+
405
+ 102
406
+ 00:07:24,000 --> 00:07:29,000
407
+ Now, you know, at least on the high level, what annotations are us?
408
+
409
+ 103
410
+ 00:07:29,000 --> 00:07:33,000
411
+ Know known annotations deeper and to learn them better?
412
+
413
+ 104
414
+ 00:07:34,000 --> 00:07:36,000
415
+ Let's create our own annotation.
416
+
417
+ 105
418
+ 00:07:36,000 --> 00:07:44,000
419
+ If you are already familiar with G-Unit will implement our own kind of test annotation if you are not
420
+
421
+ 106
422
+ 00:07:44,000 --> 00:07:45,000
423
+ familiar with your units yet.
424
+
425
+ 107
426
+ 00:07:45,000 --> 00:07:46,000
427
+ Just a few words.
428
+
429
+ 108
430
+ 00:07:47,000 --> 00:07:49,000
431
+ G-Unit is a framework for unit testing.
432
+
433
+ 109
434
+ 00:07:50,000 --> 00:07:56,000
435
+ It provides a lot of different features and the Mournes impossibility to run specific methods separately
436
+
437
+ 110
438
+ 00:07:57,000 --> 00:07:59,000
439
+ to execute separate test cases.
440
+
441
+ 111
442
+ 00:07:59,000 --> 00:08:06,000
443
+ The purpose of that massive is to reproduce the state of the system as a specific moment of time, and
444
+
445
+ 112
446
+ 00:08:06,000 --> 00:08:08,000
447
+ the Cert is expected to be here.
448
+
449
+ 113
450
+ 00:08:09,000 --> 00:08:15,000
451
+ All examples will be stored under this package, so you will easily found them in attachments to this
452
+
453
+ 114
454
+ 00:08:15,000 --> 00:08:17,000
455
+ lesson in case you want to run examples on your computer.
456
+
457
+ 115
458
+ 00:08:18,000 --> 00:08:19,000
459
+ Let's start.
460
+
461
+ 116
462
+ 00:08:19,000 --> 00:08:21,000
463
+ I create test annotations.
464
+
465
+ 117
466
+ 00:08:21,000 --> 00:08:28,000
467
+ First, I declare annotation in a separate file, and you can see in this example that the use interface
468
+
469
+ 118
470
+ 00:08:28,000 --> 00:08:30,000
471
+ here was at sign.
472
+
473
+ 119
474
+ 00:08:31,000 --> 00:08:38,000
475
+ The second important step is to add matter annotations to specify the scope and the target of our custom
476
+
477
+ 120
478
+ 00:08:38,000 --> 00:08:38,000
479
+ annotation.
480
+
481
+ 121
482
+ 00:08:39,000 --> 00:08:43,000
483
+ I'm talking about annotations, zero retention and target.
484
+
485
+ 122
486
+ 00:08:44,000 --> 00:08:44,000
487
+ Let's run.
488
+
489
+ 123
490
+ 00:08:44,000 --> 00:08:45,000
491
+ What are they?
492
+
493
+ 124
494
+ 00:08:46,000 --> 00:08:48,000
495
+ So what do we need to target annotation for?
496
+
497
+ 125
498
+ 00:08:49,000 --> 00:08:54,000
499
+ This annotation indicates a context in which an annotation type is applicable.
500
+
501
+ 126
502
+ 00:08:55,000 --> 00:09:02,000
503
+ In simple words, where you can use the sanitation target, annotation can take array of any values
504
+
505
+ 127
506
+ 00:09:02,000 --> 00:09:04,000
507
+ of element type enum.
508
+
509
+ 128
510
+ 00:09:05,000 --> 00:09:08,000
511
+ So even in case you forgot where you can use annotations.
512
+
513
+ 129
514
+ 00:09:09,000 --> 00:09:16,000
515
+ Just open element type in them and you would find enum for each possible placement of your annotation.
516
+
517
+ 130
518
+ 00:09:16,000 --> 00:09:24,000
519
+ Even despite the fact is, a on annotation may take array of elements in our specific example, we would
520
+
521
+ 131
522
+ 00:09:24,000 --> 00:09:33,000
523
+ use only one in a message because in our specific business context, we don't want to allow our client
524
+
525
+ 132
526
+ 00:09:33,000 --> 00:09:37,000
527
+ use it in other places is an exhortation is retention.
528
+
529
+ 133
530
+ 00:09:38,000 --> 00:09:43,000
531
+ This information indicates how long annotations was annotated.
532
+
533
+ 134
534
+ 00:09:43,000 --> 00:09:45,000
535
+ Time are to be retained.
536
+
537
+ 135
538
+ 00:09:45,000 --> 00:09:49,000
539
+ That is exactly what we have discussed at the beginning of our lesson.
540
+
541
+ 136
542
+ 00:09:49,000 --> 00:09:56,000
543
+ When I explained that annotation may be used during Zabeel time by the compiler and discarded from the
544
+
545
+ 137
546
+ 00:09:56,000 --> 00:10:02,000
547
+ class on the glass level but discarded during the anthem, one class is uploaded in.
548
+
549
+ 138
550
+ 00:10:03,000 --> 00:10:11,000
551
+ And during runtime, this annotation can take any value of retention policy in them, even in case you
552
+
553
+ 139
554
+ 00:10:11,000 --> 00:10:17,000
555
+ forgot what's retention levels for annotations are, you always can open the source code of this in
556
+
557
+ 140
558
+ 00:10:17,000 --> 00:10:19,000
559
+ them and explore this.
560
+
561
+ 141
562
+ 00:10:19,000 --> 00:10:22,000
563
+ As I said, there's three possible options here.
564
+
565
+ 142
566
+ 00:10:22,000 --> 00:10:31,000
567
+ They are source Closs, and one time in our case, we use runtime retention policy because we need this
568
+
569
+ 143
570
+ 00:10:31,000 --> 00:10:33,000
571
+ annotation to be retained.
572
+
573
+ 144
574
+ 00:10:33,000 --> 00:10:34,000
575
+ That's a runtime.
576
+
577
+ 145
578
+ 00:10:34,000 --> 00:10:41,000
579
+ Now, at this time, to add custom elements, imagine that you want to specify expected exception in
580
+
581
+ 146
582
+ 00:10:41,000 --> 00:10:47,000
583
+ order we can test negative scenarios, for example, in case we expect exception to be thrown.
584
+
585
+ 147
586
+ 00:10:47,000 --> 00:10:49,000
587
+ But there was no any exception.
588
+
589
+ 148
590
+ 00:10:49,000 --> 00:10:58,000
591
+ Drone zones This particular test should be considered as field and the stanzas declare an element in
592
+
593
+ 149
594
+ 00:10:58,000 --> 00:10:58,000
595
+ annotation.
596
+
597
+ 150
598
+ 00:10:58,000 --> 00:11:02,000
599
+ We have to declare mass was the name of the element itself.
600
+
601
+ 151
602
+ 00:11:03,000 --> 00:11:06,000
603
+ Return type will be the type of the element.
604
+
605
+ 152
606
+ 00:11:06,000 --> 00:11:12,000
607
+ For example, in this specific case, we would like to specify loss of the expected exception.
608
+
609
+ 153
610
+ 00:11:12,000 --> 00:11:18,000
611
+ Thus, returns type for this message will be close when we declare this matter.
612
+
613
+ 154
614
+ 00:11:18,000 --> 00:11:24,000
615
+ We should remember important things, since this massive can throw an exception.
616
+
617
+ 155
618
+ 00:11:24,000 --> 00:11:27,000
619
+ There is a restriction on the return types.
620
+
621
+ 156
622
+ 00:11:28,000 --> 00:11:35,000
623
+ Basically, you can return on your primitives string class in them, annotations and arrays of these
624
+
625
+ 157
626
+ 00:11:35,000 --> 00:11:36,000
627
+ types.
628
+
629
+ 158
630
+ 00:11:36,000 --> 00:11:39,000
631
+ Also, this must has default value.
632
+
633
+ 159
634
+ 00:11:40,000 --> 00:11:46,000
635
+ For example, in this particular case, default exception, to be certain is of non plus.
636
+
637
+ 160
638
+ 00:11:46,000 --> 00:11:51,000
639
+ This is our custom clause that extends Roble and that basically is empty.
640
+
641
+ 161
642
+ 00:11:52,000 --> 00:11:56,000
643
+ This is needed because I can't have default no values.
644
+
645
+ 162
646
+ 00:11:56,000 --> 00:12:03,000
647
+ But in case I wouldn't specify, a default value client will be forced to parse the value for this element.
648
+
649
+ 163
650
+ 00:12:03,000 --> 00:12:07,000
651
+ But what clients should Boston in case there is no expected exception?
652
+
653
+ 164
654
+ 00:12:07,000 --> 00:12:10,000
655
+ That's why I have default non clause here.
656
+
657
+ 165
658
+ 00:12:11,000 --> 00:12:14,000
659
+ Similar example of default value in our other element.
660
+
661
+ 166
662
+ 00:12:15,000 --> 00:12:19,000
663
+ Each test can be named and default name is empty string.
664
+
665
+ 167
666
+ 00:12:19,000 --> 00:12:23,000
667
+ But the client of this code can pass any custom name.
668
+
669
+ 168
670
+ 00:12:23,000 --> 00:12:26,000
671
+ One of the restriction was regards the default value.
672
+
673
+ 169
674
+ 00:12:26,000 --> 00:12:27,000
675
+ It can't be null.
676
+
677
+ 170
678
+ 00:12:28,000 --> 00:12:29,000
679
+ Is that clear?
680
+
681
+ 171
682
+ 00:12:29,000 --> 00:12:32,000
683
+ We are done with annotation creation.
684
+
685
+ 172
686
+ 00:12:32,000 --> 00:12:34,000
687
+ Let's now understand how to use it.
688
+
689
+ 173
690
+ 00:12:35,000 --> 00:12:39,000
691
+ As you can notice, there is no logic defined in the annotation.
692
+
693
+ 174
694
+ 00:12:39,000 --> 00:12:46,000
695
+ That means that I should have some place where logic for annotation process is described in this particular
696
+
697
+ 175
698
+ 00:12:46,000 --> 00:12:47,000
699
+ example.
700
+
701
+ 176
702
+ 00:12:47,000 --> 00:12:53,000
703
+ It can be some tests around the class similar to the G unit, where we have separate runners that can
704
+
705
+ 177
706
+ 00:12:53,000 --> 00:12:55,000
707
+ execute my tests.
708
+
709
+ 178
710
+ 00:12:56,000 --> 00:12:58,000
711
+ I open tests around the class.
712
+
713
+ 179
714
+ 00:12:58,000 --> 00:13:01,000
715
+ It has run tests massive that takes class.
716
+
717
+ 180
718
+ 00:13:01,000 --> 00:13:05,000
719
+ It contains tests to run as mass argument.
720
+
721
+ 181
722
+ 00:13:05,000 --> 00:13:11,000
723
+ I use this reference to a class object to get the array of all masses.
724
+
725
+ 182
726
+ 00:13:11,000 --> 00:13:18,000
727
+ After that, I feel the masses to keep in-stream only masses that have test annotation.
728
+
729
+ 183
730
+ 00:13:18,000 --> 00:13:24,000
731
+ After that, I filter all static masses to keep only non static masses in the stream.
732
+
733
+ 184
734
+ 00:13:24,000 --> 00:13:28,000
735
+ And now I need to call test my asset on the object.
736
+
737
+ 185
738
+ 00:13:28,000 --> 00:13:31,000
739
+ I create new instance using test class.
740
+
741
+ 186
742
+ 00:13:32,000 --> 00:13:39,000
743
+ After that, I need to speak logic for annotations that have expected exception and those who don't.
744
+
745
+ 187
746
+ 00:13:39,000 --> 00:13:42,000
747
+ You remember that annotations results?
748
+
749
+ 188
750
+ 00:13:42,000 --> 00:13:47,000
751
+ Bits of fired by client exception still has exception was not by default.
752
+
753
+ 189
754
+ 00:13:48,000 --> 00:13:55,000
755
+ I use this information during implementation of my logic because in case I expect any exceptions specified
756
+
757
+ 190
758
+ 00:13:55,000 --> 00:14:02,000
759
+ by client other than default, I need to check that the expected exception has been thrown come back
760
+
761
+ 191
762
+ 00:14:02,000 --> 00:14:04,000
763
+ losses of exceptions thrown.
764
+
765
+ 192
766
+ 00:14:04,000 --> 00:14:06,000
767
+ Here is the logic for that.
768
+
769
+ 193
770
+ 00:14:07,000 --> 00:14:15,000
771
+ By the way, in a reflection API in case exception has been thrown on the invoked received in the invocation
772
+
773
+ 194
774
+ 00:14:15,000 --> 00:14:20,000
775
+ target exception that serves as a wrapper for a regional exception.
776
+
777
+ 195
778
+ 00:14:21,000 --> 00:14:29,000
779
+ That's why I need to get course massive here to get the reference to the exception that caused invocation
780
+
781
+ 196
782
+ 00:14:29,000 --> 00:14:34,000
783
+ target exception in case I don't expect exception to this rule.
784
+
785
+ 197
786
+ 00:14:34,000 --> 00:14:41,000
787
+ Massad just should be executed successfully, and I just invoke mass differently.
788
+
789
+ 198
790
+ 00:14:41,000 --> 00:14:47,000
791
+ This is not the full replica of test annotation from G-Unit, but we have a goal in this lesson not
792
+
793
+ 199
794
+ 00:14:47,000 --> 00:14:53,000
795
+ to run G-Unit, but to understand how to work with annotations and process zap.
796
+
797
+ 200
798
+ 00:14:54,000 --> 00:14:57,000
799
+ Now let me show you class with tests.
800
+
801
+ 201
802
+ 00:14:57,000 --> 00:15:00,000
803
+ I open the glass, such as code test samples.
804
+
805
+ 202
806
+ 00:15:01,000 --> 00:15:02,000
807
+ This class contains.
808
+
809
+ 203
810
+ 00:15:02,000 --> 00:15:05,000
811
+ Is different mascots that are marked with test annotation.
812
+
813
+ 204
814
+ 00:15:06,000 --> 00:15:09,000
815
+ Each test has name for the sake of the current demo.
816
+
817
+ 205
818
+ 00:15:09,000 --> 00:15:17,000
819
+ I have two test cases here mascots that is executed without exception and massive that throws exception
820
+
821
+ 206
822
+ 00:15:17,000 --> 00:15:18,000
823
+ of expected type.
824
+
825
+ 207
826
+ 00:15:19,000 --> 00:15:20,000
827
+ Nothing complex here.
828
+
829
+ 208
830
+ 00:15:21,000 --> 00:15:27,000
831
+ And now let's write a code that will use my test runner to run these test cases.
832
+
833
+ 209
834
+ 00:15:28,000 --> 00:15:32,000
835
+ I open another clause at the so-called test annotation demo.
836
+
837
+ 210
838
+ 00:15:33,000 --> 00:15:34,000
839
+ I read instance of test runner.
840
+
841
+ 211
842
+ 00:15:35,000 --> 00:15:44,000
843
+ I could run test method and the person's glass that contains my test cases that so let's run this program
844
+
845
+ 212
846
+ 00:15:44,000 --> 00:15:45,000
847
+ and console.
848
+
849
+ 213
850
+ 00:15:45,000 --> 00:15:53,000
851
+ You can see that test without exception has been passed because we received exception that we expect
852
+
853
+ 214
854
+ 00:15:53,000 --> 00:16:01,000
855
+ and test without exception also has been passed because it was executed without any exception.
856
+
857
+ 215
858
+ 00:16:02,000 --> 00:16:06,000
859
+ I recommend you to look through the source code that I left in attachments to the lesson.
860
+
861
+ 216
862
+ 00:16:06,000 --> 00:16:11,000
863
+ Run it on your local computer to understand better how it works.
864
+
865
+ 217
866
+ 00:16:12,000 --> 00:16:16,000
867
+ And the last thing for the desert I'd like to share with you is repeatable annotations.
868
+
869
+ 218
870
+ 00:16:17,000 --> 00:16:23,000
871
+ To be honest, in my opinion, this is a very rare case because in case you need to pass multiple values,
872
+
873
+ 219
874
+ 00:16:24,000 --> 00:16:30,000
875
+ you always can define additional elements in the original annotation or declare array of values for
876
+
877
+ 220
878
+ 00:16:30,000 --> 00:16:31,000
879
+ some element.
880
+
881
+ 221
882
+ 00:16:32,000 --> 00:16:39,000
883
+ Anyway, it was hard for me to come up with real life example in this case, but I just want to demonstrate
884
+
885
+ 222
886
+ 00:16:39,000 --> 00:16:42,000
887
+ use a feature that was added in Java version eight.
888
+
889
+ 223
890
+ 00:16:42,000 --> 00:16:44,000
891
+ Let me open our demo example.
892
+
893
+ 224
894
+ 00:16:45,000 --> 00:16:48,000
895
+ Can they see that I have Orser annotation here duplicated?
896
+
897
+ 225
898
+ 00:16:49,000 --> 00:16:56,000
899
+ Normally it is not accepted, and to be able to use the same annotation twice for the same element,
900
+
901
+ 226
902
+ 00:16:56,000 --> 00:16:59,000
903
+ you need to perform additional actions.
904
+
905
+ 227
906
+ 00:17:00,000 --> 00:17:07,000
907
+ The first thing to do is to add annotation, repeatable annotation definition, like I did for Orser
908
+
909
+ 228
910
+ 00:17:07,000 --> 00:17:08,000
911
+ annotation.
912
+
913
+ 229
914
+ 00:17:08,000 --> 00:17:15,000
915
+ The second thing to do is to create container for repeatable annotations for compatibility reasons.
916
+
917
+ 230
918
+ 00:17:15,000 --> 00:17:19,000
919
+ Repeating annotations are stored in a container annotation.
920
+
921
+ 231
922
+ 00:17:20,000 --> 00:17:25,000
923
+ In order for the compiler to do this, two declarations are required in your code.
924
+
925
+ 232
926
+ 00:17:25,000 --> 00:17:30,000
927
+ That's why another annotation that we need to create is here.
928
+
929
+ 233
930
+ 00:17:30,000 --> 00:17:39,000
931
+ I call it Auster's container annotation must have element value that returns array with objects of repeatable
932
+
933
+ 234
934
+ 00:17:39,000 --> 00:17:42,000
935
+ annotation type that we want to repeat.
936
+
937
+ 235
938
+ 00:17:42,000 --> 00:17:47,000
939
+ In this case, value element will contain array of Orser annotations.
940
+
941
+ 236
942
+ 00:17:47,000 --> 00:17:48,000
943
+ Is that clear?
944
+
945
+ 237
946
+ 00:17:49,000 --> 00:17:52,000
947
+ Basically, that's all what I wanted to share with you.
948
+
949
+ 238
950
+ 00:17:53,000 --> 00:17:55,000
951
+ Let's review what we have learned in this lesson.
952
+
953
+ 239
954
+ 00:17:56,000 --> 00:18:03,000
955
+ In this lesson, we have learned what annotation is also explained to you, why we might need an addition
956
+
957
+ 240
958
+ 00:18:03,000 --> 00:18:05,000
959
+ and when we can use it.
960
+
961
+ 241
962
+ 00:18:05,000 --> 00:18:08,000
963
+ Now, you know where annotations may be applied.
964
+
965
+ 242
966
+ 00:18:09,000 --> 00:18:13,000
967
+ You know why we need targeted annotation and you know what element type in them is.
968
+
969
+ 243
970
+ 00:18:14,000 --> 00:18:19,000
971
+ Also, you learned what retention annotation is and what retention policy in them is.
972
+
973
+ 244
974
+ 00:18:20,000 --> 00:18:21,000
975
+ In the lesson.
976
+
977
+ 245
978
+ 00:18:21,000 --> 00:18:27,000
979
+ We created our custom annotation, and at the end of the lesson, I explained to you how to create repeatable
980
+
981
+ 246
982
+ 00:18:27,000 --> 00:18:28,000
983
+ annotations.
984
+
985
+ 247
986
+ 00:18:29,000 --> 00:18:32,000
987
+ Basically, that's a summary of all what we have learned today.
988
+
989
+ 248
990
+ 00:18:32,000 --> 00:18:37,000
991
+ I have a homework for you in order you can practice in creation of annotations.
992
+
993
+ 249
994
+ 00:18:37,000 --> 00:18:41,000
995
+ You also can find a link to the whole in attachment to the lesson.
996
+
997
+ 250
998
+ 00:18:41,000 --> 00:18:44,000
999
+ Let's understand what you need to do in this task.
1000
+
1001
+ 251
1002
+ 00:18:45,000 --> 00:18:49,000
1003
+ You need to create to do annotation that will allow us to track the progress of note.
1004
+
1005
+ 252
1006
+ 00:18:49,000 --> 00:18:50,000
1007
+ Implement that message.
1008
+
1009
+ 253
1010
+ 00:18:51,000 --> 00:18:57,000
1011
+ To do annotation has different elements such as author, priority and stages.
1012
+
1013
+ 254
1014
+ 00:18:57,000 --> 00:19:05,000
1015
+ Some of them have default values and also Element doesn't have annotation can be applied only to masses
1016
+
1017
+ 255
1018
+ 00:19:05,000 --> 00:19:07,000
1019
+ and should be available under on that.
1020
+
1021
+ 256
1022
+ 00:19:07,000 --> 00:19:14,000
1023
+ We'll see to create separate classes at the school to do analyzer in that class, we should have massive
1024
+
1025
+ 257
1026
+ 00:19:14,000 --> 00:19:22,000
1027
+ three chance string value that is generated to do report pay attention that in order your homework would
1028
+
1029
+ 258
1030
+ 00:19:22,000 --> 00:19:23,000
1031
+ be considered to be done.
1032
+
1033
+ 259
1034
+ 00:19:24,000 --> 00:19:28,000
1035
+ You need to follow specific partners for each method analysis.
1036
+
1037
+ 260
1038
+ 00:19:28,000 --> 00:19:30,000
1039
+ One is described here.
1040
+
1041
+ 261
1042
+ 00:19:30,000 --> 00:19:35,000
1043
+ You should specify method name or search priority on stages.
1044
+
1045
+ 262
1046
+ 00:19:35,000 --> 00:19:42,000
1047
+ Is it clear any way you will be able to find my solution also in attachments does assessment, but try
1048
+
1049
+ 263
1050
+ 00:19:42,000 --> 00:19:49,000
1051
+ to solve this task without any help and by yourself first and only in case solution is not on this for
1052
+
1053
+ 264
1054
+ 00:19:49,000 --> 00:19:49,000
1055
+ you.
1056
+
1057
+ 265
1058
+ 00:19:49,000 --> 00:19:56,000
1059
+ Use my solution as a reference and as always, in case you have any questions, feel free to add your
1060
+
1061
+ 266
1062
+ 00:19:56,000 --> 00:19:58,000
1063
+ questions in comments on this video.
1064
+
1065
+ 267
1066
+ 00:19:59,000 --> 00:20:01,000
1067
+ Thanks a lot you for your attention.
1068
+
1069
+ 268
1070
+ 00:20:01,000 --> 00:20:04,000
1071
+ Have a great day and see in the next lesson.
1072
+
30 - Java Reflection API/002 Homework-Solution.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/annotations/hw
30 - Java Reflection API/002 Homework.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://docs.google.com/document/d/1SFPh7rGW3vyQnOdSLgMg4v-WE_CTEpgVYyWXJkwfCic/edit?usp=sharing
30 - Java Reflection API/002 Source-code-of-examples-from-the-lesson.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/annotations
30 - Java Reflection API/external-links.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ 001 Source-code-of-example-from-the-lesson
3
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/src/com/itbulls/learnit/javacore/reflection/Demo.java
4
+
5
+ 002 Source-code-of-examples-from-the-lesson
6
+ https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/annotations
7
+
8
+ 002 Homework
9
+ https://docs.google.com/document/d/1SFPh7rGW3vyQnOdSLgMg4v-WE_CTEpgVYyWXJkwfCic/edit?usp=sharing
10
+
11
+ 002 Homework-Solution
12
+ https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/annotations/hw
31 - JDK API/001 Source-code-from-the-lesson.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/string/stringbuilder
31 - JDK API/001 StringBuilder & StringBuffer_en.srt ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:05,000 --> 00:00:06,000
3
+ Hello, Jim.
4
+
5
+ 2
6
+ 00:00:06,000 --> 00:00:10,000
7
+ In this lesson, we are going to learn how to work with swing builder and string buffer classes.
8
+
9
+ 3
10
+ 00:00:11,000 --> 00:00:14,000
11
+ Also, I'm going to explain why we might need them.
12
+
13
+ 4
14
+ 00:00:14,000 --> 00:00:21,000
15
+ We're going to start from understanding what these classes are and why do we need them and want to understand
16
+
17
+ 5
18
+ 00:00:21,000 --> 00:00:23,000
19
+ the problems that these classes are supposed to solve.
20
+
21
+ 6
22
+ 00:00:24,000 --> 00:00:29,000
23
+ We're going to have practical example where I will explain in detail why you should never forget about
24
+
25
+ 7
26
+ 00:00:29,000 --> 00:00:33,000
27
+ string builder and string the buffer in this lesson.
28
+
29
+ 8
30
+ 00:00:33,000 --> 00:00:38,000
31
+ I'm going to explain the difference between these two classes and what is even more important.
32
+
33
+ 9
34
+ 00:00:38,000 --> 00:00:42,000
35
+ I will teach you when to use these classes and how to use them.
36
+
37
+ 10
38
+ 00:00:42,000 --> 00:00:50,000
39
+ I will show you example of string builder and string the bar for usage and also will char sequence interface.
40
+
41
+ 11
42
+ 00:00:50,000 --> 00:00:57,000
43
+ Let's start let's try to understand first what a string builder class in the documentation.
44
+
45
+ 12
46
+ 00:00:57,000 --> 00:01:02,000
47
+ This class is described as mutable sequence of characters by this moment.
48
+
49
+ 13
50
+ 00:01:02,000 --> 00:01:07,000
51
+ Now, of course, you already know that objects of string class are immutable.
52
+
53
+ 14
54
+ 00:01:07,000 --> 00:01:13,000
55
+ In short, there's a class designed in the way that you can't change the state of a regional object
56
+
57
+ 15
58
+ 00:01:13,000 --> 00:01:15,000
59
+ after it was instantiated.
60
+
61
+ 16
62
+ 00:01:16,000 --> 00:01:21,000
63
+ All assets don't modify state of the original string or objects that we created.
64
+
65
+ 17
66
+ 00:01:22,000 --> 00:01:28,000
67
+ The class itself is final and you can't override it to change the logic of methods.
68
+
69
+ 18
70
+ 00:01:28,000 --> 00:01:35,000
71
+ That means that each time you modify string in your program, you actually create a new object of the
72
+
73
+ 19
74
+ 00:01:35,000 --> 00:01:35,000
75
+ string.
76
+
77
+ 20
78
+ 00:01:36,000 --> 00:01:42,000
79
+ Yes, you might lose the reference to the string object in case new string object is assigned to the
80
+
81
+ 21
82
+ 00:01:42,000 --> 00:01:43,000
83
+ regional variable.
84
+
85
+ 22
86
+ 00:01:43,000 --> 00:01:49,000
87
+ And yes, in the case there is no strong references to the object, garbage collector will clean it
88
+
89
+ 23
90
+ 00:01:49,000 --> 00:01:49,000
91
+ up.
92
+
93
+ 24
94
+ 00:01:50,000 --> 00:01:53,000
95
+ I'm going to show this case in the example later today.
96
+
97
+ 25
98
+ 00:01:53,000 --> 00:01:57,000
99
+ But the only question that I want to ask you sounds like this.
100
+
101
+ 26
102
+ 00:01:58,000 --> 00:02:02,000
103
+ Do we need to rely on garbage collector and make it work?
104
+
105
+ 27
106
+ 00:02:02,000 --> 00:02:07,000
107
+ The answer is no one garbage collector starts its work.
108
+
109
+ 28
110
+ 00:02:07,000 --> 00:02:12,000
111
+ It is also some computation time that potentially might be used by US operations.
112
+
113
+ 29
114
+ 00:02:12,000 --> 00:02:16,000
115
+ Instead of cleaning up objects without strong references.
116
+
117
+ 30
118
+ 00:02:16,000 --> 00:02:22,000
119
+ And by the way, it is important for you to know and remember the difference between different types
120
+
121
+ 31
122
+ 00:02:22,000 --> 00:02:23,000
123
+ of references.
124
+
125
+ 32
126
+ 00:02:23,000 --> 00:02:29,000
127
+ In case you want to learn more about this topic, make sure you watched my lesson about references where
128
+
129
+ 33
130
+ 00:02:29,000 --> 00:02:36,000
131
+ I explained different types of references, but still how to solve a problem of constant creation of
132
+
133
+ 34
134
+ 00:02:36,000 --> 00:02:37,000
135
+ string object.
136
+
137
+ 35
138
+ 00:02:37,000 --> 00:02:44,000
139
+ If I'm modifying string so the situation might be completely different is a process a lot of strings
140
+
141
+ 36
142
+ 00:02:44,000 --> 00:02:50,000
143
+ and you need all of them in one string or you prepare string before writing it to the file.
144
+
145
+ 37
146
+ 00:02:51,000 --> 00:02:52,000
147
+ It doesn't matter.
148
+
149
+ 38
150
+ 00:02:52,000 --> 00:02:59,000
151
+ But in some hypothetical case, instead of creation, millions of string objects and heap memory, it
152
+
153
+ 39
154
+ 00:02:59,000 --> 00:03:04,000
155
+ is recommended to create one object of string, build it up and use it.
156
+
157
+ 40
158
+ 00:03:04,000 --> 00:03:09,000
159
+ Does it make sense to understand the motivation of using an object of this type?
160
+
161
+ 41
162
+ 00:03:10,000 --> 00:03:10,000
163
+ Great.
164
+
165
+ 42
166
+ 00:03:11,000 --> 00:03:14,000
167
+ Let's now understand what a string buffer class is.
168
+
169
+ 43
170
+ 00:03:14,000 --> 00:03:21,000
171
+ It would be easy to explain what is this class about because it is almost the same as string builder
172
+
173
+ 44
174
+ 00:03:21,000 --> 00:03:21,000
175
+ class.
176
+
177
+ 45
178
+ 00:03:22,000 --> 00:03:24,000
179
+ They have similar methods, similar constructors.
180
+
181
+ 46
182
+ 00:03:25,000 --> 00:03:27,000
183
+ Literally almost everything is similar.
184
+
185
+ 47
186
+ 00:03:27,000 --> 00:03:35,000
187
+ The only difference is that string, the buffer is a safe class and objects of this type might be used
188
+
189
+ 48
190
+ 00:03:35,000 --> 00:03:39,000
191
+ in an execution without impact on data consistency.
192
+
193
+ 49
194
+ 00:03:39,000 --> 00:03:43,000
195
+ What a lot of training is discussed in the separate section of the course.
196
+
197
+ 50
198
+ 00:03:44,000 --> 00:03:51,000
199
+ But still, I would like to remind to all students about multithreaded one more time in in case of Perou
200
+
201
+ 51
202
+ 00:03:51,000 --> 00:03:53,000
203
+ execution of multiple threads.
204
+
205
+ 52
206
+ 00:03:54,000 --> 00:04:00,000
207
+ When different threads update the state of the string buffer simultaneously or read its data, only
208
+
209
+ 53
210
+ 00:04:00,000 --> 00:04:07,000
211
+ one thread is allowed to execute these operations with potential mistakes that may happen because of
212
+
213
+ 54
214
+ 00:04:08,000 --> 00:04:09,000
215
+ an axis.
216
+
217
+ 55
218
+ 00:04:09,000 --> 00:04:15,000
219
+ That's why everything what I'm going to share with you about String Builder is absolutely applicable
220
+
221
+ 56
222
+ 00:04:15,000 --> 00:04:17,000
223
+ to the string buffer in Montessori environment.
224
+
225
+ 57
226
+ 00:04:18,000 --> 00:04:24,000
227
+ The rule of thumb is to use three builder whenever is possible because it has better performance.
228
+
229
+ 58
230
+ 00:04:25,000 --> 00:04:31,000
231
+ This is just consequences of not having synchronization from multiple threads inside string builder,
232
+
233
+ 59
234
+ 00:04:31,000 --> 00:04:38,000
235
+ whereas all mascot's in string buffer are synchronized and this takes additional overhead during the
236
+
237
+ 60
238
+ 00:04:38,000 --> 00:04:39,000
239
+ execution.
240
+
241
+ 61
242
+ 00:04:39,000 --> 00:04:41,000
243
+ You should be all right with String Builder.
244
+
245
+ 62
246
+ 00:04:41,000 --> 00:04:47,000
247
+ In most cases, I believe that you already understood on the high level why we need these classes.
248
+
249
+ 63
250
+ 00:04:47,000 --> 00:04:53,000
251
+ It is time to dive deeper in details and understand how to work with objects of this type.
252
+
253
+ 64
254
+ 00:04:54,000 --> 00:04:57,000
255
+ And let's start from explaining the hypothetical problem.
256
+
257
+ 65
258
+ 00:04:58,000 --> 00:04:59,000
259
+ I have file with stacks.
260
+
261
+ 66
262
+ 00:05:00,000 --> 00:05:03,000
263
+ This is lyrics of the song that I listened while.
264
+
265
+ 67
266
+ 00:05:03,000 --> 00:05:09,000
267
+ Thinking about the structure of the lesson, the song is called Never Coming Home By Staying Pretty
268
+
269
+ 68
270
+ 00:05:10,000 --> 00:05:11,000
271
+ Cool one, by the way.
272
+
273
+ 69
274
+ 00:05:11,000 --> 00:05:18,000
275
+ And according to business logic, I need to be able to read text from files and after that work with
276
+
277
+ 70
278
+ 00:05:18,000 --> 00:05:20,000
279
+ the content of the file as a whole.
280
+
281
+ 71
282
+ 00:05:20,000 --> 00:05:24,000
283
+ For example, text analysis or text statistics is needed.
284
+
285
+ 72
286
+ 00:05:25,000 --> 00:05:29,000
287
+ Probably you want to implement programs that would analyze thousands of songs in order.
288
+
289
+ 73
290
+ 00:05:29,000 --> 00:05:36,000
291
+ You could find the best rhymes any way you can be in any of other situations that would make it to collect
292
+
293
+ 74
294
+ 00:05:36,000 --> 00:05:39,000
295
+ all streams in one string object.
296
+
297
+ 75
298
+ 00:05:39,000 --> 00:05:47,000
299
+ I open my example now that is called string build a demo I have mastered that reads all lines from file
300
+
301
+ 76
302
+ 00:05:47,000 --> 00:05:52,000
303
+ into one string object and after that I bring the strings to console.
304
+
305
+ 77
306
+ 00:05:52,000 --> 00:05:54,000
307
+ Let's review this method.
308
+
309
+ 78
310
+ 00:05:54,000 --> 00:06:00,000
311
+ I create the reference of the same time as it is pointing out to the object that is stored in St. Paul.
312
+
313
+ 79
314
+ 00:06:01,000 --> 00:06:07,000
315
+ If you don't remember what a string will please refer to as a lesson about string objects and string
316
+
317
+ 80
318
+ 00:06:07,000 --> 00:06:09,000
319
+ CPU in my Java course.
320
+
321
+ 81
322
+ 00:06:09,000 --> 00:06:14,000
323
+ In the next line I read all lines from file into the list of strings.
324
+
325
+ 82
326
+ 00:06:14,000 --> 00:06:20,000
327
+ In case you're interested how I did this, please refer to the section about input output streams in
328
+
329
+ 83
330
+ 00:06:20,000 --> 00:06:21,000
331
+ my Java course.
332
+
333
+ 84
334
+ 00:06:21,000 --> 00:06:29,000
335
+ After that I iterate and over each line and I concatenate each line with my result string and adding
336
+
337
+ 85
338
+ 00:06:29,000 --> 00:06:31,000
339
+ new one character at the end of each line.
340
+
341
+ 86
342
+ 00:06:32,000 --> 00:06:34,000
343
+ What is actually happening here?
344
+
345
+ 87
346
+ 00:06:34,000 --> 00:06:41,000
347
+ I create a new string object after each concatenation and this string reference pointing out to the
348
+
349
+ 88
350
+ 00:06:41,000 --> 00:06:42,000
351
+ new object in memory.
352
+
353
+ 89
354
+ 00:06:42,000 --> 00:06:48,000
355
+ Each time after concatenation you are going to have the object that contains the first line.
356
+
357
+ 90
358
+ 00:06:48,000 --> 00:06:52,000
359
+ Only the second object would be the first line.
360
+
361
+ 91
362
+ 00:06:52,000 --> 00:06:59,000
363
+ And Newline character is a shared object, would be the first line newline character and the second
364
+
365
+ 92
366
+ 00:06:59,000 --> 00:07:00,000
367
+ line and so on.
368
+
369
+ 93
370
+ 00:07:01,000 --> 00:07:05,000
371
+ Why do you need so many duplication and so many string objects?
372
+
373
+ 94
374
+ 00:07:05,000 --> 00:07:09,000
375
+ And that is not a big harm in process in one song.
376
+
377
+ 95
378
+ 00:07:09,000 --> 00:07:15,000
379
+ But believe me, you are going to work with files much bigger than we have in our example today.
380
+
381
+ 96
382
+ 00:07:15,000 --> 00:07:17,000
383
+ And this is going to become a problem.
384
+
385
+ 97
386
+ 00:07:18,000 --> 00:07:19,000
387
+ What would be the solution here?
388
+
389
+ 98
390
+ 00:07:19,000 --> 00:07:22,000
391
+ The solution here is to use string build object.
392
+
393
+ 99
394
+ 00:07:23,000 --> 00:07:29,000
395
+ Let's look at another method that also read all lines from the file, but do it with help of string
396
+
397
+ 100
398
+ 00:07:29,000 --> 00:07:30,000
399
+ builder object.
400
+
401
+ 101
402
+ 00:07:30,000 --> 00:07:34,000
403
+ I create object of string, build a type with the default constructor.
404
+
405
+ 102
406
+ 00:07:35,000 --> 00:07:37,000
407
+ After that I am doing the same thing.
408
+
409
+ 103
410
+ 00:07:37,000 --> 00:07:39,000
411
+ I'm bringing the lines into the list.
412
+
413
+ 104
414
+ 00:07:39,000 --> 00:07:41,000
415
+ Object in foreach loop.
416
+
417
+ 105
418
+ 00:07:41,000 --> 00:07:45,000
419
+ I call append massata patterns new line and newline character.
420
+
421
+ 106
422
+ 00:07:46,000 --> 00:07:51,000
423
+ I need to return a string object from the method so I call to string methods.
424
+
425
+ 107
426
+ 00:07:51,000 --> 00:07:54,000
427
+ It creates string object based on my string builder.
428
+
429
+ 108
430
+ 00:07:55,000 --> 00:07:55,000
431
+ That's it.
432
+
433
+ 109
434
+ 00:07:56,000 --> 00:08:02,000
435
+ To prove you that concatenation of strings with string builder is more efficient, I evaluate the time
436
+
437
+ 110
438
+ 00:08:02,000 --> 00:08:04,000
439
+ for both of these separations.
440
+
441
+ 111
442
+ 00:08:04,000 --> 00:08:11,000
443
+ I just take amount of milliseconds before the first method invocation and after that I calculate Delta
444
+
445
+ 112
446
+ 00:08:11,000 --> 00:08:19,000
447
+ in milliseconds by the doctors the time that I already have from current time after method execution.
448
+
449
+ 113
450
+ 00:08:19,000 --> 00:08:24,000
451
+ Following this approach, I can estimate how long does it take to execute code?
452
+
453
+ 114
454
+ 00:08:24,000 --> 00:08:26,000
455
+ That is between two points.
456
+
457
+ 115
458
+ 00:08:26,000 --> 00:08:30,000
459
+ And I did similar measurement in the second example for String Builder.
460
+
461
+ 116
462
+ 00:08:31,000 --> 00:08:37,000
463
+ After that I bring two values to console in order we could have a chance to compare these two values.
464
+
465
+ 117
466
+ 00:08:37,000 --> 00:08:45,000
467
+ Let's run the program so you can see the difference in performance with one song of string is approximately
468
+
469
+ 118
470
+ 00:08:45,000 --> 00:08:47,000
471
+ ten times more restrained.
472
+
473
+ 119
474
+ 00:08:47,000 --> 00:08:49,000
475
+ Object concatenation.
476
+
477
+ 120
478
+ 00:08:49,000 --> 00:08:52,000
479
+ Imagine what the difference would be was a gigabyte files.
480
+
481
+ 121
482
+ 00:08:53,000 --> 00:08:54,000
483
+ It is crazy.
484
+
485
+ 122
486
+ 00:08:54,000 --> 00:08:59,000
487
+ That's why it is important to use string builder during the processing of big number of strings.
488
+
489
+ 123
490
+ 00:09:00,000 --> 00:09:06,000
491
+ Basically, we have just removed probably the most popular example of string builder and string bar
492
+
493
+ 124
494
+ 00:09:06,000 --> 00:09:07,000
495
+ for usage.
496
+
497
+ 125
498
+ 00:09:07,000 --> 00:09:12,000
499
+ But let me also share with you a little bit more details about class structure and other methods.
500
+
501
+ 126
502
+ 00:09:13,000 --> 00:09:15,000
503
+ I open the source code of string builder class.
504
+
505
+ 127
506
+ 00:09:16,000 --> 00:09:21,000
507
+ And just to remind you, what we are going to review now is absolutely similar in string.
508
+
509
+ 128
510
+ 00:09:21,000 --> 00:09:23,000
511
+ The buffer clause was only one exception.
512
+
513
+ 129
514
+ 00:09:23,000 --> 00:09:25,000
515
+ Synchronized methods.
516
+
517
+ 130
518
+ 00:09:25,000 --> 00:09:28,000
519
+ This is the full constructor calls, constructor of super class.
520
+
521
+ 131
522
+ 00:09:29,000 --> 00:09:35,000
523
+ That is abstract string the builder specifying the original capacity of the characters array.
524
+
525
+ 132
526
+ 00:09:35,000 --> 00:09:37,000
527
+ By default it is 610.
528
+
529
+ 133
530
+ 00:09:38,000 --> 00:09:41,000
531
+ Do not find any Secrett logic behind this number.
532
+
533
+ 134
534
+ 00:09:41,000 --> 00:09:42,000
535
+ It is just 16.
536
+
537
+ 135
538
+ 00:09:43,000 --> 00:09:48,000
539
+ There is also a string builder within parameter to specify any custom default capacity.
540
+
541
+ 136
542
+ 00:09:49,000 --> 00:09:51,000
543
+ One you should use this version of constructor.
544
+
545
+ 137
546
+ 00:09:52,000 --> 00:09:55,000
547
+ I believe that you already know how arrays work in Java.
548
+
549
+ 138
550
+ 00:09:55,000 --> 00:09:59,000
551
+ You can text extend array that was created already.
552
+
553
+ 139
554
+ 00:10:00,000 --> 00:10:02,000
555
+ So to extent existing array you need.
556
+
557
+ 140
558
+ 00:10:03,000 --> 00:10:09,000
559
+ To create a bigger array and copy old values in that this is time consuming operation.
560
+
561
+ 141
562
+ 00:10:10,000 --> 00:10:16,000
563
+ That's why in case you know that you're going to process a big amount of data, you can set initial
564
+
565
+ 142
566
+ 00:10:16,000 --> 00:10:23,000
567
+ capacity in order to avoid concentration of new array objects, to have enough space for all characters.
568
+
569
+ 143
570
+ 00:10:23,000 --> 00:10:30,000
571
+ Also, we can create string builder and initialize it with the content of the string object or any char
572
+
573
+ 144
574
+ 00:10:30,000 --> 00:10:30,000
575
+ sequence.
576
+
577
+ 145
578
+ 00:10:31,000 --> 00:10:37,000
579
+ Short sequence is an interface that is implemented by many different classes in Java, for example,
580
+
581
+ 146
582
+ 00:10:37,000 --> 00:10:42,000
583
+ string swing builder, string buffer, abstract string builder and others.
584
+
585
+ 147
586
+ 00:10:42,000 --> 00:10:45,000
587
+ All of them implements char sequence interface.
588
+
589
+ 148
590
+ 00:10:46,000 --> 00:10:53,000
591
+ This interface declares contract for such mascot's as Lancs to return total number of characters in
592
+
593
+ 149
594
+ 00:10:53,000 --> 00:11:01,000
595
+ char sequence char at Richmondshire as a specified index is empty default masset the checks with the
596
+
597
+ 150
598
+ 00:11:01,000 --> 00:11:03,000
599
+ Lancs equal to zero returns.
600
+
601
+ 151
602
+ 00:11:03,000 --> 00:11:10,000
603
+ True, if character sequence is empty and false, otherwise Subsequence Masset will return char sequence
604
+
605
+ 152
606
+ 00:11:10,000 --> 00:11:14,000
607
+ from indexing collusively to indexed exclusively.
608
+
609
+ 153
610
+ 00:11:14,000 --> 00:11:16,000
611
+ And you know what the string method does.
612
+
613
+ 154
614
+ 00:11:17,000 --> 00:11:22,000
615
+ Also, we are a few more default methods and one Zem Chass returns in stream.
616
+
617
+ 155
618
+ 00:11:23,000 --> 00:11:31,000
619
+ Just to remind you that Char easily may be converted to end Y because integer variable specifies sequence
620
+
621
+ 156
622
+ 00:11:31,000 --> 00:11:40,000
623
+ number of the character and the Unicode table code points returns in stream where each end will represent
624
+
625
+ 157
626
+ 00:11:40,000 --> 00:11:42,000
627
+ characters sequence number in the Unicode table.
628
+
629
+ 158
630
+ 00:11:43,000 --> 00:11:49,000
631
+ I will be honest with you, I have never used this method, but at least it is good just to know that
632
+
633
+ 159
634
+ 00:11:49,000 --> 00:11:56,000
635
+ such as it exists in learning purposes and static methods that may be used to combat two character sequences.
636
+
637
+ 160
638
+ 00:11:57,000 --> 00:12:02,000
639
+ Let's get back to the implementation of a sequence that we are running today.
640
+
641
+ 161
642
+ 00:12:02,000 --> 00:12:04,000
643
+ I open string builder class.
644
+
645
+ 162
646
+ 00:12:04,000 --> 00:12:10,000
647
+ As you can see in outline here, there are a lot of versions of append method.
648
+
649
+ 163
650
+ 00:12:11,000 --> 00:12:16,000
651
+ This method is overloaded to be able to accept parameter of different types.
652
+
653
+ 164
654
+ 00:12:16,000 --> 00:12:23,000
655
+ Also, we can delete from char to char, from string builder onto the teacher at the specified index.
656
+
657
+ 165
658
+ 00:12:23,000 --> 00:12:28,000
659
+ And again, it is hard for me to come up with an example where you would use this massas on a daily
660
+
661
+ 166
662
+ 00:12:28,000 --> 00:12:35,000
663
+ basis, replace Masset from index to index and be replaced with the string.
664
+
665
+ 167
666
+ 00:12:36,000 --> 00:12:39,000
667
+ Another method that is overloaded in this class is insert.
668
+
669
+ 168
670
+ 00:12:40,000 --> 00:12:44,000
671
+ It is used to insert the specified value at the specified position.
672
+
673
+ 169
674
+ 00:12:44,000 --> 00:12:45,000
675
+ It is overloaded.
676
+
677
+ 170
678
+ 00:12:45,000 --> 00:12:53,000
679
+ The Different Parameters Index of Masset returns the index within this string of the first occurrence
680
+
681
+ 171
682
+ 00:12:53,000 --> 00:12:58,000
683
+ of the specified substring last index of returns.
684
+
685
+ 172
686
+ 00:12:58,000 --> 00:13:03,000
687
+ The index within this string of the last occurrence of the specified substring.
688
+
689
+ 173
690
+ 00:13:03,000 --> 00:13:10,000
691
+ The last two methods also have overloaded version that additionally it takes one more parameter of time.
692
+
693
+ 174
694
+ 00:13:11,000 --> 00:13:15,000
695
+ This is the index from which to start the search reverse.
696
+
697
+ 175
698
+ 00:13:15,000 --> 00:13:21,000
699
+ Massata causes this character sequence to be replaced by the reverse of the sequence.
700
+
701
+ 176
702
+ 00:13:21,000 --> 00:13:24,000
703
+ That's all methods of string builder class.
704
+
705
+ 177
706
+ 00:13:24,000 --> 00:13:30,000
707
+ What I would recommend you open the source code of string builder string, buffer and abstract string
708
+
709
+ 178
710
+ 00:13:30,000 --> 00:13:36,000
711
+ to build the class leukocoria through the code and try to play with matches.
712
+
713
+ 179
714
+ 00:13:36,000 --> 00:13:41,000
715
+ We have discussed the most important ones and the masses that have chance to be used in production.
716
+
717
+ 180
718
+ 00:13:42,000 --> 00:13:48,000
719
+ But in case you would find any other method that you are interested in and you would like to talk more
720
+
721
+ 181
722
+ 00:13:48,000 --> 00:13:51,000
723
+ about it, do not hesitate to ask questions below this video.
724
+
725
+ 182
726
+ 00:13:51,000 --> 00:13:57,000
727
+ I will be happy to answer all of your questions, but I truly believe that we have learned just enough
728
+
729
+ 183
730
+ 00:13:57,000 --> 00:14:02,000
731
+ things in order to be able to start using string builder and string four classes.
732
+
733
+ 184
734
+ 00:14:03,000 --> 00:14:06,000
735
+ Now, let's recap what we have learned in this lesson.
736
+
737
+ 185
738
+ 00:14:06,000 --> 00:14:10,000
739
+ After this lesson, we know what string builder and string buffer classes are.
740
+
741
+ 186
742
+ 00:14:11,000 --> 00:14:17,000
743
+ I believe that you understood the purpose of these classes and use cases when to use them.
744
+
745
+ 187
746
+ 00:14:17,000 --> 00:14:20,000
747
+ Also review the char sequence interface today.
748
+
749
+ 188
750
+ 00:14:20,000 --> 00:14:22,000
751
+ That's it for this lesson.
752
+
753
+ 189
754
+ 00:14:22,000 --> 00:14:24,000
755
+ Thanks a lot for your attention.
756
+
757
+ 190
758
+ 00:14:24,000 --> 00:14:27,000
759
+ Have a great day and see you in the next lesson.
760
+
31 - JDK API/002 Source-code-examples-from-the-lesson.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/optional
31 - JDK API/002 java.util.Optional - Optional in Java_en.srt ADDED
@@ -0,0 +1,1476 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:06,000
3
+ Hello, Jim.
4
+
5
+ 2
6
+ 00:00:06,000 --> 00:00:09,000
7
+ In this lesson, we're going to learn optional class API.
8
+
9
+ 3
10
+ 00:00:10,000 --> 00:00:16,000
11
+ We're going to start a lesson from the definition of optional class is understanding of the goal and
12
+
13
+ 4
14
+ 00:00:16,000 --> 00:00:24,000
15
+ purpose of this class will help you to understand that better known this will be an optional class API.
16
+
17
+ 5
18
+ 00:00:24,000 --> 00:00:31,000
19
+ And on real Covid examples I'm going to show you how to work was methods from optional class, and then
20
+
21
+ 6
22
+ 00:00:31,000 --> 00:00:33,000
23
+ to the lesson of explaining when to use optional.
24
+
25
+ 7
26
+ 00:00:33,000 --> 00:00:40,000
27
+ And you will understand in which cases use of optional will be efficient and will not bring more harm
28
+
29
+ 8
30
+ 00:00:40,000 --> 00:00:41,000
31
+ than good.
32
+
33
+ 9
34
+ 00:00:41,000 --> 00:00:48,000
35
+ Besides that, I will answer to the question what alternative techniques might be used instead of optional?
36
+
37
+ 10
38
+ 00:00:48,000 --> 00:00:49,000
39
+ Let's stop.
40
+
41
+ 11
42
+ 00:00:50,000 --> 00:00:53,000
43
+ And let me start from explanation of what optional class is.
44
+
45
+ 12
46
+ 00:00:53,000 --> 00:00:54,000
47
+ And why do we need it?
48
+
49
+ 13
50
+ 00:00:55,000 --> 00:00:56,000
51
+ Do you know what?
52
+
53
+ 14
54
+ 00:00:56,000 --> 00:00:58,000
55
+ No point or exception is?
56
+
57
+ 15
58
+ 00:00:58,000 --> 00:00:59,000
59
+ Probably.
60
+
61
+ 16
62
+ 00:00:59,000 --> 00:01:04,000
63
+ This is one of the most popular exceptions that interrupts our program execution.
64
+
65
+ 17
66
+ 00:01:04,000 --> 00:01:09,000
67
+ Just a reminder to all students that no point or exception is an exception.
68
+
69
+ 18
70
+ 00:01:09,000 --> 00:01:10,000
71
+ That's a strong one.
72
+
73
+ 19
74
+ 00:01:10,000 --> 00:01:13,000
75
+ We try to invoke some Masset on the reference.
76
+
77
+ 20
78
+ 00:01:13,000 --> 00:01:15,000
79
+ It is not initialized.
80
+
81
+ 21
82
+ 00:01:15,000 --> 00:01:17,000
83
+ In other words, we have variables.
84
+
85
+ 22
86
+ 00:01:17,000 --> 00:01:21,000
87
+ It doesn't store reference to any of objects in the heap memory.
88
+
89
+ 23
90
+ 00:01:22,000 --> 00:01:26,000
91
+ And when we call some Massart on the variable, we received no pointer exception.
92
+
93
+ 24
94
+ 00:01:26,000 --> 00:01:32,000
95
+ That tells us that we actually can't invoke any Massart on the nothing.
96
+
97
+ 25
98
+ 00:01:32,000 --> 00:01:33,000
99
+ Is that clear?
100
+
101
+ 26
102
+ 00:01:33,000 --> 00:01:40,000
103
+ And to avoid cases like this, we should never forget to perform no check before any Massart invocation.
104
+
105
+ 27
106
+ 00:01:41,000 --> 00:01:47,000
107
+ The new clause that has been introduced in Java eight is supposed to alleviate some problems.
108
+
109
+ 28
110
+ 00:01:47,000 --> 00:01:53,000
111
+ In my opinion, the introduction of this class is controversial from one side.
112
+
113
+ 29
114
+ 00:01:53,000 --> 00:02:00,000
115
+ It is grades that geoengineers has two legs, this one to indicate places where we may have no potentially.
116
+
117
+ 30
118
+ 00:02:00,000 --> 00:02:07,000
119
+ But from the other side, in my opinion, optional class, often used by developers inappropriately
120
+
121
+ 31
122
+ 00:02:07,000 --> 00:02:11,000
123
+ and brings into the code more complexity and harm than good.
124
+
125
+ 32
126
+ 00:02:11,000 --> 00:02:16,000
127
+ But in this lesson, I will share with you my tips and other you use optional class efficiently.
128
+
129
+ 33
130
+ 00:02:17,000 --> 00:02:23,000
131
+ Generally speaking written and no reference from any massata considered to be a bad practice.
132
+
133
+ 34
134
+ 00:02:23,000 --> 00:02:30,000
135
+ For example, you call getta on the object that doesn't have all fields initialized yet, and you receive
136
+
137
+ 35
138
+ 00:02:30,000 --> 00:02:31,000
139
+ no reference.
140
+
141
+ 36
142
+ 00:02:31,000 --> 00:02:32,000
143
+ Indeed.
144
+
145
+ 37
146
+ 00:02:32,000 --> 00:02:35,000
147
+ What else you should receive if there is nothing yet?
148
+
149
+ 38
150
+ 00:02:36,000 --> 00:02:41,000
151
+ What if a field is really empty and doesn't initialized with any reference yet?
152
+
153
+ 39
154
+ 00:02:41,000 --> 00:02:42,000
155
+ Thorney ha.
156
+
157
+ 40
158
+ 00:02:43,000 --> 00:02:48,000
159
+ One of the giants of computer science wrote I call it my billion dollar mistake.
160
+
161
+ 41
162
+ 00:02:49,000 --> 00:02:53,000
163
+ It was the invention of the no reference in nineteen sixty five.
164
+
165
+ 42
166
+ 00:02:53,000 --> 00:03:00,000
167
+ I couldn't resist the temptation to put in a no reference simply because it was so easy to implement.
168
+
169
+ 43
170
+ 00:03:01,000 --> 00:03:05,000
171
+ I can add to that it wasn't just so easy to implement.
172
+
173
+ 44
174
+ 00:03:05,000 --> 00:03:08,000
175
+ It was also so logical to implement.
176
+
177
+ 45
178
+ 00:03:09,000 --> 00:03:13,000
179
+ Let me start sharing my screen to explain the problems that we have today.
180
+
181
+ 46
182
+ 00:03:13,000 --> 00:03:14,000
183
+ Is it optional?
184
+
185
+ 47
186
+ 00:03:14,000 --> 00:03:21,000
187
+ Closs is intended to solve I open class problem statement from optional package of my little project.
188
+
189
+ 48
190
+ 00:03:21,000 --> 00:03:24,000
191
+ In this example, imagine that we have instance of the computer.
192
+
193
+ 49
194
+ 00:03:25,000 --> 00:03:32,000
195
+ We have some computer and USB drive, potentially USB drive, maybe plugged in or may not.
196
+
197
+ 50
198
+ 00:03:33,000 --> 00:03:40,000
199
+ I can call yet USB drive Massart on my computer object to get the reference to the USB drive in case
200
+
201
+ 51
202
+ 00:03:40,000 --> 00:03:42,000
203
+ Nassan is plugged in.
204
+
205
+ 52
206
+ 00:03:42,000 --> 00:03:44,000
207
+ I receive no correct.
208
+
209
+ 53
210
+ 00:03:44,000 --> 00:03:51,000
211
+ But in case there is a USB drive, I can get access to the right contacts switch to check it state.
212
+
213
+ 54
214
+ 00:03:52,000 --> 00:03:55,000
215
+ In this case, I need to perform no check again.
216
+
217
+ 55
218
+ 00:03:55,000 --> 00:03:57,000
219
+ Can you see how my code looks like?
220
+
221
+ 56
222
+ 00:03:58,000 --> 00:04:03,000
223
+ And the good thing about all this is that I am smart enough to perform such checks.
224
+
225
+ 57
226
+ 00:04:03,000 --> 00:04:07,000
227
+ It would be worse in case such checks wouldn't exist at all.
228
+
229
+ 58
230
+ 00:04:08,000 --> 00:04:10,000
231
+ And to my program would just fail.
232
+
233
+ 59
234
+ 00:04:10,000 --> 00:04:17,000
235
+ Units execution that understands the point, in addition, is just annoying that these checks get in
236
+
237
+ 60
238
+ 00:04:17,000 --> 00:04:19,000
239
+ the way of the business logic.
240
+
241
+ 61
242
+ 00:04:20,000 --> 00:04:24,000
243
+ In fact, Zedek reasons that overall are the beauty of our program.
244
+
245
+ 62
246
+ 00:04:25,000 --> 00:04:27,000
247
+ What would be better than this?
248
+
249
+ 63
250
+ 00:04:27,000 --> 00:04:33,000
251
+ It will be better to build data structure that would indicate presence or absence of the value.
252
+
253
+ 64
254
+ 00:04:34,000 --> 00:04:35,000
255
+ That's what we need.
256
+
257
+ 65
258
+ 00:04:35,000 --> 00:04:36,000
259
+ Optional Class four.
260
+
261
+ 66
262
+ 00:04:37,000 --> 00:04:44,000
263
+ So we agreed that we need a mechanism that allows a massive developer to explicitly denote there's a
264
+
265
+ 67
266
+ 00:04:44,000 --> 00:04:51,000
267
+ return value for a massive may or may not be present optional class acts as a prop for an object that
268
+
269
+ 68
270
+ 00:04:51,000 --> 00:04:53,000
271
+ may not be present.
272
+
273
+ 69
274
+ 00:04:53,000 --> 00:04:59,000
275
+ Therefore, if we know that our get USB drive mass, it may not return a desert object.
276
+
277
+ 70
278
+ 00:05:00,000 --> 00:05:02,000
279
+ We can change message, return type.
280
+
281
+ 71
282
+ 00:05:02,000 --> 00:05:10,000
283
+ Let me open solution class now in this class, you can see is that get USB drive message from my computer
284
+
285
+ 72
286
+ 00:05:10,000 --> 00:05:12,000
287
+ class, has the friends or Chen typed now?
288
+
289
+ 73
290
+ 00:05:13,000 --> 00:05:16,000
291
+ It is optional parametrized by the USB drive.
292
+
293
+ 74
294
+ 00:05:17,000 --> 00:05:18,000
295
+ And then my USB drive.
296
+
297
+ 75
298
+ 00:05:18,000 --> 00:05:20,000
299
+ I have also updated through Chintan.
300
+
301
+ 76
302
+ 00:05:21,000 --> 00:05:28,000
303
+ Now, is this is optional that this parametrized by rights protects, which did not pay a lot of attention
304
+
305
+ 77
306
+ 00:05:28,000 --> 00:05:35,000
307
+ to the details at this moment, namely how we create objects of optional type, why I use this method
308
+
309
+ 78
310
+ 00:05:35,000 --> 00:05:36,000
311
+ and didn't use another one.
312
+
313
+ 79
314
+ 00:05:36,000 --> 00:05:41,000
315
+ We're going to learn optional gloss in a minute was detailed examples.
316
+
317
+ 80
318
+ 00:05:41,000 --> 00:05:46,000
319
+ Now, I'd like you to understand the idea of problem and our solution.
320
+
321
+ 81
322
+ 00:05:46,000 --> 00:05:53,000
323
+ In my main mass, you can see that I use features of optional class and they check whether some value
324
+
325
+ 82
326
+ 00:05:53,000 --> 00:05:55,000
327
+ is present in my USB drive wrapper.
328
+
329
+ 83
330
+ 00:05:56,000 --> 00:06:01,000
331
+ And this present I execute functions that takes USB drive as my argument.
332
+
333
+ 84
334
+ 00:06:02,000 --> 00:06:06,000
335
+ Namely, I'm getting access to the switch, which is also optional.
336
+
337
+ 85
338
+ 00:06:06,000 --> 00:06:11,000
339
+ And in case it is present, I just print switches state to console.
340
+
341
+ 86
342
+ 00:06:12,000 --> 00:06:14,000
343
+ And if no, then nothing.
344
+
345
+ 87
346
+ 00:06:14,000 --> 00:06:20,000
347
+ And in case there is no USB drive object inside the wrapper, I execute another function.
348
+
349
+ 88
350
+ 00:06:20,000 --> 00:06:22,000
351
+ I just print to console.
352
+
353
+ 89
354
+ 00:06:22,000 --> 00:06:24,000
355
+ That USB drive wasn't found.
356
+
357
+ 90
358
+ 00:06:24,000 --> 00:06:30,000
359
+ As you can see on this example, optional is a similar to the wrapper that may or may not contains the
360
+
361
+ 91
362
+ 00:06:30,000 --> 00:06:33,000
363
+ actual value inside itself.
364
+
365
+ 92
366
+ 00:06:33,000 --> 00:06:40,000
367
+ In simple words, you can view optional as a single value container that is a contains a value of doesn't.
368
+
369
+ 93
370
+ 00:06:41,000 --> 00:06:44,000
371
+ It isn't set to be empty fullerenes.
372
+
373
+ 94
374
+ 00:06:44,000 --> 00:06:49,000
375
+ This construction, you make clients responsible to handle messy value.
376
+
377
+ 95
378
+ 00:06:49,000 --> 00:06:51,000
379
+ You're just walking.
380
+
381
+ 96
382
+ 00:06:51,000 --> 00:06:56,000
383
+ That value here may not be present and you decide what you want to do.
384
+
385
+ 97
386
+ 00:06:56,000 --> 00:07:04,000
387
+ In this case, this client's responsible approach means that creators and Massart is not in the position
388
+
389
+ 98
390
+ 00:07:04,000 --> 00:07:07,000
391
+ to define what should be done in case of missing value.
392
+
393
+ 99
394
+ 00:07:08,000 --> 00:07:12,000
395
+ Is a sink is to throw exception Maseru an exception?
396
+
397
+ 100
398
+ 00:07:12,000 --> 00:07:17,000
399
+ Probably not always the best case and proper behavior according to the business logic in the case of
400
+
401
+ 101
402
+ 00:07:17,000 --> 00:07:18,000
403
+ missing value.
404
+
405
+ 102
406
+ 00:07:19,000 --> 00:07:23,000
407
+ Now, I wonder, you look at this example with fresh eyes.
408
+
409
+ 103
410
+ 00:07:23,000 --> 00:07:29,000
411
+ If Java community and software engineers would like to call this more readable code and simple if URL
412
+
413
+ 104
414
+ 00:07:29,000 --> 00:07:32,000
415
+ statement, I am happy to accept it.
416
+
417
+ 105
418
+ 00:07:32,000 --> 00:07:36,000
419
+ Really, guys, I just want to we don't lie to ourselves.
420
+
421
+ 106
422
+ 00:07:36,000 --> 00:07:43,000
423
+ What we have, instead of if as blogs with a few lambda expressions that are also located inside each
424
+
425
+ 107
426
+ 00:07:43,000 --> 00:07:43,000
427
+ other.
428
+
429
+ 108
430
+ 00:07:43,000 --> 00:07:50,000
431
+ And moreover, all our mass is written optional now, and we can't just take value and work with it
432
+
433
+ 109
434
+ 00:07:50,000 --> 00:07:50,000
435
+ in order.
436
+
437
+ 110
438
+ 00:07:50,000 --> 00:07:52,000
439
+ We could avoid no point exception.
440
+
441
+ 111
442
+ 00:07:52,000 --> 00:07:56,000
443
+ Well, definitely optional is a very powerful tool.
444
+
445
+ 112
446
+ 00:07:56,000 --> 00:08:00,000
447
+ But guys, I can't see what we have want in this case.
448
+
449
+ 113
450
+ 00:08:01,000 --> 00:08:06,000
451
+ There are multiple other features in optional that breena's amazing flexibility.
452
+
453
+ 114
454
+ 00:08:06,000 --> 00:08:11,000
455
+ And let us write less lines of code with optional than without it.
456
+
457
+ 115
458
+ 00:08:12,000 --> 00:08:12,000
459
+ That is true.
460
+
461
+ 116
462
+ 00:08:13,000 --> 00:08:20,000
463
+ But again, it should be also a special case to apply those features of optional is a true story from
464
+
465
+ 117
466
+ 00:08:20,000 --> 00:08:26,000
467
+ my life is one developer from my team created few classes, was all massive rechanneled, optional type
468
+
469
+ 118
470
+ 00:08:26,000 --> 00:08:28,000
471
+ parameterized by other types.
472
+
473
+ 119
474
+ 00:08:28,000 --> 00:08:31,000
475
+ I asked him, why would you do that?
476
+
477
+ 120
478
+ 00:08:31,000 --> 00:08:37,000
479
+ And he replied, because we need to use optional everywhere where we may receive no.
480
+
481
+ 121
482
+ 00:08:37,000 --> 00:08:39,000
483
+ Well, guess not everywhere.
484
+
485
+ 122
486
+ 00:08:39,000 --> 00:08:41,000
487
+ And then again, use an optional everywhere.
488
+
489
+ 123
490
+ 00:08:42,000 --> 00:08:46,000
491
+ Wouldn't agree with us for the better with the abilities that we are so struggling for.
492
+
493
+ 124
494
+ 00:08:46,000 --> 00:08:54,000
495
+ So let's not API optional to better understand its power and understand, jaysus, when and where this
496
+
497
+ 125
498
+ 00:08:54,000 --> 00:08:54,000
499
+ might be applicable.
500
+
501
+ 126
502
+ 00:08:55,000 --> 00:08:59,000
503
+ I open optional demo class with a lot of examples here.
504
+
505
+ 127
506
+ 00:08:59,000 --> 00:09:01,000
507
+ Let me walk you through each example.
508
+
509
+ 128
510
+ 00:09:01,000 --> 00:09:09,000
511
+ Seeing the first ones that we are going to review is how to create an object of optional type in most
512
+
513
+ 129
514
+ 00:09:09,000 --> 00:09:15,000
515
+ of the cases to create object of type optional when it is static, factor in masses, optional class.
516
+
517
+ 130
518
+ 00:09:16,000 --> 00:09:19,000
519
+ The first way to create optional is to call static mass of empty.
520
+
521
+ 131
522
+ 00:09:20,000 --> 00:09:22,000
523
+ This is our chance imta optional.
524
+
525
+ 132
526
+ 00:09:22,000 --> 00:09:28,000
527
+ The empty mass is often used when it is known apro or is at no value exists.
528
+
529
+ 133
530
+ 00:09:28,000 --> 00:09:35,000
531
+ If you have some value and you need to create optional call, static method of attention, you need
532
+
533
+ 134
534
+ 00:09:35,000 --> 00:09:42,000
535
+ to have that object behind's a reference that you are going to use to create optional object was of
536
+
537
+ 135
538
+ 00:09:42,000 --> 00:09:49,000
539
+ mass, because in case you pass no value to the of method, you will get no point exception.
540
+
541
+ 136
542
+ 00:09:49,000 --> 00:09:55,000
543
+ In the case, you know its value behind the reference, Megan, now or may not be now, use another
544
+
545
+ 137
546
+ 00:09:55,000 --> 00:09:57,000
547
+ method of nullable.
548
+
549
+ 138
550
+ 00:09:58,000 --> 00:10:02,000
551
+ This will create optional object based on the no and no not.
552
+
553
+ 139
554
+ 00:10:02,000 --> 00:10:09,000
555
+ Various for example, in previous example, in solution, I used of nullable factor in mass because
556
+
557
+ 140
558
+ 00:10:09,000 --> 00:10:14,000
559
+ I knew that I may need to create optional object based on value.
560
+
561
+ 141
562
+ 00:10:15,000 --> 00:10:22,000
563
+ Now let's review methods that allow us to check if value is present or absent, that the masses that
564
+
565
+ 142
566
+ 00:10:22,000 --> 00:10:27,000
567
+ allow us to check the value inside the optional is present and is empty.
568
+
569
+ 143
570
+ 00:10:28,000 --> 00:10:31,000
571
+ Obviously, these masses are controversial.
572
+
573
+ 144
574
+ 00:10:31,000 --> 00:10:37,000
575
+ One is present, returns true, is empty, returns false, and vice versa.
576
+
577
+ 145
578
+ 00:10:37,000 --> 00:10:38,000
579
+ Here's an example.
580
+
581
+ 146
582
+ 00:10:38,000 --> 00:10:46,000
583
+ You can see that I have destry quail and check was an optional is empty or has value and is a similar
584
+
585
+ 147
586
+ 00:10:46,000 --> 00:10:48,000
587
+ test for optional that contains Nassan.
588
+
589
+ 148
590
+ 00:10:49,000 --> 00:10:53,000
591
+ As a result of method execution, you confront and conceal output.
592
+
593
+ 149
594
+ 00:10:54,000 --> 00:10:56,000
595
+ Now let's review example of conditional masses.
596
+
597
+ 150
598
+ 00:10:57,000 --> 00:11:03,000
599
+ I call these methods conditional because based on the specific condition, API allows us to perform
600
+
601
+ 151
602
+ 00:11:03,000 --> 00:11:05,000
603
+ one or another action.
604
+
605
+ 152
606
+ 00:11:06,000 --> 00:11:12,000
607
+ The first method in this example, if present you already you saw me using this method in the example
608
+
609
+ 153
610
+ 00:11:12,000 --> 00:11:18,000
611
+ in solution was use B drive F presence method takes consumer as method argument.
612
+
613
+ 154
614
+ 00:11:19,000 --> 00:11:25,000
615
+ If you're not familiar with lambda expressions and such function interfaces as consumer, I recommend
616
+
617
+ 155
618
+ 00:11:25,000 --> 00:11:26,000
619
+ you to pass my course.
620
+
621
+ 156
622
+ 00:11:26,000 --> 00:11:29,000
623
+ Guanciale programming for Giwa Engineers.
624
+
625
+ 157
626
+ 00:11:29,000 --> 00:11:32,000
627
+ I explained these topics in detail zere.
628
+
629
+ 158
630
+ 00:11:32,000 --> 00:11:37,000
631
+ Just to remind you, consumer takes some argument and returns nothing.
632
+
633
+ 159
634
+ 00:11:37,000 --> 00:11:41,000
635
+ So basically, if the value is present, we pass it.
636
+
637
+ 160
638
+ 00:11:41,000 --> 00:11:44,000
639
+ Does it function and perform any action?
640
+
641
+ 161
642
+ 00:11:44,000 --> 00:11:44,000
643
+ Was it.
644
+
645
+ 162
646
+ 00:11:44,000 --> 00:11:47,000
647
+ What we need in this particular example.
648
+
649
+ 163
650
+ 00:11:47,000 --> 00:11:51,000
651
+ I just printed to console in case there is no value in optional.
652
+
653
+ 164
654
+ 00:11:51,000 --> 00:11:55,000
655
+ We just ignore this function and just do nothing.
656
+
657
+ 165
658
+ 00:11:55,000 --> 00:11:59,000
659
+ Another conditional Massart is if present or else.
660
+
661
+ 166
662
+ 00:11:59,000 --> 00:12:03,000
663
+ I also use this one in solution of the examples that I have already showed.
664
+
665
+ 167
666
+ 00:12:03,000 --> 00:12:09,000
667
+ I believe that from the massive name, it is already clear for you what is this method for.
668
+
669
+ 168
670
+ 00:12:09,000 --> 00:12:14,000
671
+ So in case value is present, will use consumer and will work with the value.
672
+
673
+ 169
674
+ 00:12:15,000 --> 00:12:22,000
675
+ In the case, value is absent, will execute some random that contains lines of code to be executed.
676
+
677
+ 170
678
+ 00:12:22,000 --> 00:12:24,000
679
+ In case there is no value.
680
+
681
+ 171
682
+ 00:12:24,000 --> 00:12:28,000
683
+ The next example is simple and regular gets massive.
684
+
685
+ 172
686
+ 00:12:28,000 --> 00:12:34,000
687
+ You can extract value from optional Bikel and get mass, but be attentive.
688
+
689
+ 173
690
+ 00:12:34,000 --> 00:12:38,000
691
+ In case there is no value, you will get no such element.
692
+
693
+ 174
694
+ 00:12:38,000 --> 00:12:38,000
695
+ The exception.
696
+
697
+ 175
698
+ 00:12:39,000 --> 00:12:43,000
699
+ And here, in example, you can see this just in case optional is empty.
700
+
701
+ 176
702
+ 00:12:43,000 --> 00:12:45,000
703
+ We are catching exception.
704
+
705
+ 177
706
+ 00:12:45,000 --> 00:12:49,000
707
+ In practice, it is recommended to use is present.
708
+
709
+ 178
710
+ 00:12:49,000 --> 00:12:53,000
711
+ Massett, that guarantees that there is a value inside optional.
712
+
713
+ 179
714
+ 00:12:53,000 --> 00:12:55,000
715
+ So just remember this.
716
+
717
+ 180
718
+ 00:12:56,000 --> 00:12:58,000
719
+ Let's imagine that we are using is present Massart.
720
+
721
+ 181
722
+ 00:12:58,000 --> 00:12:59,000
723
+ OK.
724
+
725
+ 182
726
+ 00:12:59,000 --> 00:13:01,000
727
+ Just look at this example.
728
+
729
+ 183
730
+ 00:13:01,000 --> 00:13:09,000
731
+ How far it is from no check from our problem statement was if we again have the similar Evelio.
732
+
733
+ 184
734
+ 00:13:09,000 --> 00:13:16,000
735
+ That's why in most cases we intentionally award to use the get Masset and use one of the other methods.
736
+
737
+ 185
738
+ 00:13:16,000 --> 00:13:17,000
739
+ Such as.
740
+
741
+ 186
742
+ 00:13:17,000 --> 00:13:23,000
743
+ Or else or else through top things of value associated with a populated, optional.
744
+
745
+ 187
746
+ 00:13:24,000 --> 00:13:25,000
747
+ Or perform another action.
748
+
749
+ 188
750
+ 00:13:25,000 --> 00:13:30,000
751
+ Let me show you this in the next example, you can see how to use or else mass.
752
+
753
+ 189
754
+ 00:13:31,000 --> 00:13:36,000
755
+ Basically, it returns a value if at this present and in case it does not.
756
+
757
+ 190
758
+ 00:13:36,000 --> 00:13:39,000
759
+ It returns the values that they passed as a message.
760
+
761
+ 191
762
+ 00:13:39,000 --> 00:13:41,000
763
+ Also, we have or else get method.
764
+
765
+ 192
766
+ 00:13:42,000 --> 00:13:45,000
767
+ What is the difference between orals and this?
768
+
769
+ 193
770
+ 00:13:45,000 --> 00:13:48,000
771
+ Massively different parameters oils.
772
+
773
+ 194
774
+ 00:13:48,000 --> 00:13:51,000
775
+ Yet they supply as methods argument.
776
+
777
+ 195
778
+ 00:13:51,000 --> 00:13:54,000
779
+ Supply is a function that produce something.
780
+
781
+ 196
782
+ 00:13:54,000 --> 00:13:57,000
783
+ It takes nothing and returns some value.
784
+
785
+ 197
786
+ 00:13:57,000 --> 00:13:59,000
787
+ And what does it give us?
788
+
789
+ 198
790
+ 00:14:00,000 --> 00:14:03,000
791
+ Well, probably it is not obvious in this particular example.
792
+
793
+ 199
794
+ 00:14:04,000 --> 00:14:06,000
795
+ But let's look at the next lines.
796
+
797
+ 200
798
+ 00:14:07,000 --> 00:14:14,000
799
+ Imagine that you have some massive that performs a lot of work and calculations and as a result, recharges
800
+
801
+ 201
802
+ 00:14:14,000 --> 00:14:19,000
803
+ your reference to string value and then use your call or else Massett.
804
+
805
+ 202
806
+ 00:14:19,000 --> 00:14:26,000
807
+ And you would like to parse the string returned by these massive PZM Massett is actually involved.
808
+
809
+ 203
810
+ 00:14:27,000 --> 00:14:31,000
811
+ And you spent some time to wait until the mass of the got finished.
812
+
813
+ 204
814
+ 00:14:32,000 --> 00:14:35,000
815
+ But is it the same with or else get method?
816
+
817
+ 205
818
+ 00:14:35,000 --> 00:14:36,000
819
+ No.
820
+
821
+ 206
822
+ 00:14:36,000 --> 00:14:45,000
823
+ Lukins this line you're actually not invoking is a massive you just Parsons's reference to the function
824
+
825
+ 207
826
+ 00:14:45,000 --> 00:14:48,000
827
+ that knows how to get the value for you.
828
+
829
+ 208
830
+ 00:14:48,000 --> 00:14:50,000
831
+ In case this is needed.
832
+
833
+ 209
834
+ 00:14:51,000 --> 00:14:52,000
835
+ This is the main difference.
836
+
837
+ 210
838
+ 00:14:53,000 --> 00:15:00,000
839
+ Lasing insolate Zeeshan in the first case we're invoking Massart no matter was an optional has a value
840
+
841
+ 211
842
+ 00:15:00,000 --> 00:15:00,000
843
+ on.
844
+
845
+ 212
846
+ 00:15:00,000 --> 00:15:00,000
847
+ No.
848
+
849
+ 213
850
+ 00:15:01,000 --> 00:15:01,000
851
+ And in.
852
+
853
+ 214
854
+ 00:15:01,000 --> 00:15:08,000
855
+ The second case would just use functions that knows how to provide us with value only when it is needed,
856
+
857
+ 215
858
+ 00:15:09,000 --> 00:15:11,000
859
+ only when optional has no value.
860
+
861
+ 216
862
+ 00:15:12,000 --> 00:15:18,000
863
+ Does it make sense now in case the value is absent and you want to throw an exception.
864
+
865
+ 217
866
+ 00:15:18,000 --> 00:15:20,000
867
+ You can use or else throw massive.
868
+
869
+ 218
870
+ 00:15:21,000 --> 00:15:23,000
871
+ This method is overloaded.
872
+
873
+ 219
874
+ 00:15:23,000 --> 00:15:26,000
875
+ The version without arguments will throw no such element.
876
+
877
+ 220
878
+ 00:15:26,000 --> 00:15:28,000
879
+ The exception by default.
880
+
881
+ 221
882
+ 00:15:28,000 --> 00:15:35,000
883
+ Or you can post supplier as Mussert argument to generate object of the exception that you would like
884
+
885
+ 222
886
+ 00:15:35,000 --> 00:15:35,000
887
+ to throw.
888
+
889
+ 223
890
+ 00:15:36,000 --> 00:15:38,000
891
+ Now let's somehow filter Massart works.
892
+
893
+ 224
894
+ 00:15:39,000 --> 00:15:45,000
895
+ In case you have the reference to the optional object, you can check it first to understand whether
896
+
897
+ 225
898
+ 00:15:45,000 --> 00:15:46,000
899
+ it is much your predicate.
900
+
901
+ 226
902
+ 00:15:47,000 --> 00:15:52,000
903
+ And in case verification this past, you receive optional was that value.
904
+
905
+ 227
906
+ 00:15:52,000 --> 00:15:55,000
907
+ Otherwise, you receive empty optional.
908
+
909
+ 228
910
+ 00:15:55,000 --> 00:15:57,000
911
+ Let me explain this example.
912
+
913
+ 229
914
+ 00:15:57,000 --> 00:16:01,000
915
+ Imagine that I have optional that contains my full name.
916
+
917
+ 230
918
+ 00:16:01,000 --> 00:16:07,000
919
+ After that, I can call Filton Masset on the optional object and pass predicate.
920
+
921
+ 231
922
+ 00:16:07,000 --> 00:16:10,000
923
+ Let me quickly remind you what Prickett is.
924
+
925
+ 232
926
+ 00:16:11,000 --> 00:16:14,000
927
+ CreditCard is a functional interface that declares one.
928
+
929
+ 233
930
+ 00:16:14,000 --> 00:16:15,000
931
+ Massart is.
932
+
933
+ 234
934
+ 00:16:15,000 --> 00:16:19,000
935
+ It takes one argument and the returns is a true or false.
936
+
937
+ 235
938
+ 00:16:19,000 --> 00:16:21,000
939
+ So here is my function.
940
+
941
+ 236
942
+ 00:16:21,000 --> 00:16:25,000
943
+ I pass full name and I check whether it contains Andry.
944
+
945
+ 237
946
+ 00:16:25,000 --> 00:16:33,000
947
+ If yes, then I receive optional with this name when I call, or else I get the reference to my whole
948
+
949
+ 238
950
+ 00:16:33,000 --> 00:16:36,000
951
+ name and bring that to console in a similar example.
952
+
953
+ 239
954
+ 00:16:36,000 --> 00:16:39,000
955
+ But with a different name, I will get give empty optional.
956
+
957
+ 240
958
+ 00:16:40,000 --> 00:16:46,000
959
+ And you can charge this by console output in the second case paren to console the false string that
960
+
961
+ 241
962
+ 00:16:46,000 --> 00:16:48,000
963
+ they used in or else methods.
964
+
965
+ 242
966
+ 00:16:48,000 --> 00:16:56,000
967
+ Do you understand why we may need to field the method that is normally used to reject wrapt values based
968
+
969
+ 243
970
+ 00:16:56,000 --> 00:16:57,000
971
+ on the predefined tool?
972
+
973
+ 244
974
+ 00:16:58,000 --> 00:17:04,000
975
+ Imagine now in another case we have a user object, and we need to make sure that the users that we
976
+
977
+ 245
978
+ 00:17:04,000 --> 00:17:11,000
979
+ received from database or from another method has Mercier's less than one number than the more than
980
+
981
+ 246
982
+ 00:17:11,000 --> 00:17:12,000
983
+ another number.
984
+
985
+ 247
986
+ 00:17:13,000 --> 00:17:14,000
987
+ How to do that?
988
+
989
+ 248
990
+ 00:17:14,000 --> 00:17:22,000
991
+ We can use map mass simply to convert the rabbit value to another type, Zimet, Mass, that allows
992
+
993
+ 249
994
+ 00:17:22,000 --> 00:17:26,000
995
+ us to convert the value from one object to another.
996
+
997
+ 250
998
+ 00:17:26,000 --> 00:17:33,000
999
+ If an optional is populated, this method can be thought of as a pipeline method, whereas the rabbit
1000
+
1001
+ 251
1002
+ 00:17:33,000 --> 00:17:37,000
1003
+ value is passed along the pipeline and transform.
1004
+
1005
+ 252
1006
+ 00:17:37,000 --> 00:17:41,000
1007
+ Can you value the remember how Stream API works?
1008
+
1009
+ 253
1010
+ 00:17:42,000 --> 00:17:43,000
1011
+ This similar concept is here.
1012
+
1013
+ 254
1014
+ 00:17:44,000 --> 00:17:50,000
1015
+ This method works by accepting the function object as it is applied to the rabbit value to produce the
1016
+
1017
+ 255
1018
+ 00:17:50,000 --> 00:17:51,000
1019
+ mapped value.
1020
+
1021
+ 256
1022
+ 00:17:52,000 --> 00:17:58,000
1023
+ Even the optional is empty, is a function object is never called, and an empty optional is returned
1024
+
1025
+ 257
1026
+ 00:17:58,000 --> 00:18:00,000
1027
+ from the map massively.
1028
+
1029
+ 258
1030
+ 00:18:00,000 --> 00:18:02,000
1031
+ Let me explain your own example.
1032
+
1033
+ 259
1034
+ 00:18:02,000 --> 00:18:05,000
1035
+ I have optional parametrized by type user.
1036
+
1037
+ 260
1038
+ 00:18:05,000 --> 00:18:07,000
1039
+ I have arrived here.
1040
+
1041
+ 261
1042
+ 00:18:07,000 --> 00:18:08,000
1043
+ User object.
1044
+
1045
+ 262
1046
+ 00:18:08,000 --> 00:18:14,000
1047
+ This user has named Igor and his universe is 1990s.
1048
+
1049
+ 263
1050
+ 00:18:14,000 --> 00:18:21,000
1051
+ I call map Massart on my optional object to convert data in the pipeline from user to an end.
1052
+
1053
+ 264
1054
+ 00:18:22,000 --> 00:18:27,000
1055
+ I need to pass functions that knows how to transform the current type thing.
1056
+
1057
+ 265
1058
+ 00:18:28,000 --> 00:18:35,000
1059
+ And when I have int value in pipeline, I can use filter mass to check was a year of birth of the current
1060
+
1061
+ 266
1062
+ 00:18:35,000 --> 00:18:38,000
1063
+ user is within the expected range.
1064
+
1065
+ 267
1066
+ 00:18:38,000 --> 00:18:44,000
1067
+ In this case, my user matches the current filters and optional was very is returned.
1068
+
1069
+ 268
1070
+ 00:18:45,000 --> 00:18:49,000
1071
+ That's why I can print the user's Berthier tokens.
1072
+
1073
+ 269
1074
+ 00:18:49,000 --> 00:18:55,000
1075
+ So what does this example please let me know in case you have any questions in case something is still
1076
+
1077
+ 270
1078
+ 00:18:55,000 --> 00:18:56,000
1079
+ unclear.
1080
+
1081
+ 271
1082
+ 00:18:56,000 --> 00:18:57,000
1083
+ Please.
1084
+
1085
+ 272
1086
+ 00:18:57,000 --> 00:18:59,000
1087
+ What's your question below this video?
1088
+
1089
+ 273
1090
+ 00:18:59,000 --> 00:19:02,000
1091
+ And there will be happy to answer it.
1092
+
1093
+ 274
1094
+ 00:19:02,000 --> 00:19:06,000
1095
+ Let's review another method that is similar to those in Map Mass.
1096
+
1097
+ 275
1098
+ 00:19:06,000 --> 00:19:11,000
1099
+ Let's have the flat map Masset as an alternative for values transformation.
1100
+
1101
+ 276
1102
+ 00:19:12,000 --> 00:19:15,000
1103
+ There is one main difference between these two masses.
1104
+
1105
+ 277
1106
+ 00:19:15,000 --> 00:19:21,000
1107
+ The difference is that map transforms values only when Xe unwrap.
1108
+
1109
+ 278
1110
+ 00:19:21,000 --> 00:19:27,000
1111
+ Whereas flat map takes a wrapped value and unwraps it before transforming it.
1112
+
1113
+ 279
1114
+ 00:19:28,000 --> 00:19:32,000
1115
+ Let's make sure that you understood this following Z example.
1116
+
1117
+ 280
1118
+ 00:19:32,000 --> 00:19:41,000
1119
+ So imagine that we keep working with the same user, but interested in sync in a mass returns, optional
1120
+
1121
+ 281
1122
+ 00:19:41,000 --> 00:19:45,000
1123
+ to, for example, get name Massart, which is optional.
1124
+
1125
+ 282
1126
+ 00:19:45,000 --> 00:19:47,000
1127
+ It is parametrized by string.
1128
+
1129
+ 283
1130
+ 00:19:48,000 --> 00:19:48,000
1131
+ No.
1132
+
1133
+ 284
1134
+ 00:19:48,000 --> 00:19:54,000
1135
+ And all what we know that's extracted from the optional parameterized by type user.
1136
+
1137
+ 285
1138
+ 00:19:55,000 --> 00:20:00,000
1139
+ The first thing that I do, I want to convert optional of user to the just name.
1140
+
1141
+ 286
1142
+ 00:20:00,000 --> 00:20:01,000
1143
+ What I got instead.
1144
+
1145
+ 287
1146
+ 00:20:02,000 --> 00:20:07,000
1147
+ Instead, I got optional parameterized by optional the disbursements surprised by string.
1148
+
1149
+ 288
1150
+ 00:20:07,000 --> 00:20:11,000
1151
+ That is because my get name Masset returns optional.
1152
+
1153
+ 289
1154
+ 00:20:11,000 --> 00:20:16,000
1155
+ Having this wrapper, I can extract optional parameterized by a string.
1156
+
1157
+ 290
1158
+ 00:20:17,000 --> 00:20:22,000
1159
+ It should contain the name of the user, and only after that I can extract user.
1160
+
1161
+ 291
1162
+ 00:20:23,000 --> 00:20:30,000
1163
+ Don't you think that they added a lot of redundant steps similar to the Stream API from Jaedicke?
1164
+
1165
+ 292
1166
+ 00:20:30,000 --> 00:20:35,000
1167
+ So that map doesn't rabs the value was additional optional.
1168
+
1169
+ 293
1170
+ 00:20:35,000 --> 00:20:42,000
1171
+ So to achieve the same goal in a little bit simpler way is to call threads, map and parse the references
1172
+
1173
+ 294
1174
+ 00:20:42,000 --> 00:20:43,000
1175
+ to get name message.
1176
+
1177
+ 295
1178
+ 00:20:44,000 --> 00:20:49,000
1179
+ And now I can apply Ozz masses to extract value like or message.
1180
+
1181
+ 296
1182
+ 00:20:50,000 --> 00:20:54,000
1183
+ And in console, you can see that the results are the same.
1184
+
1185
+ 297
1186
+ 00:20:54,000 --> 00:20:59,000
1187
+ But the second option, Dukas, less lines of code to achieve is the same result.
1188
+
1189
+ 298
1190
+ 00:20:59,000 --> 00:21:00,000
1191
+ Does it make sense?
1192
+
1193
+ 299
1194
+ 00:21:01,000 --> 00:21:08,000
1195
+ In my opinion, we have removed all the most important masses from optional API that might come in handy.
1196
+
1197
+ 300
1198
+ 00:21:08,000 --> 00:21:15,000
1199
+ But any way opens a source code of GMU to optional class by yourself and investigated.
1200
+
1201
+ 301
1202
+ 00:21:15,000 --> 00:21:21,000
1203
+ Now let's discuss when and how to use optional to make sure it is not dangerous and you don't bring
1204
+
1205
+ 302
1206
+ 00:21:21,000 --> 00:21:23,000
1207
+ more harm than good.
1208
+
1209
+ 303
1210
+ 00:21:24,000 --> 00:21:27,000
1211
+ Let's review different parts of our program and different use cases.
1212
+
1213
+ 304
1214
+ 00:21:28,000 --> 00:21:30,000
1215
+ And I will give you my advice.
1216
+
1217
+ 305
1218
+ 00:21:30,000 --> 00:21:31,000
1219
+ Return values.
1220
+
1221
+ 306
1222
+ 00:21:32,000 --> 00:21:35,000
1223
+ Often optionals are well suited for a chance values.
1224
+
1225
+ 307
1226
+ 00:21:36,000 --> 00:21:43,000
1227
+ Originally, this was intended to be zem main use case in documentation that we can find.
1228
+
1229
+ 308
1230
+ 00:21:43,000 --> 00:21:44,000
1231
+ Is it optional?
1232
+
1233
+ 309
1234
+ 00:21:44,000 --> 00:21:52,000
1235
+ Type is primarily intended for use as a message, Chantae, where there is a growing need to represent
1236
+
1237
+ 310
1238
+ 00:21:52,000 --> 00:21:53,000
1239
+ no result.
1240
+
1241
+ 311
1242
+ 00:21:53,000 --> 00:21:57,000
1243
+ And we're using now is likely to cause errors.
1244
+
1245
+ 312
1246
+ 00:21:57,000 --> 00:22:04,000
1247
+ And here I'd like to pay you extra attention in order you wouldn't follow code style of colleague of
1248
+
1249
+ 313
1250
+ 00:22:04,000 --> 00:22:08,000
1251
+ mine who has all methods developed this optional type return.
1252
+
1253
+ 314
1254
+ 00:22:09,000 --> 00:22:16,000
1255
+ You should return optional as of this set where there is a clear need to represent no result.
1256
+
1257
+ 315
1258
+ 00:22:17,000 --> 00:22:22,000
1259
+ And we're using now is likely to cause errors, not everywhere.
1260
+
1261
+ 316
1262
+ 00:22:23,000 --> 00:22:27,000
1263
+ But still, this recommendation leaves error for interpretations.
1264
+
1265
+ 317
1266
+ 00:22:27,000 --> 00:22:30,000
1267
+ I would also add one more important thing to consider.
1268
+
1269
+ 318
1270
+ 00:22:31,000 --> 00:22:38,000
1271
+ Use optional only in cases when you want to make client of your code responsible for handling of absent
1272
+
1273
+ 319
1274
+ 00:22:38,000 --> 00:22:39,000
1275
+ value.
1276
+
1277
+ 320
1278
+ 00:22:39,000 --> 00:22:43,000
1279
+ And this is really a good reason not to put optional the chandab everywhere.
1280
+
1281
+ 321
1282
+ 00:22:44,000 --> 00:22:44,000
1283
+ Why?
1284
+
1285
+ 322
1286
+ 00:22:45,000 --> 00:22:52,000
1287
+ Because in most cases, we need to provide ready to use API, but not make our clients seeing about
1288
+
1289
+ 323
1290
+ 00:22:52,000 --> 00:22:58,000
1291
+ each return value, what to do in case value wasn't returned regarding the fields.
1292
+
1293
+ 324
1294
+ 00:22:59,000 --> 00:23:00,000
1295
+ Let me put it simple.
1296
+
1297
+ 325
1298
+ 00:23:00,000 --> 00:23:04,000
1299
+ You can create fields of optional type, but you shouldn't.
1300
+
1301
+ 326
1302
+ 00:23:04,000 --> 00:23:05,000
1303
+ Why?
1304
+
1305
+ 327
1306
+ 00:23:05,000 --> 00:23:08,000
1307
+ For me, it is a sign of a bad architecture.
1308
+
1309
+ 328
1310
+ 00:23:08,000 --> 00:23:13,000
1311
+ You have fields known from the beginning that they may not be initialized.
1312
+
1313
+ 329
1314
+ 00:23:13,000 --> 00:23:20,000
1315
+ But in this case, you have met Iraqui and that or the architecture was not implemented.
1316
+
1317
+ 330
1318
+ 00:23:20,000 --> 00:23:21,000
1319
+ Solid principles.
1320
+
1321
+ 331
1322
+ 00:23:21,000 --> 00:23:27,000
1323
+ Probably there are some classes that don't need all these fields, and it is just a matter of building
1324
+
1325
+ 332
1326
+ 00:23:27,000 --> 00:23:29,000
1327
+ of proper Iraqui.
1328
+
1329
+ 333
1330
+ 00:23:29,000 --> 00:23:30,000
1331
+ A lot of questions.
1332
+
1333
+ 334
1334
+ 00:23:30,000 --> 00:23:36,000
1335
+ So I'll put it simple, the not to use optionals in fields parameters.
1336
+
1337
+ 335
1338
+ 00:23:36,000 --> 00:23:39,000
1339
+ You can use optional methods, parameters.
1340
+
1341
+ 336
1342
+ 00:23:39,000 --> 00:23:42,000
1343
+ But again, it is not recommended to do that.
1344
+
1345
+ 337
1346
+ 00:23:42,000 --> 00:23:45,000
1347
+ It is recommended instead to have law that.
1348
+
1349
+ 338
1350
+ 00:23:46,000 --> 00:23:53,000
1351
+ If you know that, you might need to invoke this method with no parameter or this empty optional, in
1352
+
1353
+ 339
1354
+ 00:23:53,000 --> 00:23:53,000
1355
+ other words.
1356
+
1357
+ 340
1358
+ 00:23:54,000 --> 00:23:57,000
1359
+ So just with mass, that takes no parameter.
1360
+
1361
+ 341
1362
+ 00:23:58,000 --> 00:24:04,000
1363
+ But you also can have our law that was the same name, but which takes parameter.
1364
+
1365
+ 342
1366
+ 00:24:04,000 --> 00:24:05,000
1367
+ Is that clear?
1368
+
1369
+ 343
1370
+ 00:24:05,000 --> 00:24:09,000
1371
+ Some students ask me what is alternative to use an optional.
1372
+
1373
+ 344
1374
+ 00:24:10,000 --> 00:24:15,000
1375
+ Well, the simplest alternative is to leave like our ancestors left.
1376
+
1377
+ 345
1378
+ 00:24:15,000 --> 00:24:19,000
1379
+ Just use no value and do not forget, put no checks.
1380
+
1381
+ 346
1382
+ 00:24:20,000 --> 00:24:23,000
1383
+ This is still the case in a lot of programs nowadays.
1384
+
1385
+ 347
1386
+ 00:24:23,000 --> 00:24:30,000
1387
+ Another alternative might be a sort of an exception if absence of the value really brigg's the way of
1388
+
1389
+ 348
1390
+ 00:24:30,000 --> 00:24:31,000
1391
+ your program execution.
1392
+
1393
+ 349
1394
+ 00:24:32,000 --> 00:24:37,000
1395
+ Then you need to be prepared to handle specific exception and to handle it properly.
1396
+
1397
+ 350
1398
+ 00:24:37,000 --> 00:24:42,000
1399
+ During the handling of this exception, you specify 70 fractions.
1400
+
1401
+ 351
1402
+ 00:24:42,000 --> 00:24:45,000
1403
+ What is needed to be done in case the value is absent?
1404
+
1405
+ 352
1406
+ 00:24:46,000 --> 00:24:48,000
1407
+ Almost a similar way you do with optional.
1408
+
1409
+ 353
1410
+ 00:24:49,000 --> 00:24:51,000
1411
+ And another alternative is no objects.
1412
+
1413
+ 354
1414
+ 00:24:51,000 --> 00:24:58,000
1415
+ You can create a time that has the same API, but it is empty inside and all my are error safe.
1416
+
1417
+ 355
1418
+ 00:24:59,000 --> 00:25:01,000
1419
+ And when it is seen, you just create.
1420
+
1421
+ 356
1422
+ 00:25:01,000 --> 00:25:07,000
1423
+ Instance of the empty object or just parcels, a reference to that empty constantly, for example,
1424
+
1425
+ 357
1426
+ 00:25:07,000 --> 00:25:10,000
1427
+ in collections, glossaries, empty, list constant.
1428
+
1429
+ 358
1430
+ 00:25:11,000 --> 00:25:14,000
1431
+ And instead of returning, no one least is expected.
1432
+
1433
+ 359
1434
+ 00:25:15,000 --> 00:25:16,000
1435
+ You can just return empty.
1436
+
1437
+ 360
1438
+ 00:25:16,000 --> 00:25:22,000
1439
+ These constant that will save you from no point exception remembers use of devices.
1440
+
1441
+ 361
1442
+ 00:25:23,000 --> 00:25:27,000
1443
+ They're years of experience and millions of dollars behind these advices.
1444
+
1445
+ 362
1446
+ 00:25:28,000 --> 00:25:31,000
1447
+ Let's recap what we have learned in this lesson.
1448
+
1449
+ 363
1450
+ 00:25:31,000 --> 00:25:32,000
1451
+ In this lesson we learned.
1452
+
1453
+ 364
1454
+ 00:25:33,000 --> 00:25:35,000
1455
+ Optional class API and its methods.
1456
+
1457
+ 365
1458
+ 00:25:36,000 --> 00:25:39,000
1459
+ It knows the purpose of the optional and when to use it.
1460
+
1461
+ 366
1462
+ 00:25:39,000 --> 00:25:46,000
1463
+ And at the end of the lesson, I also explained few alternative techniques to use instead of optional.
1464
+
1465
+ 367
1466
+ 00:25:46,000 --> 00:25:48,000
1467
+ That's all for this lesson.
1468
+
1469
+ 368
1470
+ 00:25:48,000 --> 00:25:49,000
1471
+ Thanks a lot for your attention.
1472
+
1473
+ 369
1474
+ 00:25:50,000 --> 00:25:52,000
1475
+ Have a great day and see you in the next lesson.
1476
+
31 - JDK API/003 Reactive Programming in Java Flow API, Reactive Streams_en.srt ADDED
@@ -0,0 +1,996 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:05,000 --> 00:00:11,000
3
+ Hello dear students, in this lesson we are going to learn what reactive programming is and how we can
4
+
5
+ 2
6
+ 00:00:11,000 --> 00:00:16,000
7
+ apply reactive programming practices using Java via flow API.
8
+
9
+ 3
10
+ 00:00:16,000 --> 00:00:20,000
11
+ We are going to start the lesson from learning general concepts.
12
+
13
+ 4
14
+ 00:00:20,000 --> 00:00:23,000
15
+ We'll learn what reactive programming approach is.
16
+
17
+ 5
18
+ 00:00:23,000 --> 00:00:29,000
19
+ We'll discuss what the most popular libraries for reactive programming in Java are.
20
+
21
+ 6
22
+ 00:00:29,000 --> 00:00:36,000
23
+ But in scope of this lesson, we will focus our attention on the flow API that is available in JDK for
24
+
25
+ 7
26
+ 00:00:36,000 --> 00:00:38,000
27
+ reactive programming.
28
+
29
+ 8
30
+ 00:00:38,000 --> 00:00:39,000
31
+ As we will go.
32
+
33
+ 9
34
+ 00:00:39,000 --> 00:00:45,000
35
+ We'll learn different terms like for example Backpressure aware concept.
36
+
37
+ 10
38
+ 00:00:45,000 --> 00:00:49,000
39
+ We'll learn key interfaces from flow API.
40
+
41
+ 11
42
+ 00:00:49,000 --> 00:00:51,000
43
+ Then we'll talk about use cases.
44
+
45
+ 12
46
+ 00:00:51,000 --> 00:00:57,000
47
+ And I will try to answer the question when it is recommended to use reactive programming approach.
48
+
49
+ 13
50
+ 00:00:57,000 --> 00:01:04,000
51
+ And at the end of the lesson we are going to review code examples in order to understand how reactive
52
+
53
+ 14
54
+ 00:01:04,000 --> 00:01:06,000
55
+ streams work on practice.
56
+
57
+ 15
58
+ 00:01:06,000 --> 00:01:08,000
59
+ Let's start our lesson.
60
+
61
+ 16
62
+ 00:01:09,000 --> 00:01:12,000
63
+ Let's start from learning of what reactive programming is.
64
+
65
+ 17
66
+ 00:01:13,000 --> 00:01:20,000
67
+ Reactive programming is a programming paradigm focused on handling asynchronous data streams and the
68
+
69
+ 18
70
+ 00:01:20,000 --> 00:01:22,000
71
+ propagation of changes.
72
+
73
+ 19
74
+ 00:01:22,000 --> 00:01:29,000
75
+ It provides a set of principles, patterns, and libraries that enable developers to build responsive
76
+
77
+ 20
78
+ 00:01:29,000 --> 00:01:36,000
79
+ and scalable systems, especially in the context of handling events, input output operations, and
80
+
81
+ 21
82
+ 00:01:36,000 --> 00:01:37,000
83
+ real time data.
84
+
85
+ 22
86
+ 00:01:38,000 --> 00:01:41,000
87
+ Let's review key characteristics of reactive programming.
88
+
89
+ 23
90
+ 00:01:41,000 --> 00:01:45,000
91
+ They include asynchronous and non-blocking.
92
+
93
+ 24
94
+ 00:01:46,000 --> 00:01:51,000
95
+ Reactive programming emphasizes asynchronous and non-blocking operations.
96
+
97
+ 25
98
+ 00:01:51,000 --> 00:01:58,000
99
+ It allows components to continue processing other tasks while waiting for asynchronous operations to
100
+
101
+ 26
102
+ 00:01:58,000 --> 00:02:02,000
103
+ complete, leading to more efficient resource utilization.
104
+
105
+ 27
106
+ 00:02:03,000 --> 00:02:04,000
107
+ Data streams.
108
+
109
+ 28
110
+ 00:02:04,000 --> 00:02:09,000
111
+ At the core of reactive programming is the concept of data streams.
112
+
113
+ 29
114
+ 00:02:09,000 --> 00:02:13,000
115
+ Sequences of events or values that occur over time.
116
+
117
+ 30
118
+ 00:02:13,000 --> 00:02:21,000
119
+ These streams can represent various types of data such as user inputs, sensor readings, or messages
120
+
121
+ 31
122
+ 00:02:21,000 --> 00:02:22,000
123
+ from a server.
124
+
125
+ 32
126
+ 00:02:23,000 --> 00:02:30,000
127
+ Event-driven reactive systems are often event driven, meaning they respond to events or changes in
128
+
129
+ 33
130
+ 00:02:30,000 --> 00:02:31,000
131
+ the system.
132
+
133
+ 34
134
+ 00:02:31,000 --> 00:02:37,000
135
+ Events can trigger reactions and the system adapts dynamically to these changes.
136
+
137
+ 35
138
+ 00:02:38,000 --> 00:02:39,000
139
+ Back pressure.
140
+
141
+ 36
142
+ 00:02:40,000 --> 00:02:43,000
143
+ Back pressure is a key concept in reactive programming.
144
+
145
+ 37
146
+ 00:02:43,000 --> 00:02:51,000
147
+ It refers to the ability of downstream component to signal its capacity to handle data to an upstream
148
+
149
+ 38
150
+ 00:02:51,000 --> 00:02:52,000
151
+ component.
152
+
153
+ 39
154
+ 00:02:52,000 --> 00:02:59,000
155
+ This helps prevent overwhelming the system with more data than it can process efficiently.
156
+
157
+ 40
158
+ 00:03:00,000 --> 00:03:02,000
159
+ Responsive and scalable.
160
+
161
+ 41
162
+ 00:03:02,000 --> 00:03:09,000
163
+ Reactive programming aims to create responsive applications that can handle varied workloads.
164
+
165
+ 42
166
+ 00:03:09,000 --> 00:03:17,000
167
+ By embracing asynchrony and scalability, reactive systems can efficiently adapt to changes in demand.
168
+
169
+ 43
170
+ 00:03:18,000 --> 00:03:20,000
171
+ Functional programming.
172
+
173
+ 44
174
+ 00:03:20,000 --> 00:03:25,000
175
+ Reactive programming often aligns with functional programming principles.
176
+
177
+ 45
178
+ 00:03:25,000 --> 00:03:33,000
179
+ It emphasizes immutability, pure functions, and the use of higher order functions, enabling developers
180
+
181
+ 46
182
+ 00:03:33,000 --> 00:03:36,000
183
+ to write more concise and maintainable code.
184
+
185
+ 47
186
+ 00:03:37,000 --> 00:03:39,000
187
+ Reactive extensions.
188
+
189
+ 48
190
+ 00:03:39,000 --> 00:03:47,000
191
+ Reactive extensions, often referred to as RCS, is a set of libraries that provide a uniform way to
192
+
193
+ 49
194
+ 00:03:47,000 --> 00:03:52,000
195
+ work with reactive programming concepts across multiple programming languages.
196
+
197
+ 50
198
+ 00:03:53,000 --> 00:03:58,000
199
+ RCS libraries exist for languages like Java, JavaScript, C, sharp, and more.
200
+
201
+ 51
202
+ 00:03:59,000 --> 00:04:05,000
203
+ Reactive programming has become popular in building modern applications, especially those that involve
204
+
205
+ 52
206
+ 00:04:05,000 --> 00:04:10,000
207
+ real time data, user interfaces, and distributed systems.
208
+
209
+ 53
210
+ 00:04:10,000 --> 00:04:18,000
211
+ Frameworks and libraries like Project Reactor, Erik's Java provide tools and abstractions to implement
212
+
213
+ 54
214
+ 00:04:18,000 --> 00:04:21,000
215
+ reactive programming in various programming languages.
216
+
217
+ 55
218
+ 00:04:22,000 --> 00:04:29,000
219
+ These tools simplify the handling of asynchronous and streaming data, making it easier for developers
220
+
221
+ 56
222
+ 00:04:29,000 --> 00:04:32,000
223
+ to build responsive and scalable applications.
224
+
225
+ 57
226
+ 00:04:33,000 --> 00:04:40,000
227
+ In Java, reactive programming approach may be implemented with different libraries, for example a
228
+
229
+ 58
230
+ 00:04:40,000 --> 00:04:42,000
231
+ Java reactor core.
232
+
233
+ 59
234
+ 00:04:42,000 --> 00:04:52,000
235
+ Reactive streams are socket martini reactor, but starting from Java version nine, you can use JDK
236
+
237
+ 60
238
+ 00:04:52,000 --> 00:04:55,000
239
+ to implement reactive programming approach.
240
+
241
+ 61
242
+ 00:04:55,000 --> 00:04:59,000
243
+ Flow API is available starting from Java nine.
244
+
245
+ 62
246
+ 00:04:59,000 --> 00:05:02,000
247
+ In this lesson we will focus on flow API.
248
+
249
+ 63
250
+ 00:05:03,000 --> 00:05:05,000
251
+ So let's learn what a flow API is.
252
+
253
+ 64
254
+ 00:05:06,000 --> 00:05:14,000
255
+ The flow API, also known as Reactive Streams, was introduced in Java nine to address challenges associated
256
+
257
+ 65
258
+ 00:05:14,000 --> 00:05:21,000
259
+ with asynchronous programming and handling streams of data in a more efficient and scalable way.
260
+
261
+ 66
262
+ 00:05:21,000 --> 00:05:28,000
263
+ Reactive streams provide a standard for asynchronous stream processing with non-blocking back pressure,
264
+
265
+ 67
266
+ 00:05:28,000 --> 00:05:33,000
267
+ enabling better control over the flow of data between components.
268
+
269
+ 68
270
+ 00:05:33,000 --> 00:05:40,000
271
+ Reactive streams define a set of interfaces, classes, and masses that standardize the exchange of
272
+
273
+ 69
274
+ 00:05:40,000 --> 00:05:46,000
275
+ asynchronous data streams between components in a non-blocking, back pressure aware manner.
276
+
277
+ 70
278
+ 00:05:47,000 --> 00:05:51,000
279
+ Now let me share with you key interfaces in the flow API.
280
+
281
+ 71
282
+ 00:05:51,000 --> 00:05:58,000
283
+ So the main interfaces include publisher, subscriber, subscription and processor.
284
+
285
+ 72
286
+ 00:05:58,000 --> 00:06:05,000
287
+ I will make just a brief overview of them and we will learn more during the review of real life example.
288
+
289
+ 73
290
+ 00:06:06,000 --> 00:06:13,000
291
+ Publisher amidst a potentially unbounded sequence of elements to one or more subscribers.
292
+
293
+ 74
294
+ 00:06:14,000 --> 00:06:22,000
295
+ Subscriber consumes elements from a publisher and signals when it can handle more elements.
296
+
297
+ 75
298
+ 00:06:22,000 --> 00:06:30,000
299
+ Subscription represents the link between a subscriber and a publisher, allowing the subscriber to request
300
+
301
+ 76
302
+ 00:06:30,000 --> 00:06:31,000
303
+ and cancel elements.
304
+
305
+ 77
306
+ 00:06:32,000 --> 00:06:33,000
307
+ Processor.
308
+
309
+ 78
310
+ 00:06:34,000 --> 00:06:43,000
311
+ The processor interface in the Reactive Streams API serves as a dual role component, acting both as
312
+
313
+ 79
314
+ 00:06:43,000 --> 00:06:49,000
315
+ a subscriber and a publisher, enabling custom data processing within a reactive stream.
316
+
317
+ 80
318
+ 00:06:50,000 --> 00:06:55,000
319
+ So let's try to answer the question why flow API is needed?
320
+
321
+ 81
322
+ 00:06:55,000 --> 00:07:02,000
323
+ Traditional stream processing in Java lacked a standardized way to handle asynchronous data streams,
324
+
325
+ 82
326
+ 00:07:02,000 --> 00:07:09,000
327
+ which could lead to issues like buffer overflow or excessive resource consumption.
328
+
329
+ 83
330
+ 00:07:09,000 --> 00:07:16,000
331
+ Reactive streams address these problems by introducing Backpressure, allowing subscribers to signal
332
+
333
+ 84
334
+ 00:07:16,000 --> 00:07:22,000
335
+ when they are ready to receive more data, preventing overwhelming downstream components.
336
+
337
+ 85
338
+ 00:07:22,000 --> 00:07:26,000
339
+ And in which cases it is recommended to use flow API.
340
+
341
+ 86
342
+ 00:07:27,000 --> 00:07:29,000
343
+ Asynchronous processing.
344
+
345
+ 87
346
+ 00:07:29,000 --> 00:07:36,000
347
+ Reactive streams are beneficial in scenarios where asynchronous processing is required, such as handling
348
+
349
+ 88
350
+ 00:07:36,000 --> 00:07:40,000
351
+ events, input output operations, or real time data.
352
+
353
+ 89
354
+ 00:07:41,000 --> 00:07:48,000
355
+ Backpressure handling when dealing with data streams, where the rate of data production is different
356
+
357
+ 90
358
+ 00:07:48,000 --> 00:07:50,000
359
+ from the rate of data consumption.
360
+
361
+ 91
362
+ 00:07:50,000 --> 00:07:56,000
363
+ Reactive streams help manage backpressure, preventing overwhelming downstream components.
364
+
365
+ 92
366
+ 00:07:57,000 --> 00:08:00,000
367
+ Scalable and responsive applications.
368
+
369
+ 93
370
+ 00:08:01,000 --> 00:08:02,000
371
+ Reactive programming was.
372
+
373
+ 94
374
+ 00:08:02,000 --> 00:08:09,000
375
+ Reactive Streams is well suited for building responsive and scalable applications, especially in scenarios
376
+
377
+ 95
378
+ 00:08:09,000 --> 00:08:13,000
379
+ like web services, where responsiveness is crucial.
380
+
381
+ 96
382
+ 00:08:14,000 --> 00:08:16,000
383
+ Use reactive streams when you need to.
384
+
385
+ 97
386
+ 00:08:17,000 --> 00:08:20,000
387
+ Handle asynchronous data streams.
388
+
389
+ 98
390
+ 00:08:20,000 --> 00:08:26,000
391
+ Implement Backpressure to control the flow of data and prevent resource exhaustion.
392
+
393
+ 99
394
+ 00:08:26,000 --> 00:08:34,000
395
+ Build scalable and responsive applications with non-blocking input output operations.
396
+
397
+ 100
398
+ 00:08:35,000 --> 00:08:41,000
399
+ Reactive streams have gained popularity in modern Java development and are widely used in frameworks
400
+
401
+ 101
402
+ 00:08:41,000 --> 00:08:46,000
403
+ like Project Reactor to build reactive and resilient systems.
404
+
405
+ 102
406
+ 00:08:46,000 --> 00:08:52,000
407
+ I believe we learned enough theory, and now we are ready to review examples that I prepared especially
408
+
409
+ 103
410
+ 00:08:52,000 --> 00:08:53,000
411
+ for this lesson.
412
+
413
+ 104
414
+ 00:08:54,000 --> 00:09:00,000
415
+ You can find the source code of examples that I am going to share with you in attachments to the lesson.
416
+
417
+ 105
418
+ 00:09:00,000 --> 00:09:06,000
419
+ Remember, Tim, that you are always welcome to ask questions in case something is not clear.
420
+
421
+ 106
422
+ 00:09:06,000 --> 00:09:11,000
423
+ Just post your question below the video and I will be happy to answer.
424
+
425
+ 107
426
+ 00:09:11,000 --> 00:09:17,000
427
+ As you can see, examples related to reactive streams are in flow API package.
428
+
429
+ 108
430
+ 00:09:18,000 --> 00:09:22,000
431
+ We're going to start review from the flow API example class.
432
+
433
+ 109
434
+ 00:09:22,000 --> 00:09:26,000
435
+ This is a class where I put client code and main method.
436
+
437
+ 110
438
+ 00:09:27,000 --> 00:09:30,000
439
+ So we will go together with the flow of execution.
440
+
441
+ 111
442
+ 00:09:30,000 --> 00:09:34,000
443
+ And I will explain you what is happening here line by line.
444
+
445
+ 112
446
+ 00:09:34,000 --> 00:09:39,000
447
+ Let me also run this file in order to have all console output printed.
448
+
449
+ 113
450
+ 00:09:39,000 --> 00:09:43,000
451
+ And you will be able to see the sequence of events that is happening here.
452
+
453
+ 114
454
+ 00:09:44,000 --> 00:09:51,000
455
+ Pay attention that today we will review types that are stored on the Java.util.concurrent package inside
456
+
457
+ 115
458
+ 00:09:51,000 --> 00:09:53,000
459
+ final class flow.
460
+
461
+ 116
462
+ 00:09:53,000 --> 00:10:00,000
463
+ There are such important interfaces as publisher, subscriber, subscription and processor.
464
+
465
+ 117
466
+ 00:10:00,000 --> 00:10:03,000
467
+ These are types that we are going to use today.
468
+
469
+ 118
470
+ 00:10:04,000 --> 00:10:07,000
471
+ I start example from creation of the submission publisher.
472
+
473
+ 119
474
+ 00:10:08,000 --> 00:10:15,000
475
+ The submission publisher is a built in implementation of the publisher interface in Java Flow API.
476
+
477
+ 120
478
+ 00:10:15,000 --> 00:10:23,000
479
+ It emits a potentially unbounded sequence of elements, in this case integers to one or more subscribers.
480
+
481
+ 121
482
+ 00:10:24,000 --> 00:10:29,000
483
+ The next thing I create instance of my subscriber.
484
+
485
+ 122
486
+ 00:10:29,000 --> 00:10:36,000
487
+ It is parametrized by integer type because in this example I plan to receive integer elements.
488
+
489
+ 123
490
+ 00:10:36,000 --> 00:10:42,000
491
+ To implement subscriber interface, you need to give implementation to all following methods.
492
+
493
+ 124
494
+ 00:10:42,000 --> 00:10:45,000
495
+ Let's review each of them one by one.
496
+
497
+ 125
498
+ 00:10:46,000 --> 00:10:48,000
499
+ Unsubscribe method.
500
+
501
+ 126
502
+ 00:10:48,000 --> 00:10:56,000
503
+ This method signals about the subscription sets the subscription object, and requests the first item
504
+
505
+ 127
506
+ 00:10:56,000 --> 00:10:59,000
507
+ to initialize the data flow with the provided subscription.
508
+
509
+ 128
510
+ 00:11:00,000 --> 00:11:07,000
511
+ Basically, with the request method, you create demand for elements that subscriber can process depending
512
+
513
+ 129
514
+ 00:11:07,000 --> 00:11:13,000
515
+ on the amount of requested elements, the same amount of times on next method will be invoked.
516
+
517
+ 130
518
+ 00:11:14,000 --> 00:11:16,000
519
+ On next method.
520
+
521
+ 131
522
+ 00:11:16,000 --> 00:11:21,000
523
+ This method processes in common integer items.
524
+
525
+ 132
526
+ 00:11:21,000 --> 00:11:28,000
527
+ In our example, I just double all in common integers and transform them to string just for the sake
528
+
529
+ 133
530
+ 00:11:28,000 --> 00:11:34,000
531
+ of example, because theoretically we can implement processor interface that I am going to explain a
532
+
533
+ 134
534
+ 00:11:34,000 --> 00:11:42,000
535
+ little bit later, and you can supply process data downstream in such way you can build processing chain
536
+
537
+ 135
538
+ 00:11:42,000 --> 00:11:43,000
539
+ and data flow.
540
+
541
+ 136
542
+ 00:11:44,000 --> 00:11:48,000
543
+ That's why I created submit method just for the sake of example.
544
+
545
+ 137
546
+ 00:11:48,000 --> 00:11:55,000
547
+ And just to show you that in submit method, you can put the logic of processed item submission downstream
548
+
549
+ 138
550
+ 00:11:55,000 --> 00:11:56,000
551
+ in simple words.
552
+
553
+ 139
554
+ 00:11:56,000 --> 00:12:03,000
555
+ Send processed item further down the processing chain depending on your business logic.
556
+
557
+ 140
558
+ 00:12:04,000 --> 00:12:12,000
559
+ Onerror method handles errors during processing by printing an error message, allowing the processor
560
+
561
+ 141
562
+ 00:12:12,000 --> 00:12:15,000
563
+ to respond appropriately to error conditions.
564
+
565
+ 142
566
+ 00:12:16,000 --> 00:12:20,000
567
+ On complete signals, the completion of processing.
568
+
569
+ 143
570
+ 00:12:20,000 --> 00:12:24,000
571
+ Printing a message to indicate the end of the data stream.
572
+
573
+ 144
574
+ 00:12:24,000 --> 00:12:31,000
575
+ If you build a longer processing chain, this is the method where you can notify downstream components
576
+
577
+ 145
578
+ 00:12:31,000 --> 00:12:36,000
579
+ that processing is completed, and in this method I cancel subscription.
580
+
581
+ 146
582
+ 00:12:37,000 --> 00:12:40,000
583
+ Let's get back to flow API example class.
584
+
585
+ 147
586
+ 00:12:41,000 --> 00:12:49,000
587
+ The next thing that I do here I subscribe my subscriber to publisher in the context of the Reactive
588
+
589
+ 148
590
+ 00:12:49,000 --> 00:12:50,000
591
+ Streams API.
592
+
593
+ 149
594
+ 00:12:50,000 --> 00:12:57,000
595
+ The relationship between a publisher and a subscriber is established through the subscribe method.
596
+
597
+ 150
598
+ 00:12:57,000 --> 00:13:04,000
599
+ However, it is important to note that it is the publisher who initiates the subscription process by
600
+
601
+ 151
602
+ 00:13:04,000 --> 00:13:08,000
603
+ calling the subscribe method on the publisher object.
604
+
605
+ 152
606
+ 00:13:08,000 --> 00:13:11,000
607
+ Now there will be a connection between them.
608
+
609
+ 153
610
+ 00:13:12,000 --> 00:13:19,000
611
+ Publisher will be aware about subscriber and when this will happen, then unsubscribe method will be
612
+
613
+ 154
614
+ 00:13:19,000 --> 00:13:24,000
615
+ triggered and I will initialize my subscription property inside.
616
+
617
+ 155
618
+ 00:13:25,000 --> 00:13:28,000
619
+ But wait, something should be wrong here.
620
+
621
+ 156
622
+ 00:13:28,000 --> 00:13:34,000
623
+ Where missing subscription object because we have publisher, we have subscriber.
624
+
625
+ 157
626
+ 00:13:34,000 --> 00:13:36,000
627
+ But where is subscription object?
628
+
629
+ 158
630
+ 00:13:36,000 --> 00:13:41,000
631
+ You can implement it by yourself by implementing subscription interface.
632
+
633
+ 159
634
+ 00:13:41,000 --> 00:13:43,000
635
+ But what is happening in this case?
636
+
637
+ 160
638
+ 00:13:44,000 --> 00:13:50,000
639
+ You can see that I decided to print subscription object to console in order to understand the type of
640
+
641
+ 161
642
+ 00:13:50,000 --> 00:13:51,000
643
+ this object.
644
+
645
+ 162
646
+ 00:13:52,000 --> 00:13:54,000
647
+ And we can see that we received here.
648
+
649
+ 163
650
+ 00:13:54,000 --> 00:13:56,000
651
+ Object of type buffered subscription.
652
+
653
+ 164
654
+ 00:13:57,000 --> 00:14:01,000
655
+ This is nested class inside submission publisher class.
656
+
657
+ 165
658
+ 00:14:01,000 --> 00:14:03,000
659
+ But who created this object?
660
+
661
+ 166
662
+ 00:14:03,000 --> 00:14:10,000
663
+ And when a buffered subscription is created when a subscriber subscribes to a submission publisher,
664
+
665
+ 167
666
+ 00:14:11,000 --> 00:14:17,000
667
+ this subscription object manages the communication between the publisher and the subscriber, facilitating
668
+
669
+ 168
670
+ 00:14:17,000 --> 00:14:19,000
671
+ the flow of data.
672
+
673
+ 169
674
+ 00:14:19,000 --> 00:14:21,000
675
+ The charm buffer.
676
+
677
+ 170
678
+ 00:14:21,000 --> 00:14:28,000
679
+ It suggests that this subscription might have some internal buffer to store items when the subscriber
680
+
681
+ 171
682
+ 00:14:28,000 --> 00:14:31,000
683
+ can't keep up with the rate of data production.
684
+
685
+ 172
686
+ 00:14:32,000 --> 00:14:36,000
687
+ Here is a breakdown of what happens during the subscription process.
688
+
689
+ 173
690
+ 00:14:37,000 --> 00:14:42,000
691
+ Publisher calls subscribe method and subscribe subscriber object.
692
+
693
+ 174
694
+ 00:14:42,000 --> 00:14:47,000
695
+ Submission publisher creates a buffered subscription object internally.
696
+
697
+ 175
698
+ 00:14:48,000 --> 00:14:51,000
699
+ This is happening inside subscribe method.
700
+
701
+ 176
702
+ 00:14:51,000 --> 00:14:57,000
703
+ If we would open the source code of subscribe method, we will see how instance of buffered subscription
704
+
705
+ 177
706
+ 00:14:57,000 --> 00:14:58,000
707
+ is created.
708
+
709
+ 178
710
+ 00:14:59,000 --> 00:15:05,000
711
+ Unsubscribe method is called on the subscriber with created buffered subscription.
712
+
713
+ 179
714
+ 00:15:05,000 --> 00:15:12,000
715
+ The unsubscribe method is then invoked on the subscriber, passing the buffered subscription as an argument.
716
+
717
+ 180
718
+ 00:15:12,000 --> 00:15:17,000
719
+ This allows the subscriber to request items and manage backpressure.
720
+
721
+ 181
722
+ 00:15:17,000 --> 00:15:24,000
723
+ The buffered aspect of the subscription typically comes into play when the subscriber is unable to keep
724
+
725
+ 182
726
+ 00:15:24,000 --> 00:15:27,000
727
+ up with the rate of data production.
728
+
729
+ 183
730
+ 00:15:27,000 --> 00:15:35,000
731
+ In such cases, the buffered subscription may buffer items until the subscriber signals that it can
732
+
733
+ 184
734
+ 00:15:35,000 --> 00:15:38,000
735
+ process more data by calling the request method.
736
+
737
+ 185
738
+ 00:15:39,000 --> 00:15:44,000
739
+ So after subscription is happened, then I set the timeout.
740
+
741
+ 186
742
+ 00:15:45,000 --> 00:15:49,000
743
+ We need this time out to make sure that subscription is created.
744
+
745
+ 187
746
+ 00:15:49,000 --> 00:15:56,000
747
+ But using timeout is very primitive way that I decided to use for the sake of example.
748
+
749
+ 188
750
+ 00:15:56,000 --> 00:16:03,000
751
+ In reality, ensuring that everyone is successfully subscribed in a reactive system can be a complicated
752
+
753
+ 189
754
+ 00:16:03,000 --> 00:16:09,000
755
+ task, and the approach might depend on the specific requirements of your application.
756
+
757
+ 190
758
+ 00:16:10,000 --> 00:16:14,000
759
+ Some points to consider using of countdown Lodge.
760
+
761
+ 191
762
+ 00:16:15,000 --> 00:16:17,000
763
+ Using of completablefuture.
764
+
765
+ 192
766
+ 00:16:17,000 --> 00:16:22,000
767
+ Using of timeout mechanism, including using it with completablefuture.
768
+
769
+ 193
770
+ 00:16:23,000 --> 00:16:26,000
771
+ In my course Java from zero to first job.
772
+
773
+ 194
774
+ 00:16:26,000 --> 00:16:33,000
775
+ I have multi-threading section where I explained in details API of countdown, Lodge, Completablefuture
776
+
777
+ 195
778
+ 00:16:33,000 --> 00:16:35,000
779
+ and other things.
780
+
781
+ 196
782
+ 00:16:35,000 --> 00:16:38,000
783
+ That's why I wouldn't stop too much on this right now.
784
+
785
+ 197
786
+ 00:16:39,000 --> 00:16:43,000
787
+ In console you can see subscriber subscribed.
788
+
789
+ 198
790
+ 00:16:44,000 --> 00:16:52,000
791
+ After the timeout, I declare a for loop with counter and I submit five integers using publisher object.
792
+
793
+ 199
794
+ 00:16:52,000 --> 00:17:00,000
795
+ I submit them one by one, and in console you can see that publisher submits one element and subscriber
796
+
797
+ 200
798
+ 00:17:00,000 --> 00:17:01,000
799
+ receives it.
800
+
801
+ 201
802
+ 00:17:01,000 --> 00:17:08,000
803
+ Taking into account that println method is synchronized, text and console not necessarily represents
804
+
805
+ 202
806
+ 00:17:08,000 --> 00:17:15,000
807
+ the exact sequence of events, but at least it can give us an understanding of what is going on.
808
+
809
+ 203
810
+ 00:17:15,000 --> 00:17:23,000
811
+ Subscriber after receiving integers, doubles, received elements and prints them to console two and
812
+
813
+ 204
814
+ 00:17:23,000 --> 00:17:30,000
815
+ when publisher is closed, subscriber got notified two and Oncomplete method is triggered.
816
+
817
+ 205
818
+ 00:17:31,000 --> 00:17:32,000
819
+ And that's it.
820
+
821
+ 206
822
+ 00:17:32,000 --> 00:17:39,000
823
+ Knowing this, you can build more complex data flows with multiple subscribers, different publishers.
824
+
825
+ 207
826
+ 00:17:39,000 --> 00:17:44,000
827
+ You can connect them between each other as your business logic would require.
828
+
829
+ 208
830
+ 00:17:45,000 --> 00:17:51,000
831
+ And the last but not the least thing that I would like to show you for today is processor interface.
832
+
833
+ 209
834
+ 00:17:52,000 --> 00:17:58,000
835
+ You can create processor class that would implement processor interface if you want to make it acting
836
+
837
+ 210
838
+ 00:17:58,000 --> 00:18:02,000
839
+ as both a publisher and a subscriber.
840
+
841
+ 211
842
+ 00:18:02,000 --> 00:18:06,000
843
+ This can be helpful when you want to build a processing chain.
844
+
845
+ 212
846
+ 00:18:06,000 --> 00:18:13,000
847
+ For example, you can receive some data from publisher, process it, and pass it further to the next
848
+
849
+ 213
850
+ 00:18:13,000 --> 00:18:14,000
851
+ subscriber.
852
+
853
+ 214
854
+ 00:18:15,000 --> 00:18:15,000
855
+ And like this.
856
+
857
+ 215
858
+ 00:18:15,000 --> 00:18:18,000
859
+ You can build complex data flows.
860
+
861
+ 216
862
+ 00:18:18,000 --> 00:18:26,000
863
+ So the processor interface in the Reactive Streams API is used when you need to create a component that
864
+
865
+ 217
866
+ 00:18:26,000 --> 00:18:29,000
867
+ acts as a both a publisher and a subscriber.
868
+
869
+ 218
870
+ 00:18:29,000 --> 00:18:36,000
871
+ It is particularly useful in scenarios where you want to transform or process the data flowing through
872
+
873
+ 219
874
+ 00:18:36,000 --> 00:18:40,000
875
+ a reactive stream before it reaches the downstream subscribers.
876
+
877
+ 220
878
+ 00:18:41,000 --> 00:18:46,000
879
+ Here are some situations where you might consider using the processor interface.
880
+
881
+ 221
882
+ 00:18:47,000 --> 00:18:50,000
883
+ Transforming or processing data.
884
+
885
+ 222
886
+ 00:18:50,000 --> 00:18:57,000
887
+ If you need to apply transformations, filtering or any other processing logic to the data before it
888
+
889
+ 223
890
+ 00:18:57,000 --> 00:19:03,000
891
+ is delivered to subscribers, the processor interface allows you to implement this logic.
892
+
893
+ 224
894
+ 00:19:04,000 --> 00:19:07,000
895
+ Connecting different parts of a reactive pipeline.
896
+
897
+ 225
898
+ 00:19:07,000 --> 00:19:13,000
899
+ When you have a reactive pipeline with multiple stages, and you want to connect these stages with a
900
+
901
+ 226
902
+ 00:19:13,000 --> 00:19:20,000
903
+ component that can both consume data from the upstream and emit processed data to the downstream.
904
+
905
+ 227
906
+ 00:19:21,000 --> 00:19:24,000
907
+ Implementing a custom flow control mechanism.
908
+
909
+ 228
910
+ 00:19:24,000 --> 00:19:31,000
911
+ If you need to implement a custom flow control mechanism between the publisher and subscribers, the
912
+
913
+ 229
914
+ 00:19:31,000 --> 00:19:38,000
915
+ processor allows you to manage backpressure and control the rate at which data is consumed.
916
+
917
+ 230
918
+ 00:19:38,000 --> 00:19:41,000
919
+ Aggregating or combining data streams.
920
+
921
+ 231
922
+ 00:19:41,000 --> 00:19:47,000
923
+ When you want to combine or aggregate data from multiple publishers before delivering it to downstream
924
+
925
+ 232
926
+ 00:19:47,000 --> 00:19:49,000
927
+ subscribers.
928
+
929
+ 233
930
+ 00:19:49,000 --> 00:19:52,000
931
+ A processor can be used to implement the necessary logic.
932
+
933
+ 234
934
+ 00:19:53,000 --> 00:20:00,000
935
+ If you check the source code of processor interface, then you will find that processor is a static
936
+
937
+ 235
938
+ 00:20:00,000 --> 00:20:05,000
939
+ interface that extends subscriber and publisher at the same time.
940
+
941
+ 236
942
+ 00:20:05,000 --> 00:20:10,000
943
+ In Java, an interface can extend multiple other interfaces.
944
+
945
+ 237
946
+ 00:20:10,000 --> 00:20:17,000
947
+ This feature allows an interface to inherit abstract masses from multiple parent interfaces, providing
948
+
949
+ 238
950
+ 00:20:17,000 --> 00:20:22,000
951
+ a way to express multiple types of behavior in a single interface.
952
+
953
+ 239
954
+ 00:20:22,000 --> 00:20:30,000
955
+ So feel free to use processor interface implementations when it will be needed in your business cases.
956
+
957
+ 240
958
+ 00:20:30,000 --> 00:20:34,000
959
+ That's all what I wanted to share with you today in this lesson.
960
+
961
+ 241
962
+ 00:20:34,000 --> 00:20:37,000
963
+ Let's recap what we have learned in the video.
964
+
965
+ 242
966
+ 00:20:38,000 --> 00:20:41,000
967
+ We learned reactive programming approach.
968
+
969
+ 243
970
+ 00:20:41,000 --> 00:20:45,000
971
+ Now you know the most popular libraries for reactive programming in Java.
972
+
973
+ 244
974
+ 00:20:46,000 --> 00:20:54,000
975
+ I explained you what flow API in JDK is, and we learned key interfaces and types in flow API.
976
+
977
+ 245
978
+ 00:20:54,000 --> 00:21:01,000
979
+ I explained when and in which cases it is recommended to use Reactive Programming, Reactive Streams
980
+
981
+ 246
982
+ 00:21:01,000 --> 00:21:08,000
983
+ flow API, and at the end of the lesson we reviewed code example in order to understand how it works
984
+
985
+ 247
986
+ 00:21:08,000 --> 00:21:09,000
987
+ in practice.
988
+
989
+ 248
990
+ 00:21:09,000 --> 00:21:12,000
991
+ That's all what I wanted to share with you today.
992
+
993
+ 249
994
+ 00:21:12,000 --> 00:21:15,000
995
+ Have a great day and see you in the next lesson.
996
+
31 - JDK API/003 Source-code-examples-from-the-lesson.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/commit/d62a11591550fc4c8455d610c8ddbcf31c194b71
31 - JDK API/004 Quiz JDK API - Check yourself.html ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Quiz JDK API - Check yourself</title>
7
+
8
+ <style>
9
+ * {
10
+ box-sizing: border-box;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+ body {
15
+ font-family: var(--font-stack-text);
16
+ font-weight: 400;
17
+ line-height: 1.4;
18
+ font-size: 1.6rem;
19
+ color: #2d2f31;
20
+ }
21
+ .container {
22
+ position: relative;
23
+ height: 100%;
24
+ overflow-y: auto;
25
+ }
26
+ .content {
27
+ padding: 3.2rem 4.8rem;
28
+ word-break: break-word;
29
+ max-width: 69.6rem;
30
+ margin: 0 auto;
31
+ }
32
+ .heading {
33
+ margin-bottom: 24px;
34
+ font-family: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Helvetica, Arial, sans-serif,
35
+ "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
36
+ font-weight: 700;
37
+ line-height: 1.2;
38
+ letter-spacing: 0;
39
+ font-size: 32px;
40
+ max-width: 36em;
41
+ }
42
+ .article-asset-container {
43
+ padding: 2.4rem;
44
+ }
45
+ .article-asset-container p {
46
+ font-size: 19px;
47
+ }
48
+ code {
49
+ background-color: #fff;
50
+ border: 1px solid #d1d7dc;
51
+ color: #b4690e;
52
+ font-size: 80%;
53
+ padding: 0.2rem 0.4rem;
54
+ font-family: sfmono-regular, Consolas, liberation mono, Menlo, Courier, monospace;
55
+ }
56
+ p {
57
+ font-weight: 400;
58
+ }
59
+ </style>
60
+ </head>
61
+ <body>
62
+ <div class="container">
63
+ <div class="content">
64
+ <div class="heading">Quiz JDK API - Check yourself</div>
65
+ <div class="article-asset-container"><p><strong>Quiz Link: </strong><a href="https://forms.gle/LBnM5Sc5PXE71h6w6" rel="noopener noreferrer" target="_blank"><strong>https://forms.gle/LBnM5Sc5PXE71h6w6</strong></a></p><p>The quiz doesn’t require you to log in or submit any personal information. Your data privacy is my priority.</p><p>The Quiz covers content from the following lessons:</p><ul><li><p>StringBuilder &amp; StringBuffer</p></li><li><p>java.util.Optional - Optional in Java</p></li><li><p>Reactive Programming in Java: Flow API, Reactive Streams</p></li></ul><p><br></p><p><strong>Quiz Instructions:</strong></p><p>This quiz is designed to help you check your understanding of the content from the previous lessons. All questions are based only on material covered in the lessons you've already watched, so there’s no need to worry about unfamiliar topics.</p><ul><li><p>Each question has one correct answer. Select the best answer and click "Submit" when you're ready.</p></li><li><p>After submitting, you'll see your score. For each question, you earn 1 point.</p></li><li><p>Click "View Results" to see the explanations for each correct answer. Reviewing these explanations can help reinforce your understanding.</p></li><li><p>If you score below 70%, I recommend revisiting the previous lessons. However, if the explanations make sense and you’re confident in your understanding, feel free to move on.</p></li><li><p>If any explanations are unclear, please don’t hesitate to post questions in the Q&amp;A section—I’m here to help!</p></li></ul></div>
66
+ </div>
67
+ </div>
68
+ </body>
69
+ </html>
31 - JDK API/external-links.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+
2
+ 001 Source-code-from-the-lesson
3
+ https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/string/stringbuilder
4
+
5
+ 002 Source-code-examples-from-the-lesson
6
+ https://github.com/AndriiPiatakha/learnit_java_core/tree/master/src/com/itbulls/learnit/javacore/optional
7
+
8
+ 003 Source-code-examples-from-the-lesson
9
+ https://github.com/AndriiPiatakha/learnit_java_core/commit/d62a11591550fc4c8455d610c8ddbcf31c194b71
32 - Java Platform Module System Modules in Java & Migration of Java Apps/001 Modules in Java Modular Application Example_en.srt ADDED
@@ -0,0 +1,1576 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:11,000
3
+ Hello, the students in this lesson, we're going to learn more about features it was added in Java
4
+
5
+ 2
6
+ 00:00:11,000 --> 00:00:12,000
7
+ version nine.
8
+
9
+ 3
10
+ 00:00:12,000 --> 00:00:14,000
11
+ I'm talking about modules in Java.
12
+
13
+ 4
14
+ 00:00:14,000 --> 00:00:21,000
15
+ There we have really a lot of new things to learn modules, really powerful features that exist in Java
16
+
17
+ 5
18
+ 00:00:21,000 --> 00:00:22,000
19
+ platform.
20
+
21
+ 6
22
+ 00:00:22,000 --> 00:00:28,000
23
+ And if you want to become Java software engineer or get one of Oracle certifications, you have to be
24
+
25
+ 7
26
+ 00:00:28,000 --> 00:00:29,000
27
+ familiar with it.
28
+
29
+ 8
30
+ 00:00:29,000 --> 00:00:38,000
31
+ We'll start lesson from simple and general topics such as what models are and just talking about why
32
+
33
+ 9
34
+ 00:00:38,000 --> 00:00:42,000
35
+ we might need them to help you understand modules better.
36
+
37
+ 10
38
+ 00:00:42,000 --> 00:00:49,000
39
+ I will explain what goals we are trying to achieve by using them and what benefits we expect to get.
40
+
41
+ 11
42
+ 00:00:50,000 --> 00:00:52,000
43
+ We'll review different module types.
44
+
45
+ 12
46
+ 00:00:53,000 --> 00:01:00,000
47
+ After that, we'll learn module directives that we use in the module descriptor and common line options
48
+
49
+ 13
50
+ 00:01:00,000 --> 00:01:05,000
51
+ that might come in handy when you will work with multiple modules from Consult.
52
+
53
+ 14
54
+ 00:01:05,000 --> 00:01:12,000
55
+ And at the end of the lesson, we're going to create modular Hello World application, and I will show
56
+
57
+ 15
58
+ 00:01:12,000 --> 00:01:18,000
59
+ you how to configure it leaves and either you can work with this modular application from Eclipse.
60
+
61
+ 16
62
+ 00:01:19,000 --> 00:01:22,000
63
+ As you can see, we have really a lot of things to do.
64
+
65
+ 17
66
+ 00:01:22,000 --> 00:01:24,000
67
+ Let's start our lesson.
68
+
69
+ 18
70
+ 00:01:25,000 --> 00:01:28,000
71
+ Let's understand first what modules are.
72
+
73
+ 19
74
+ 00:01:28,000 --> 00:01:37,000
75
+ Module is a Nicklin named reusable group of related packages, as well as resources such as images and
76
+
77
+ 20
78
+ 00:01:37,000 --> 00:01:39,000
79
+ Xolo files and module.
80
+
81
+ 21
82
+ 00:01:39,000 --> 00:01:44,000
83
+ The specifying the modules name Xen Modules dependencies.
84
+
85
+ 22
86
+ 00:01:44,000 --> 00:01:46,000
87
+ These are the other modules.
88
+
89
+ 23
90
+ 00:01:46,000 --> 00:01:49,000
91
+ This module depends on zip packages.
92
+
93
+ 24
94
+ 00:01:49,000 --> 00:01:52,000
95
+ It explicitly makes available to other modules.
96
+
97
+ 25
98
+ 00:01:53,000 --> 00:02:00,000
99
+ All other packages in the module I implicitly unavailable to other modules, just services it offers,
100
+
101
+ 26
102
+ 00:02:01,000 --> 00:02:06,000
103
+ the services it consumes, but what other modules it allows?
104
+
105
+ 27
106
+ 00:02:06,000 --> 00:02:12,000
107
+ Reflection and General Module is a packaging mechanism that enables you to package a Java application
108
+
109
+ 28
110
+ 00:02:13,000 --> 00:02:21,000
111
+ or Java API as a separate Java module and general module is packaged as Modular Jar File and Java module
112
+
113
+ 29
114
+ 00:02:21,000 --> 00:02:24,000
115
+ can specify which of Java packages it contains.
116
+
117
+ 30
118
+ 00:02:24,000 --> 00:02:28,000
119
+ That should be visible to OSR Java modules, which he uses.
120
+
121
+ 31
122
+ 00:02:28,000 --> 00:02:36,000
123
+ This module and you have a module must also specify which OSI Jumo modules are required to do its job.
124
+
125
+ 32
126
+ 00:02:37,000 --> 00:02:45,000
127
+ In most single words, Java module is a package for packages that is super simplified, but hope this
128
+
129
+ 33
130
+ 00:02:45,000 --> 00:02:48,000
131
+ will help you to understand this concept.
132
+
133
+ 34
134
+ 00:02:48,000 --> 00:02:55,000
135
+ You can group packages into modules and to ensure encapsulation, you may control access to different
136
+
137
+ 35
138
+ 00:02:55,000 --> 00:02:57,000
139
+ packages within the module.
140
+
141
+ 36
142
+ 00:02:57,000 --> 00:03:02,000
143
+ Modularity as higher level of a nation above packages is a clear.
144
+
145
+ 37
146
+ 00:03:03,000 --> 00:03:06,000
147
+ Java Modules is a new feature in Java nine.
148
+
149
+ 38
150
+ 00:03:07,000 --> 00:03:15,000
151
+ We as a Java Platform Module System Z Java Platform Module System is also sometimes referred to as Java,
152
+
153
+ 39
154
+ 00:03:15,000 --> 00:03:20,000
155
+ Jigsaw or Project Jigsaw, depending on where you read.
156
+
157
+ 40
158
+ 00:03:20,000 --> 00:03:25,000
159
+ Jigsaw was internally used project name during development.
160
+
161
+ 41
162
+ 00:03:25,000 --> 00:03:29,000
163
+ Later, Jigsaw changed the name to Java Platform Module system.
164
+
165
+ 42
166
+ 00:03:30,000 --> 00:03:37,000
167
+ There is a juicer 376 Juicer stands for Java specification request.
168
+
169
+ 43
170
+ 00:03:37,000 --> 00:03:45,000
171
+ This is an actual description of proposed and final specification for the Java platform at any one time.
172
+
173
+ 44
174
+ 00:03:45,000 --> 00:03:49,000
175
+ There are numerous juicers movies with a review and approval process.
176
+
177
+ 45
178
+ 00:03:50,000 --> 00:03:55,000
179
+ In the Juicer 376, we can find list of goals of modular.
180
+
181
+ 46
182
+ 00:03:55,000 --> 00:04:02,000
183
+ Ryzen is a Java Sea platform, and one them such goals as a reliable configuration.
184
+
185
+ 47
186
+ 00:04:03,000 --> 00:04:10,000
187
+ Modularity provides mechanisms for explicitly declaring dependencies between modules in a manner that's
188
+
189
+ 48
190
+ 00:04:10,000 --> 00:04:14,000
191
+ recognized both at compile time and execution time.
192
+
193
+ 49
194
+ 00:04:15,000 --> 00:04:16,000
195
+ The system can work.
196
+
197
+ 50
198
+ 00:04:16,000 --> 00:04:24,000
199
+ Suzy's Dependencies commands a subset of all modules required to support your app from Gemini nine and
200
+
201
+ 51
202
+ 00:04:24,000 --> 00:04:33,000
203
+ forward Java applications must be packaged as Java Modules two zero four and application modules specifies
204
+
205
+ 52
206
+ 00:04:33,000 --> 00:04:38,000
207
+ what OSM modules Java API modules supporting modules.
208
+
209
+ 53
210
+ 00:04:38,000 --> 00:04:47,000
211
+ It uses zero for the Java virtual machine can check the whole module dependency graph from application
212
+
213
+ 54
214
+ 00:04:47,000 --> 00:04:52,000
215
+ module and four one one zero virtual machine starts up.
216
+
217
+ 55
218
+ 00:04:52,000 --> 00:05:00,000
219
+ If any required models are not found at startup, the Java Virtual Machine reports is a missing module
220
+
221
+ 56
222
+ 00:05:00,000 --> 00:05:03,000
223
+ and shuts down before Java nine Mason class.
224
+
225
+ 57
226
+ 00:05:04,000 --> 00:05:11,000
227
+ Just from a Mason Jar file, for example, would not be detected until the application actually tried
228
+
229
+ 58
230
+ 00:05:11,000 --> 00:05:12,000
231
+ to use Zoom Mason class.
232
+
233
+ 59
234
+ 00:05:13,000 --> 00:05:20,000
235
+ This would happen sometime at runtime dependent on one's application tried to use the missing class.
236
+
237
+ 60
238
+ 00:05:20,000 --> 00:05:28,000
239
+ Having missing modules reported at application startup time is a big advantage compared to its runtime
240
+
241
+ 61
242
+ 00:05:28,000 --> 00:05:37,000
243
+ when trying to use Zoom's Mojo Jar plus strong encapsulation zip packages in the module are accessible
244
+
245
+ 62
246
+ 00:05:37,000 --> 00:05:41,000
247
+ to OSM modules only use the module explicitly exports them.
248
+
249
+ 63
250
+ 00:05:42,000 --> 00:05:51,000
251
+ Even then, another module can't use those packages unless it explicitly states that it requires as
252
+
253
+ 64
254
+ 00:05:51,000 --> 00:05:53,000
255
+ other modules capabilities.
256
+
257
+ 65
258
+ 00:05:53,000 --> 00:05:59,000
259
+ This improves platform security because fewer classes accessible to potential attackers.
260
+
261
+ 66
262
+ 00:06:00,000 --> 00:06:06,000
263
+ You may find that considering modularity helps you come up with cleaner, more logical designs.
264
+
265
+ 67
266
+ 00:06:07,000 --> 00:06:15,000
267
+ Scalable Java Platform Robust is a Java platform was a monolith consisting of a massive number of packages,
268
+
269
+ 68
270
+ 00:06:16,000 --> 00:06:20,000
271
+ making it challenging to develop, maintain and evolve.
272
+
273
+ 69
274
+ 00:06:20,000 --> 00:06:22,000
275
+ It couldn't be easily subset.
276
+
277
+ 70
278
+ 00:06:23,000 --> 00:06:27,000
279
+ The platform is now one of the rise into ninety five modules.
280
+
281
+ 71
282
+ 00:06:28,000 --> 00:06:30,000
283
+ This number might change as Java evolves.
284
+
285
+ 72
286
+ 00:06:31,000 --> 00:06:38,000
287
+ You can create custom rom coms consisting of only modules you need for your apps was devices you are
288
+
289
+ 73
290
+ 00:06:38,000 --> 00:06:39,000
291
+ targeting.
292
+
293
+ 74
294
+ 00:06:39,000 --> 00:06:46,000
295
+ For example, if a device doesn't support graphical user interfaces, you could create a runtime that
296
+
297
+ 75
298
+ 00:06:46,000 --> 00:06:47,000
299
+ doesn't include xG.
300
+
301
+ 76
302
+ 00:06:47,000 --> 00:06:56,000
303
+ UI modules significantly reduces your runtime size before Java nine and the Java Platform Module system.
304
+
305
+ 77
306
+ 00:06:56,000 --> 00:07:03,000
307
+ You would have had to package all of the Java platform APIs with your job application because there
308
+
309
+ 78
310
+ 00:07:03,000 --> 00:07:06,000
311
+ was no official way of reliable checking.
312
+
313
+ 79
314
+ 00:07:06,000 --> 00:07:09,000
315
+ What crosses your Java application use?
316
+
317
+ 80
318
+ 00:07:10,000 --> 00:07:16,000
319
+ Since the job platform API eyes have grown quite large over the years, your application will get the
320
+
321
+ 81
322
+ 00:07:16,000 --> 00:07:23,000
323
+ large amount of Java classes included in its distribution, many of which your application would probably
324
+
325
+ 82
326
+ 00:07:23,000 --> 00:07:24,000
327
+ not be using.
328
+
329
+ 83
330
+ 00:07:25,000 --> 00:07:32,000
331
+ Greater platform integrity Before Java Non, it was possible to use many classes in the platform as
332
+
333
+ 84
334
+ 00:07:32,000 --> 00:07:35,000
335
+ it were not meant for use by and apps.
336
+
337
+ 85
338
+ 00:07:35,000 --> 00:07:43,000
339
+ Classes with strong encapsulation zones and channel API are truly encapsulated and hidden from apps
340
+
341
+ 86
342
+ 00:07:43,000 --> 00:07:45,000
343
+ using the platform.
344
+
345
+ 87
346
+ 00:07:45,000 --> 00:07:51,000
347
+ This can make migrating legacy code the Modularized Java non problematic.
348
+
349
+ 88
350
+ 00:07:51,000 --> 00:07:59,000
351
+ If your code depends on internal APIs, then use glossies make up the key from distributable big, then
352
+
353
+ 89
354
+ 00:07:59,000 --> 00:08:00,000
355
+ it needs to be.
356
+
357
+ 90
358
+ 00:08:01,000 --> 00:08:08,000
359
+ This can be a problem on small devices like mobile phones, Raspberry Pi, etc. was a Java platform
360
+
361
+ 91
362
+ 00:08:08,000 --> 00:08:09,000
363
+ modular system.
364
+
365
+ 92
366
+ 00:08:10,000 --> 00:08:16,000
367
+ You can now package your application was always a module of the Java Platform API that your application
368
+
369
+ 93
370
+ 00:08:16,000 --> 00:08:18,000
371
+ is actually using.
372
+
373
+ 94
374
+ 00:08:18,000 --> 00:08:21,000
375
+ This will result in small application distribution.
376
+
377
+ 95
378
+ 00:08:21,000 --> 00:08:24,000
379
+ Both improve performance.
380
+
381
+ 96
382
+ 00:08:25,000 --> 00:08:29,000
383
+ Gem uses various optimization techniques to improve application performance.
384
+
385
+ 97
386
+ 00:08:30,000 --> 00:08:38,000
387
+ GSR 376 indicates that these techniques are more effective when it's known in advance.
388
+
389
+ 98
390
+ 00:08:39,000 --> 00:08:46,000
391
+ Word types are located only in specific modules, and this was a great improvement for Java as a platform.
392
+
393
+ 99
394
+ 00:08:47,000 --> 00:08:53,000
395
+ Nowadays, questions about modules among many questions during different Oracle certifications.
396
+
397
+ 100
398
+ 00:08:54,000 --> 00:08:57,000
399
+ Let's talk now about different modules types.
400
+
401
+ 101
402
+ 00:08:57,000 --> 00:09:03,000
403
+ There are four types of modules in the new model system system modules.
404
+
405
+ 102
406
+ 00:09:03,000 --> 00:09:07,000
407
+ These other modules listed when we run Java.
408
+
409
+ 103
410
+ 00:09:07,000 --> 00:09:14,000
411
+ These modules Command Z, includes a Java Sea and JDK modules application modules.
412
+
413
+ 104
414
+ 00:09:15,000 --> 00:09:22,000
415
+ These models are what we usually want to build when we decide to use modules z unnamed and defined as
416
+
417
+ 105
418
+ 00:09:22,000 --> 00:09:28,000
419
+ a compile module info class file included in the assembled jar.
420
+
421
+ 106
422
+ 00:09:28,000 --> 00:09:37,000
423
+ Today, we are going to create our own module info file and see all examples automatic modules.
424
+
425
+ 107
426
+ 00:09:37,000 --> 00:09:43,000
427
+ We can include unofficial modules by an existing jar files to the module pass.
428
+
429
+ 108
430
+ 00:09:43,000 --> 00:09:47,000
431
+ The name of the module will be derived from the name of the jar.
432
+
433
+ 109
434
+ 00:09:48,000 --> 00:09:58,000
435
+ Automatic modules will have full access to every OSM module loaded by pass name tomorrow when a class
436
+
437
+ 110
438
+ 00:09:58,000 --> 00:10:01,000
439
+ or jar is loaded into the class bus.
440
+
441
+ 111
442
+ 00:10:01,000 --> 00:10:03,000
443
+ But no, the module bus.
444
+
445
+ 112
446
+ 00:10:03,000 --> 00:10:06,000
447
+ It's automatically added to the unnamed model.
448
+
449
+ 113
450
+ 00:10:07,000 --> 00:10:14,000
451
+ It's a catch all model to maintain backwards compatibility with previously written Java code.
452
+
453
+ 114
454
+ 00:10:14,000 --> 00:10:19,000
455
+ The unnamed, more new concept is similar to the default package.
456
+
457
+ 115
458
+ 00:10:19,000 --> 00:10:26,000
459
+ Therefore, it is not considered a real model but can be viewed as a default module.
460
+
461
+ 116
462
+ 00:10:26,000 --> 00:10:33,000
463
+ We can create multi-modal projects comprised of a main application and several library modules.
464
+
465
+ 117
466
+ 00:10:33,000 --> 00:10:39,000
467
+ We have to be careful, though, because we can only have one module per jar file.
468
+
469
+ 118
470
+ 00:10:40,000 --> 00:10:46,000
471
+ Let's see now what module descriptor is and what are the different directives that might be used in
472
+
473
+ 119
474
+ 00:10:46,000 --> 00:10:53,000
475
+ the module if a Java file, as we have discussed already, a module must provide a module descriptor
476
+
477
+ 120
478
+ 00:10:53,000 --> 00:11:00,000
479
+ metadata that specifies the modules, dependencies, zip packages the model makes available to other
480
+
481
+ 121
482
+ 00:11:00,000 --> 00:11:07,000
483
+ modules and more, and module descriptor is a compiled version of the module declaration that's defined
484
+
485
+ 122
486
+ 00:11:07,000 --> 00:11:09,000
487
+ in the file name module.
488
+
489
+ 123
490
+ 00:11:09,000 --> 00:11:16,000
491
+ Info jowar and the first scene that we need to do is to create a file was named Module Info and with
492
+
493
+ 124
494
+ 00:11:16,000 --> 00:11:17,000
495
+ Java extension.
496
+
497
+ 125
498
+ 00:11:18,000 --> 00:11:22,000
499
+ This file should be located in the source code directory.
500
+
501
+ 126
502
+ 00:11:23,000 --> 00:11:31,000
503
+ Each module declaration begins with the keyword module, followed by a unique module name and the module
504
+
505
+ 127
506
+ 00:11:31,000 --> 00:11:35,000
507
+ body enclosed in races like you see in that example.
508
+
509
+ 128
510
+ 00:11:35,000 --> 00:11:40,000
511
+ In general, module name follows the same naming rules as Java packages.
512
+
513
+ 129
514
+ 00:11:41,000 --> 00:11:48,000
515
+ However, you should not use underscores any module names or package names, class and these massive
516
+
517
+ 130
518
+ 00:11:48,000 --> 00:11:56,000
519
+ names, variable names, etc. from Gemini and Forward because Java wants to use underscore as reserved
520
+
521
+ 131
522
+ 00:11:56,000 --> 00:11:58,000
523
+ and easy to in the future.
524
+
525
+ 132
526
+ 00:11:58,000 --> 00:12:05,000
527
+ It is recommended to name a Java module is the same as the name of the root Java package contained in
528
+
529
+ 133
530
+ 00:12:05,000 --> 00:12:06,000
531
+ the module.
532
+
533
+ 134
534
+ 00:12:06,000 --> 00:12:14,000
535
+ If that is possible, because some of this might contain multiple packages is a module declarations,
536
+
537
+ 135
538
+ 00:12:14,000 --> 00:12:22,000
539
+ but it can be empty or may contain various module directives, including the requis experts provide
540
+
541
+ 136
542
+ 00:12:22,000 --> 00:12:27,000
543
+ space, etc. We are going to discuss each of these in a few minutes.
544
+
545
+ 137
546
+ 00:12:27,000 --> 00:12:35,000
547
+ As you'll see later, components and module declaration create is a model descriptor, which is stored
548
+
549
+ 138
550
+ 00:12:35,000 --> 00:12:40,000
551
+ in the file named Module Info, plus the Modules folder.
552
+
553
+ 139
554
+ 00:12:40,000 --> 00:12:48,000
555
+ On this slide, I will briefly introduce each module directive Zacchaeus only in module declarations
556
+
557
+ 140
558
+ 00:12:48,000 --> 00:12:53,000
559
+ and may be used as identifiers anywhere else in your code.
560
+
561
+ 141
562
+ 00:12:53,000 --> 00:12:56,000
563
+ Let's learn now directives.
564
+
565
+ 142
566
+ 00:12:56,000 --> 00:13:00,000
567
+ The first directives that we are given to them is requires.
568
+
569
+ 143
570
+ 00:13:00,000 --> 00:13:06,000
571
+ This module directive allows us to declare module dependencies, for example.
572
+
573
+ 144
574
+ 00:13:06,000 --> 00:13:13,000
575
+ In this case, my module has both a runtime and the compile time dependency on some module that you
576
+
577
+ 145
578
+ 00:13:13,000 --> 00:13:15,000
579
+ should refer by module name.
580
+
581
+ 146
582
+ 00:13:16,000 --> 00:13:20,000
583
+ Each module must explicitly state its dependencies.
584
+
585
+ 147
586
+ 00:13:20,000 --> 00:13:30,000
587
+ When Module eight requires Model B, Module A is set to read Module B and Module B is spread by Module
588
+
589
+ 148
590
+ 00:13:30,000 --> 00:13:37,000
591
+ A, the specified dependency on another module user requires and all public Typekit.
592
+
593
+ 149
594
+ 00:13:37,000 --> 00:13:43,000
595
+ Experts from a dependency are accessible by our module when we use this directive.
596
+
597
+ 150
598
+ 00:13:43,000 --> 00:13:50,000
599
+ Another important mention here is that it is not allowed to have separate dependencies between modules.
600
+
601
+ 151
602
+ 00:13:50,000 --> 00:14:00,000
603
+ In other words, if Module eight requires Module B, Module B can also require module a z module dependency
604
+
605
+ 152
606
+ 00:14:00,000 --> 00:14:06,000
607
+ graph must be an acyclic graph and thus a directive is a quasi static.
608
+
609
+ 153
610
+ 00:14:06,000 --> 00:14:09,000
611
+ We might write a lot of functions that pretty.
612
+
613
+ 154
614
+ 00:14:10,000 --> 00:14:18,000
615
+ Our internal state one another to log in module is present, but not every consumer of our level will
616
+
617
+ 155
618
+ 00:14:18,000 --> 00:14:24,000
619
+ want this functionality, and they don't want to include an extra log in library.
620
+
621
+ 156
622
+ 00:14:24,000 --> 00:14:28,000
623
+ In this case, we want to use an optional dependency.
624
+
625
+ 157
626
+ 00:14:29,000 --> 00:14:35,000
627
+ By using the request setting directive, we create a compile time only dependency.
628
+
629
+ 158
630
+ 00:14:35,000 --> 00:14:38,000
631
+ Now let's learn transitive directive.
632
+
633
+ 159
634
+ 00:14:39,000 --> 00:14:45,000
635
+ Imagine that we want to use third party library, and that library in turn has other dependencies.
636
+
637
+ 160
638
+ 00:14:46,000 --> 00:14:54,000
639
+ How we can make sure that any module that we are dependent on will bring its own dependencies to work
640
+
641
+ 161
642
+ 00:14:54,000 --> 00:14:54,000
643
+ properly.
644
+
645
+ 162
646
+ 00:14:55,000 --> 00:15:03,000
647
+ We can force any downstream consumers also to read our required dependencies, which requires transitive.
648
+
649
+ 163
650
+ 00:15:03,000 --> 00:15:11,000
651
+ Attractive, let's review exports DirecTV Now, as you already could understand, is a strong encapsulation
652
+
653
+ 164
654
+ 00:15:11,000 --> 00:15:18,000
655
+ was one of the main goal when Java Platform Module System has been introduced by default, and Model
656
+
657
+ 165
658
+ 00:15:18,000 --> 00:15:22,000
659
+ doesn't expose any of its API to other modules.
660
+
661
+ 166
662
+ 00:15:23,000 --> 00:15:31,000
663
+ Our code is significantly more secure if we don't expose our API to external users.
664
+
665
+ 167
666
+ 00:15:31,000 --> 00:15:38,000
667
+ But what if we created API that it should be used by different modules and we need to explicitly make
668
+
669
+ 168
670
+ 00:15:38,000 --> 00:15:40,000
671
+ it available for everyone?
672
+
673
+ 169
674
+ 00:15:40,000 --> 00:15:46,000
675
+ We use the experts directive to expose all public members of the named package.
676
+
677
+ 170
678
+ 00:15:47,000 --> 00:15:55,000
679
+ Please note that only the least the package itself is experts now support packages of the experts package
680
+
681
+ 171
682
+ 00:15:56,000 --> 00:15:56,000
683
+ experts.
684
+
685
+ 172
686
+ 00:15:57,000 --> 00:16:06,000
687
+ That means that even this package, in my example, contains a package named You Zens Akombe.
688
+
689
+ 173
690
+ 00:16:06,000 --> 00:16:11,000
691
+ My package name util package is not exported.
692
+
693
+ 174
694
+ 00:16:11,000 --> 00:16:16,000
695
+ Just because of parent package is to export the SAP package.
696
+
697
+ 175
698
+ 00:16:16,000 --> 00:16:24,000
699
+ Also, we must declare it explicitly in the module descriptor, and the one module is a singular package
700
+
701
+ 176
702
+ 00:16:24,000 --> 00:16:29,000
703
+ can only be exported by a single Java module at one time.
704
+
705
+ 177
706
+ 00:16:29,000 --> 00:16:37,000
707
+ In other words, you can't have two or more and more and use that export the same package in use at
708
+
709
+ 178
710
+ 00:16:37,000 --> 00:16:38,000
711
+ the same time.
712
+
713
+ 179
714
+ 00:16:39,000 --> 00:16:46,000
715
+ The Java Virtual Machine will come clean startup if you do having two modules export.
716
+
717
+ 180
718
+ 00:16:46,000 --> 00:16:55,000
719
+ The same package is also sometimes referred to as a split package by split package is meant that the
720
+
721
+ 181
722
+ 00:16:55,000 --> 00:17:01,000
723
+ total content classes of the package is split between the multiple modules.
724
+
725
+ 182
726
+ 00:17:02,000 --> 00:17:03,000
727
+ This is not allowed.
728
+
729
+ 183
730
+ 00:17:04,000 --> 00:17:13,000
731
+ In case we want to limit access to our API and expose it only to some packages XL, we have to use experts
732
+
733
+ 184
734
+ 00:17:13,000 --> 00:17:17,000
735
+ to direct it similar to the experts directive.
736
+
737
+ 185
738
+ 00:17:17,000 --> 00:17:25,000
739
+ We declare a package as experts, but we also list which models we are allowing to import this package
740
+
741
+ 186
742
+ 00:17:25,000 --> 00:17:26,000
743
+ as it requires.
744
+
745
+ 187
746
+ 00:17:27,000 --> 00:17:36,000
747
+ And here's how it looks like the next directive is users now use this Model Directive Force, a service
748
+
749
+ 188
750
+ 00:17:36,000 --> 00:17:44,000
751
+ used by this module, making the model a service consumer, a service services, an object of loss that
752
+
753
+ 189
754
+ 00:17:44,000 --> 00:17:45,000
755
+ implements the interface.
756
+
757
+ 190
758
+ 00:17:45,000 --> 00:17:49,000
759
+ So extensive apps are specified in the users directive.
760
+
761
+ 191
762
+ 00:17:50,000 --> 00:17:55,000
763
+ With this in mind, the services our model consumes with a users directive.
764
+
765
+ 192
766
+ 00:17:56,000 --> 00:17:58,000
767
+ No, just the last name we use.
768
+
769
+ 193
770
+ 00:17:58,000 --> 00:18:06,000
771
+ This is the interface for apps, loss of the service, the on the implementation class, because service
772
+
773
+ 194
774
+ 00:18:06,000 --> 00:18:12,000
775
+ in this context means and implementation of a specific interface or apps a gloss that can be consumed
776
+
777
+ 195
778
+ 00:18:12,000 --> 00:18:14,000
779
+ by OSI classes.
780
+
781
+ 196
782
+ 00:18:14,000 --> 00:18:21,000
783
+ But what is the difference between uses and requires the wrappers we might require and more uses?
784
+
785
+ 197
786
+ 00:18:21,000 --> 00:18:29,000
787
+ It provides a service we want to consume, but that service implements an interface from one of its
788
+
789
+ 198
790
+ 00:18:29,000 --> 00:18:36,000
791
+ transitive dependencies instead of forcing our module to require all transitive dependencies.
792
+
793
+ 199
794
+ 00:18:36,000 --> 00:18:43,000
795
+ Just in case we use the uses, Directive two adds the required interface to the module.
796
+
797
+ 200
798
+ 00:18:43,000 --> 00:18:44,000
799
+ POS is a career.
800
+
801
+ 201
802
+ 00:18:45,000 --> 00:18:52,000
803
+ We have discussed directives that consumes the services, but this also means that we have modules that
804
+
805
+ 202
806
+ 00:18:52,000 --> 00:19:00,000
807
+ provides services so a module can also be a service providers that other modules can consume, and we
808
+
809
+ 203
810
+ 00:19:00,000 --> 00:19:04,000
811
+ can ensure this voice provides with direction.
812
+
813
+ 204
814
+ 00:19:05,000 --> 00:19:12,000
815
+ We should write provides key words first and specifies the interface or abstract class name of our service
816
+
817
+ 205
818
+ 00:19:13,000 --> 00:19:14,000
819
+ is Let's see.
820
+
821
+ 206
822
+ 00:19:14,000 --> 00:19:21,000
823
+ What we have to do is to specify what specific implementation of our service we are going to provide
824
+
825
+ 207
826
+ 00:19:22,000 --> 00:19:24,000
827
+ was a help with directing.
828
+
829
+ 208
830
+ 00:19:25,000 --> 00:19:29,000
831
+ You provide the implementation class name that isn't implements.
832
+
833
+ 209
834
+ 00:19:29,000 --> 00:19:33,000
835
+ The interface or extents is an abstract class.
836
+
837
+ 210
838
+ 00:19:34,000 --> 00:19:40,000
839
+ The next important declarations that I'd like to show you opens and opens to.
840
+
841
+ 211
842
+ 00:19:41,000 --> 00:19:44,000
843
+ Let's learn this before December nine.
844
+
845
+ 212
846
+ 00:19:44,000 --> 00:19:53,000
847
+ Reflection could be used to learn about all types in the package and all members of it time even its
848
+
849
+ 213
850
+ 00:19:53,000 --> 00:19:58,000
851
+ private members, was the one that allows this capability on not.
852
+
853
+ 214
854
+ 00:19:59,000 --> 00:20:04,000
855
+ Thus, nothing was truly encapsulated like we have discussed already.
856
+
857
+ 215
858
+ 00:20:05,000 --> 00:20:12,000
859
+ The key motivation of the module system is strong, and cancellation by default and died in the module
860
+
861
+ 216
862
+ 00:20:12,000 --> 00:20:19,000
863
+ is not accessible to OSM modules unless it's a public type and you export its package.
864
+
865
+ 217
866
+ 00:20:20,000 --> 00:20:26,000
867
+ You expose all the packages you want to expose with Gemini.
868
+
869
+ 218
870
+ 00:20:26,000 --> 00:20:28,000
871
+ This also applies to reflection.
872
+
873
+ 219
874
+ 00:20:29,000 --> 00:20:36,000
875
+ For example, we can allow runtime only access to a package, so directive opened.
876
+
877
+ 220
878
+ 00:20:36,000 --> 00:20:44,000
879
+ Some package indicates that a specific package is public types and then nested public and protected
880
+
881
+ 221
882
+ 00:20:44,000 --> 00:20:49,000
883
+ types accessible to code in other modules at runtime only.
884
+
885
+ 222
886
+ 00:20:49,000 --> 00:20:59,000
887
+ Also, all the types in the specified package and all of the types members are accessible via reflection.
888
+
889
+ 223
890
+ 00:20:59,000 --> 00:21:08,000
891
+ Another example We can allow runtime only access the package by specific modules and opens to Model
892
+
893
+ 224
894
+ 00:21:08,000 --> 00:21:08,000
895
+ Directive.
896
+
897
+ 225
898
+ 00:21:09,000 --> 00:21:18,000
899
+ Like, for example, open package name to some list of modules indicates that specific packages, public
900
+
901
+ 226
902
+ 00:21:18,000 --> 00:21:26,000
903
+ types and then nascent public and protected types are accessible to code in the list of modules at runtime
904
+
905
+ 227
906
+ 00:21:26,000 --> 00:21:27,000
907
+ only.
908
+
909
+ 228
910
+ 00:21:27,000 --> 00:21:35,000
911
+ All of the types in the specified package and all of the types members are accessible via reflection
912
+
913
+ 229
914
+ 00:21:35,000 --> 00:21:37,000
915
+ to court in the specified modules.
916
+
917
+ 230
918
+ 00:21:38,000 --> 00:21:45,000
919
+ We have discussed already that one of the main goals of modules is strong encapsulation, and I believe
920
+
921
+ 231
922
+ 00:21:45,000 --> 00:21:50,000
923
+ that you watched the previous lesson and you're pretty familiar with reflection by this moment already.
924
+
925
+ 232
926
+ 00:21:51,000 --> 00:21:58,000
927
+ So you can understand that before June nine, it was possible to use a reflection to examine every type
928
+
929
+ 233
930
+ 00:21:59,000 --> 00:22:02,000
931
+ and the member in the package, even the private ones.
932
+
933
+ 234
934
+ 00:22:03,000 --> 00:22:04,000
935
+ Was through.
936
+
937
+ 235
938
+ 00:22:04,000 --> 00:22:11,000
939
+ Really encapsulated, which can open up all kinds of problems for developers of the libraries because
940
+
941
+ 236
942
+ 00:22:11,000 --> 00:22:13,000
943
+ Java nine enforce a strong encapsulation.
944
+
945
+ 237
946
+ 00:22:14,000 --> 00:22:21,000
947
+ We have to explicitly grant permission for OSM modules to reflect on our classes if we want to continue
948
+
949
+ 238
950
+ 00:22:21,000 --> 00:22:28,000
951
+ to allow full reflection as older versions of Java did, we can simply opens entire modules by using
952
+
953
+ 239
954
+ 00:22:28,000 --> 00:22:32,000
955
+ open direct before module name like you see on the slide.
956
+
957
+ 240
958
+ 00:22:33,000 --> 00:22:35,000
959
+ Does it make sense so far?
960
+
961
+ 241
962
+ 00:22:35,000 --> 00:22:42,000
963
+ And please always remember these in case you have any questions, please post them below this video
964
+
965
+ 242
966
+ 00:22:42,000 --> 00:22:45,000
967
+ and I will be happy to answer those.
968
+
969
+ 243
970
+ 00:22:45,000 --> 00:22:51,000
971
+ We have just learned directives that we can use in our modules in profile.
972
+
973
+ 244
974
+ 00:22:51,000 --> 00:22:55,000
975
+ The next step would be to learn how to build our modules.
976
+
977
+ 245
978
+ 00:22:56,000 --> 00:22:59,000
979
+ And before I show you examples of how to do that.
980
+
981
+ 246
982
+ 00:23:00,000 --> 00:23:01,000
983
+ Let me explain.
984
+
985
+ 247
986
+ 00:23:01,000 --> 00:23:08,000
987
+ Different command line options that we can use when we build Java modules, even despite the fact that
988
+
989
+ 248
990
+ 00:23:08,000 --> 00:23:15,000
991
+ later in our course, we are going to learn such views as Randall and May one and zero when you have
992
+
993
+ 249
994
+ 00:23:15,000 --> 00:23:18,000
995
+ support for building modules in Java.
996
+
997
+ 250
998
+ 00:23:18,000 --> 00:23:22,000
999
+ It's still valuable to know how to use modules.
1000
+
1001
+ 251
1002
+ 00:23:22,000 --> 00:23:28,000
1003
+ System forms a common plan will be used as a common line for our full example.
1004
+
1005
+ 252
1006
+ 00:23:28,000 --> 00:23:36,000
1007
+ I'm going to show you in a few minutes to help solidify how the entire system works in our minds.
1008
+
1009
+ 253
1010
+ 00:23:37,000 --> 00:23:38,000
1011
+ Module Pass.
1012
+
1013
+ 254
1014
+ 00:23:38,000 --> 00:23:42,000
1015
+ We use a module pass option to specify the module for us.
1016
+
1017
+ 255
1018
+ 00:23:42,000 --> 00:23:49,000
1019
+ This is a list of one on one directories that contain our modules athletes.
1020
+
1021
+ 256
1022
+ 00:23:49,000 --> 00:23:57,000
1023
+ Instead of relying on the module declaration file, we can use the command line equivalent of the requires
1024
+
1025
+ 257
1026
+ 00:23:57,000 --> 00:23:59,000
1027
+ directors and experts.
1028
+
1029
+ 258
1030
+ 00:24:00,000 --> 00:24:09,000
1031
+ Common Line replacement for the X Plus DirecTV and Opens replaces the open clause in the module declaration
1032
+
1033
+ 259
1034
+ 00:24:09,000 --> 00:24:16,000
1035
+ file adds modules adds is a list of modules into the default set of modules.
1036
+
1037
+ 260
1038
+ 00:24:16,000 --> 00:24:24,000
1039
+ These modules creates a list of all modules and their version strings by each module.
1040
+
1041
+ 261
1042
+ 00:24:24,000 --> 00:24:27,000
1043
+ Add or overwrite classes in modules.
1044
+
1045
+ 262
1046
+ 00:24:28,000 --> 00:24:38,000
1047
+ Illegal acts was values is permit over or do not use a relaxed encapsulation by showing a single global
1048
+
1049
+ 263
1050
+ 00:24:38,000 --> 00:24:43,000
1051
+ warning shows rewarding or fails with errors.
1052
+
1053
+ 264
1054
+ 00:24:43,000 --> 00:24:45,000
1055
+ The default is permit.
1056
+
1057
+ 265
1058
+ 00:24:46,000 --> 00:24:49,000
1059
+ Finally, we are done with the mini series piece.
1060
+
1061
+ 266
1062
+ 00:24:49,000 --> 00:24:53,000
1063
+ Let's continue learning modules with examples now.
1064
+
1065
+ 267
1066
+ 00:24:53,000 --> 00:24:57,000
1067
+ This would be our Hello World modular application.
1068
+
1069
+ 268
1070
+ 00:24:57,000 --> 00:25:04,000
1071
+ Thus, it would all be super complicated because the main goal right now is to make you understand key
1072
+
1073
+ 269
1074
+ 00:25:04,000 --> 00:25:07,000
1075
+ principles of modular application.
1076
+
1077
+ 270
1078
+ 00:25:08,000 --> 00:25:15,000
1079
+ The rest of the synths will be super easy to understand if you learned how everything works on the hood.
1080
+
1081
+ 271
1082
+ 00:25:15,000 --> 00:25:23,000
1083
+ So first of all, I want to say that for the sake of the demo, I created separate multi module project.
1084
+
1085
+ 272
1086
+ 00:25:23,000 --> 00:25:27,000
1087
+ I will share with you a link to it in attachments to this lesson.
1088
+
1089
+ 273
1090
+ 00:25:28,000 --> 00:25:32,000
1091
+ I have Food Project folder and I created the Modules folder.
1092
+
1093
+ 274
1094
+ 00:25:33,000 --> 00:25:38,000
1095
+ Apparently, this folder will contain different modules of my app.
1096
+
1097
+ 275
1098
+ 00:25:38,000 --> 00:25:43,000
1099
+ It is full of some main modules as a root source package.
1100
+
1101
+ 276
1102
+ 00:25:43,000 --> 00:25:49,000
1103
+ For example, it was a top level package of the module is compatibles greetings.
1104
+
1105
+ 277
1106
+ 00:25:49,000 --> 00:25:52,000
1107
+ Then I named the module in the same way.
1108
+
1109
+ 278
1110
+ 00:25:53,000 --> 00:25:55,000
1111
+ Note this is a full stops.
1112
+
1113
+ 279
1114
+ 00:25:55,000 --> 00:25:57,000
1115
+ These are modular root directory name.
1116
+
1117
+ 280
1118
+ 00:25:58,000 --> 00:26:07,000
1119
+ Z's full stops need to be easier because part of the module name Zen not to be interpreted as subdirectory
1120
+
1121
+ 281
1122
+ 00:26:07,000 --> 00:26:08,000
1123
+ POS dividers.
1124
+
1125
+ 282
1126
+ 00:26:09,000 --> 00:26:09,000
1127
+ Is it the.
1128
+
1129
+ 283
1130
+ 00:26:10,000 --> 00:26:13,000
1131
+ As you can see, I have two models here.
1132
+
1133
+ 284
1134
+ 00:26:13,000 --> 00:26:16,000
1135
+ Let me start from greeting Swan.
1136
+
1137
+ 285
1138
+ 00:26:16,000 --> 00:26:24,000
1139
+ It contains loss was named greetings and static mass insight that brings hello world to console.
1140
+
1141
+ 286
1142
+ 00:26:25,000 --> 00:26:28,000
1143
+ Each model should have Model E for file.
1144
+
1145
+ 287
1146
+ 00:26:29,000 --> 00:26:32,000
1147
+ Let's look at the model descriptor of this model.
1148
+
1149
+ 288
1150
+ 00:26:32,000 --> 00:26:34,000
1151
+ On the top, you can see model name.
1152
+
1153
+ 289
1154
+ 00:26:35,000 --> 00:26:42,000
1155
+ Basically, model name and name of the model for this should match and be expert package from this model.
1156
+
1157
+ 290
1158
+ 00:26:42,000 --> 00:26:46,000
1159
+ Experts directive is used was package name.
1160
+
1161
+ 291
1162
+ 00:26:47,000 --> 00:26:53,000
1163
+ Now creates a second model is the name of my second module is Compatibles App.
1164
+
1165
+ 292
1166
+ 00:26:53,000 --> 00:26:56,000
1167
+ This is the main module that uses greetings module.
1168
+
1169
+ 293
1170
+ 00:26:57,000 --> 00:27:04,000
1171
+ It has only one class was the main message where we use greetings class to invoke say hello mass pay
1172
+
1173
+ 294
1174
+ 00:27:04,000 --> 00:27:05,000
1175
+ attention.
1176
+
1177
+ 295
1178
+ 00:27:05,000 --> 00:27:11,000
1179
+ We also have the import statement here to import greetings class from another package.
1180
+
1181
+ 296
1182
+ 00:27:11,000 --> 00:27:14,000
1183
+ This module also has module descriptor.
1184
+
1185
+ 297
1186
+ 00:27:15,000 --> 00:27:16,000
1187
+ Let's look at it.
1188
+
1189
+ 298
1190
+ 00:27:16,000 --> 00:27:24,000
1191
+ Here we can see that this module requires my greetings module, and this is all of this agree because
1192
+
1193
+ 299
1194
+ 00:27:24,000 --> 00:27:27,000
1195
+ we are using class from greetings module in this one.
1196
+
1197
+ 300
1198
+ 00:27:28,000 --> 00:27:36,000
1199
+ Then the stand dependencies between these two modules, if he isn't great, if no, please press pause
1200
+
1201
+ 301
1202
+ 00:27:36,000 --> 00:27:40,000
1203
+ for a minute and think about it one more time.
1204
+
1205
+ 302
1206
+ 00:27:40,000 --> 00:27:48,000
1207
+ The next step that we need to do this to compile our models specially for that, I create a script that
1208
+
1209
+ 303
1210
+ 00:27:48,000 --> 00:27:50,000
1211
+ will compile all sources.
1212
+
1213
+ 304
1214
+ 00:27:50,000 --> 00:28:00,000
1215
+ It is located in the root directory and it is called Build this sage I use Linux shall come here, so
1216
+
1217
+ 305
1218
+ 00:28:00,000 --> 00:28:07,000
1219
+ pay attention to your transit script, either on Linux platforms or from Bosch on your Windows machine
1220
+
1221
+ 306
1222
+ 00:28:07,000 --> 00:28:12,000
1223
+ and do not use Windows Common Line to run this script.
1224
+
1225
+ 307
1226
+ 00:28:12,000 --> 00:28:14,000
1227
+ You know what Java commands?
1228
+
1229
+ 308
1230
+ 00:28:15,000 --> 00:28:16,000
1231
+ This is our Java compiler.
1232
+
1233
+ 309
1234
+ 00:28:17,000 --> 00:28:24,000
1235
+ After that, I pass the name of the output directly to specify where I want to put the compiled classes.
1236
+
1237
+ 310
1238
+ 00:28:25,000 --> 00:28:29,000
1239
+ The next thing I do, I need to pass module source plus option.
1240
+
1241
+ 311
1242
+ 00:28:30,000 --> 00:28:33,000
1243
+ This is different from the one I shared before.
1244
+
1245
+ 312
1246
+ 00:28:33,000 --> 00:28:40,000
1247
+ If you remember the interview module courses on a separate slot, there is a difference between module
1248
+
1249
+ 313
1250
+ 00:28:40,000 --> 00:28:43,000
1251
+ costs and module source boss.
1252
+
1253
+ 314
1254
+ 00:28:43,000 --> 00:28:51,000
1255
+ The component needs a distinction between the code it used to compile in module source, boss and location
1256
+
1257
+ 315
1258
+ 00:28:51,000 --> 00:28:55,000
1259
+ of compiled dependencies and libraries.
1260
+
1261
+ 316
1262
+ 00:28:55,000 --> 00:28:58,000
1263
+ Module boss does it make more sense now?
1264
+
1265
+ 317
1266
+ 00:28:59,000 --> 00:29:02,000
1267
+ I was here name of my folder with modules.
1268
+
1269
+ 318
1270
+ 00:29:03,000 --> 00:29:09,000
1271
+ After that, I used Show Command to find old files with Java Extension in Modules folder.
1272
+
1273
+ 319
1274
+ 00:29:10,000 --> 00:29:13,000
1275
+ Once my modular app is compiled, I can run it.
1276
+
1277
+ 320
1278
+ 00:29:14,000 --> 00:29:16,000
1279
+ I have another script for this.
1280
+
1281
+ 321
1282
+ 00:29:16,000 --> 00:29:18,000
1283
+ Is it a school run app or sage?
1284
+
1285
+ 322
1286
+ 00:29:19,000 --> 00:29:21,000
1287
+ Let's look at it in this script.
1288
+
1289
+ 323
1290
+ 00:29:21,000 --> 00:29:25,000
1291
+ You also see program that is familiar to you, Java.
1292
+
1293
+ 324
1294
+ 00:29:26,000 --> 00:29:28,000
1295
+ I am going to start Java Virtual Machine.
1296
+
1297
+ 325
1298
+ 00:29:29,000 --> 00:29:37,000
1299
+ I use option module POS to puzzle the reference to the compiled modules and after completion, all of
1300
+
1301
+ 326
1302
+ 00:29:37,000 --> 00:29:41,000
1303
+ them are stored in target output directory.
1304
+
1305
+ 327
1306
+ 00:29:41,000 --> 00:29:49,000
1307
+ You can see that all files here have class extension and even module info file is compiled into class
1308
+
1309
+ 328
1310
+ 00:29:49,000 --> 00:29:49,000
1311
+ file.
1312
+
1313
+ 329
1314
+ 00:29:50,000 --> 00:29:58,000
1315
+ Zen I specifies that most of the class it contains main message zip past consists of module name and
1316
+
1317
+ 330
1318
+ 00:29:58,000 --> 00:29:59,000
1319
+ full class name.
1320
+
1321
+ 331
1322
+ 00:30:00,000 --> 00:30:08,000
1323
+ So in this particular example, Compatibles Rules app is the model name and call it Bus App.
1324
+
1325
+ 332
1326
+ 00:30:08,000 --> 00:30:11,000
1327
+ App is a full class name.
1328
+
1329
+ 333
1330
+ 00:30:11,000 --> 00:30:12,000
1331
+ Is this clear?
1332
+
1333
+ 334
1334
+ 00:30:13,000 --> 00:30:17,000
1335
+ For the sake of the demo, I opened it March inside eclipse.
1336
+
1337
+ 335
1338
+ 00:30:17,000 --> 00:30:27,000
1339
+ I run build S.H. script first, and after that I run run apps, script and hindcast so we can see Hello
1340
+
1341
+ 336
1342
+ 00:30:27,000 --> 00:30:29,000
1343
+ World from the application.
1344
+
1345
+ 337
1346
+ 00:30:29,000 --> 00:30:30,000
1347
+ Can you see this?
1348
+
1349
+ 338
1350
+ 00:30:30,000 --> 00:30:34,000
1351
+ Congratulations to you with your first modular application.
1352
+
1353
+ 339
1354
+ 00:30:35,000 --> 00:30:40,000
1355
+ One more small comment here was the moment of recording this video.
1356
+
1357
+ 340
1358
+ 00:30:40,000 --> 00:30:45,000
1359
+ There is no single and proper way of using Eclipse to run multi-modal application.
1360
+
1361
+ 341
1362
+ 00:30:46,000 --> 00:30:51,000
1363
+ There might be some additional steps to configure multimodal application in eclipse.
1364
+
1365
+ 342
1366
+ 00:30:52,000 --> 00:30:59,000
1367
+ That's why, even on your work, most likely you would use common client to build and to run your complex
1368
+
1369
+ 343
1370
+ 00:30:59,000 --> 00:31:02,000
1371
+ enterprise application for the sake of convenience.
1372
+
1373
+ 344
1374
+ 00:31:03,000 --> 00:31:10,000
1375
+ You still can work in eclipse, but do you need to be prepared that sometimes you will see more errors?
1376
+
1377
+ 345
1378
+ 00:31:10,000 --> 00:31:17,000
1379
+ Is unusual because sometimes it is hard to conceive of all dependencies, not in the app, but in the
1380
+
1381
+ 346
1382
+ 00:31:17,000 --> 00:31:25,000
1383
+ creep's itself in order Eclipse would understand the clearly dependencies between all modules.
1384
+
1385
+ 347
1386
+ 00:31:25,000 --> 00:31:33,000
1387
+ Here's an example you can import two modules as separate projects and work in Java editor was Java files.
1388
+
1389
+ 348
1390
+ 00:31:34,000 --> 00:31:42,000
1391
+ But in app module, you may see error because Eclipse can't see dependency on another module.
1392
+
1393
+ 349
1394
+ 00:31:42,000 --> 00:31:49,000
1395
+ Since technically fruit loops, this is a separate project, and the groups allows only one module info
1396
+
1397
+ 350
1398
+ 00:31:49,000 --> 00:31:51,000
1399
+ file per project.
1400
+
1401
+ 351
1402
+ 00:31:51,000 --> 00:31:53,000
1403
+ In order to remove the error.
1404
+
1405
+ 352
1406
+ 00:31:53,000 --> 00:31:57,000
1407
+ Sometimes you may need to configure dependencies manually.
1408
+
1409
+ 353
1410
+ 00:31:57,000 --> 00:32:04,000
1411
+ If Eclipse didn't manage to configure everything automatically, for example, in my app module, I
1412
+
1413
+ 354
1414
+ 00:32:04,000 --> 00:32:11,000
1415
+ open built up submenu, configure builds bus and here on library staff.
1416
+
1417
+ 355
1418
+ 00:32:12,000 --> 00:32:16,000
1419
+ On the Module POS, I select Add Class Folder.
1420
+
1421
+ 356
1422
+ 00:32:16,000 --> 00:32:24,000
1423
+ Here I put checkbox next to the modules that they need in this one, namely Reding's module and press,
1424
+
1425
+ 357
1426
+ 00:32:24,000 --> 00:32:24,000
1427
+ OK.
1428
+
1429
+ 358
1430
+ 00:32:25,000 --> 00:32:32,000
1431
+ Now you wouldn't see any errors in the clips, but in case you have multiple modules and not all of
1432
+
1433
+ 359
1434
+ 00:32:32,000 --> 00:32:34,000
1435
+ them, I configure it automatically.
1436
+
1437
+ 360
1438
+ 00:32:34,000 --> 00:32:41,000
1439
+ This might take time during the configuration of your project very first time after these configuration
1440
+
1441
+ 361
1442
+ 00:32:41,000 --> 00:32:42,000
1443
+ steps.
1444
+
1445
+ 362
1446
+ 00:32:42,000 --> 00:32:44,000
1447
+ You may run even from Eclipse.
1448
+
1449
+ 363
1450
+ 00:32:45,000 --> 00:32:51,000
1451
+ Can you see this great since you have near Z simple syncs already?
1452
+
1453
+ 364
1454
+ 00:32:51,000 --> 00:32:56,000
1455
+ Let me show you how to add the service to our modular application.
1456
+
1457
+ 365
1458
+ 00:32:56,000 --> 00:33:04,000
1459
+ In my Goulding's module, I declare an interface was name service status log that contains only one
1460
+
1461
+ 366
1462
+ 00:33:04,000 --> 00:33:07,000
1463
+ massive print service that is slow.
1464
+
1465
+ 367
1466
+ 00:33:07,000 --> 00:33:10,000
1467
+ I have implementation of this interface.
1468
+
1469
+ 368
1470
+ 00:33:10,000 --> 00:33:17,000
1471
+ Is it the school default service status slogan for the sake of our demo and just brings text to console?
1472
+
1473
+ 369
1474
+ 00:33:18,000 --> 00:33:26,000
1475
+ Now, in my model info file, I need to declare that this module provides such service was a complete
1476
+
1477
+ 370
1478
+ 00:33:26,000 --> 00:33:27,000
1479
+ implementation.
1480
+
1481
+ 371
1482
+ 00:33:27,000 --> 00:33:30,000
1483
+ I use provides service directive for.
1484
+
1485
+ 372
1486
+ 00:33:30,000 --> 00:33:37,000
1487
+ This is the next logical step would be to consumes this service in my app module.
1488
+
1489
+ 373
1490
+ 00:33:37,000 --> 00:33:44,000
1491
+ I use uses directly for that and specify full class name of the interface.
1492
+
1493
+ 374
1494
+ 00:33:45,000 --> 00:33:52,000
1495
+ After that, in App G+ with the help of Service Loader from January to package I can load my service.
1496
+
1497
+ 375
1498
+ 00:33:52,000 --> 00:33:57,000
1499
+ I use load mass and quasi loss of the services that I need.
1500
+
1501
+ 376
1502
+ 00:33:57,000 --> 00:34:00,000
1503
+ Service loader is a terrible time.
1504
+
1505
+ 377
1506
+ 00:34:01,000 --> 00:34:07,000
1507
+ That's why it has iterate mass app that allows me to get a reference to the first service load.
1508
+
1509
+ 378
1510
+ 00:34:07,000 --> 00:34:12,000
1511
+ The object in the sequence handles a reference to the object.
1512
+
1513
+ 379
1514
+ 00:34:12,000 --> 00:34:15,000
1515
+ I can call print service that is massive.
1516
+
1517
+ 380
1518
+ 00:34:16,000 --> 00:34:24,000
1519
+ Let's now use our new brush to compile new sources one more time and run our app in so you can see that
1520
+
1521
+ 381
1522
+ 00:34:24,000 --> 00:34:27,000
1523
+ we successfully managed to invoke service message.
1524
+
1525
+ 382
1526
+ 00:34:28,000 --> 00:34:31,000
1527
+ That's all what I wanted to share with you in this lesson.
1528
+
1529
+ 383
1530
+ 00:34:32,000 --> 00:34:35,000
1531
+ Let's recap what we have learned in this lesson.
1532
+
1533
+ 384
1534
+ 00:34:36,000 --> 00:34:40,000
1535
+ In the lesson we have learned what general models are all seeing.
1536
+
1537
+ 385
1538
+ 00:34:40,000 --> 00:34:45,000
1539
+ Those are goals that we want to achieve and that that captures images.
1540
+
1541
+ 386
1542
+ 00:34:45,000 --> 00:34:47,000
1543
+ 376.
1544
+
1545
+ 387
1546
+ 00:34:47,000 --> 00:34:53,000
1547
+ We have learned different more of those types of after that revealed details.
1548
+
1549
+ 388
1550
+ 00:34:53,000 --> 00:35:01,000
1551
+ Different command line options to work was more use and on real example, you saw how to create, build
1552
+
1553
+ 389
1554
+ 00:35:01,000 --> 00:35:03,000
1555
+ and run modular application.
1556
+
1557
+ 390
1558
+ 00:35:04,000 --> 00:35:06,000
1559
+ Together, we can simulate eclipse.
1560
+
1561
+ 391
1562
+ 00:35:06,000 --> 00:35:13,000
1563
+ The work was modular application form I.D. and the zenith of the lesson I explained to you how to provide
1564
+
1565
+ 392
1566
+ 00:35:13,000 --> 00:35:16,000
1567
+ and consume service in different modules.
1568
+
1569
+ 393
1570
+ 00:35:17,000 --> 00:35:19,000
1571
+ Thanks a lot for your attention.
1572
+
1573
+ 394
1574
+ 00:35:19,000 --> 00:35:22,000
1575
+ Have a great day and see you in the next lesson.
1576
+
32 - Java Platform Module System Modules in Java & Migration of Java Apps/001 Source-code-examples-from-the-lesson-Modular-Project.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/java-modules
32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 -Example-Migration-Guide-by-Oracle.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://docs.oracle.com/en/java/javase/12/migrate/index.html#JSMIG-GUID-C25E2B1D-6C24-4403-8540-CFEA875B994A
32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 Migration of Java Apps Example of migration to a modular application_en.srt ADDED
@@ -0,0 +1,1524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:11,000
3
+ Hello, distance in Prius lesson, we have learned what modules are in decay?
4
+
5
+ 2
6
+ 00:00:11,000 --> 00:00:14,000
7
+ We also created our first modular application.
8
+
9
+ 3
10
+ 00:00:14,000 --> 00:00:21,000
11
+ In case you skipped the previous lesson, please make sure you watched it because in this lesson, we'll
12
+
13
+ 4
14
+ 00:00:21,000 --> 00:00:23,000
15
+ keep talking about modules.
16
+
17
+ 5
18
+ 00:00:24,000 --> 00:00:28,000
19
+ But this time will not create our module application from scratch.
20
+
21
+ 6
22
+ 00:00:28,000 --> 00:00:35,000
23
+ But instead, we'll focus our attention on the questions of migration of Nano Modular Java application
24
+
25
+ 7
26
+ 00:00:35,000 --> 00:00:37,000
27
+ to modular Java application.
28
+
29
+ 8
30
+ 00:00:37,000 --> 00:00:44,000
31
+ Also, this lesson will be interesting for architects who are in charge of Java migration and responsible
32
+
33
+ 9
34
+ 00:00:44,000 --> 00:00:47,000
35
+ for making decisions and planning next migration steps.
36
+
37
+ 10
38
+ 00:00:48,000 --> 00:00:53,000
39
+ You need to be aware about issues and solutions that we are going to discuss in this lesson.
40
+
41
+ 11
42
+ 00:00:54,000 --> 00:01:00,000
43
+ This is a super important topic, especially if your organization made a decision to migrate from Java
44
+
45
+ 12
46
+ 00:01:00,000 --> 00:01:07,000
47
+ eight to NAS, a long term support version like Java Plans that includes support of modules.
48
+
49
+ 13
50
+ 00:01:07,000 --> 00:01:14,000
51
+ And also, this is super important in case you decide to pass Oracle Java certifications, because some
52
+
53
+ 14
54
+ 00:01:14,000 --> 00:01:22,000
55
+ of the Oracle certifications include questions about migration to modular application, including top
56
+
57
+ 15
58
+ 00:01:22,000 --> 00:01:29,000
59
+ down and bottom up migration, and Split Ajala Agile Associates application into modules for migration.
60
+
61
+ 16
62
+ 00:01:30,000 --> 00:01:36,000
63
+ We'll start our lesson from learning and understanding of general algorithm for migration of our court
64
+
65
+ 17
66
+ 00:01:36,000 --> 00:01:41,000
67
+ to the new environment, including migration to the new version of Dedicate.
68
+
69
+ 18
70
+ 00:01:41,000 --> 00:01:47,000
71
+ Special focus today will be the migration of application to modular architecture.
72
+
73
+ 19
74
+ 00:01:47,000 --> 00:01:54,000
75
+ I will explain in one Java Class Dependency Analyzer tool is and what Java deprecated API is.
76
+
77
+ 20
78
+ 00:01:54,000 --> 00:01:57,000
79
+ Current tool is also we're going to learn today.
80
+
81
+ 21
82
+ 00:01:57,000 --> 00:02:04,000
83
+ Different migration strategies will review Bottom-Up and top-down migration strategies that start our
84
+
85
+ 22
86
+ 00:02:04,000 --> 00:02:05,000
87
+ lesson.
88
+
89
+ 23
90
+ 00:02:06,000 --> 00:02:13,000
91
+ And before I start diving in details, let's come up with steps and migration algorithm first, the
92
+
93
+ 24
94
+ 00:02:13,000 --> 00:02:15,000
95
+ step number zero and super important one.
96
+
97
+ 25
98
+ 00:02:16,000 --> 00:02:21,000
99
+ If you great internet, not sure that you would find this advice anywhere, but exactly as you said,
100
+
101
+ 26
102
+ 00:02:21,000 --> 00:02:23,000
103
+ was help make them a great deal.
104
+
105
+ 27
106
+ 00:02:23,000 --> 00:02:29,000
107
+ Worse software products two different versions and environments before any movements were scored that
108
+
109
+ 28
110
+ 00:02:29,000 --> 00:02:36,000
111
+ potentially may impact the way our program works, no matter whether this is refactoring or migrating
112
+
113
+ 29
114
+ 00:02:36,000 --> 00:02:41,000
115
+ and in what may impact or change code and the way how it is executed.
116
+
117
+ 30
118
+ 00:02:42,000 --> 00:02:45,000
119
+ Make sure that you have for libel suit of tests on different levels.
120
+
121
+ 31
122
+ 00:02:46,000 --> 00:02:51,000
123
+ The general recommendation here would be to automate as much as possible.
124
+
125
+ 32
126
+ 00:02:51,000 --> 00:02:57,000
127
+ Some of my clients say to me that this automation is a huge investments and they have dedicated manual
128
+
129
+ 33
130
+ 00:02:57,000 --> 00:03:04,000
131
+ regression time and cost wise, easy to understand the point you were talking about short periods of
132
+
133
+ 34
134
+ 00:03:04,000 --> 00:03:07,000
135
+ time and a not complex project.
136
+
137
+ 35
138
+ 00:03:07,000 --> 00:03:11,000
139
+ But I also saw projects where regression takes months.
140
+
141
+ 36
142
+ 00:03:11,000 --> 00:03:13,000
143
+ Nowadays, probably it is crazy.
144
+
145
+ 37
146
+ 00:03:13,000 --> 00:03:19,000
147
+ Amount of times it will add this software product to survive in the current environment, where your
148
+
149
+ 38
150
+ 00:03:19,000 --> 00:03:26,000
151
+ competitors are releasing new features each week or two weeks and your product only has regression for
152
+
153
+ 39
154
+ 00:03:26,000 --> 00:03:26,000
155
+ one months.
156
+
157
+ 40
158
+ 00:03:27,000 --> 00:03:27,000
159
+ Definitely.
160
+
161
+ 41
162
+ 00:03:27,000 --> 00:03:30,000
163
+ Is there a different areas and domains?
164
+
165
+ 42
166
+ 00:03:30,000 --> 00:03:31,000
167
+ Some of them more competitive?
168
+
169
+ 43
170
+ 00:03:32,000 --> 00:03:33,000
171
+ Some of them less.
172
+
173
+ 44
174
+ 00:03:33,000 --> 00:03:35,000
175
+ But I am sure you understood my point.
176
+
177
+ 45
178
+ 00:03:36,000 --> 00:03:42,000
179
+ So when my clients send me about not having enough resources on the creation of automation test and
180
+
181
+ 46
182
+ 00:03:42,000 --> 00:03:48,000
183
+ framework that includes small tests, use regression tests, etc., I'm asking a simple question.
184
+
185
+ 47
186
+ 00:03:49,000 --> 00:03:55,000
187
+ I am sure that in this case, you have enough resources and needs to halt any migrations.
188
+
189
+ 48
190
+ 00:03:56,000 --> 00:04:02,000
191
+ Probably it is better to put resources into product development, marketing to the market, find investments
192
+
193
+ 49
194
+ 00:04:02,000 --> 00:04:09,000
195
+ and come to the point where we have enough resources to scale and grow because otherwise we are not
196
+
197
+ 50
198
+ 00:04:09,000 --> 00:04:12,000
199
+ doing any migration just to do migration.
200
+
201
+ 51
202
+ 00:04:12,000 --> 00:04:20,000
203
+ We need to identify purposes of the migration and be sure that our migration brings some value and it
204
+
205
+ 52
206
+ 00:04:20,000 --> 00:04:21,000
207
+ is needed.
208
+
209
+ 53
210
+ 00:04:21,000 --> 00:04:27,000
211
+ And if it is needed, we're happy to accept all imports and provide everything what is necessary to
212
+
213
+ 54
214
+ 00:04:27,000 --> 00:04:28,000
215
+ make this happen.
216
+
217
+ 55
218
+ 00:04:29,000 --> 00:04:31,000
219
+ Here's where the first principle comes from.
220
+
221
+ 56
222
+ 00:04:32,000 --> 00:04:39,000
223
+ We need to identify goals of our migration and measures to stay specific and objective.
224
+
225
+ 57
226
+ 00:04:39,000 --> 00:04:46,000
227
+ What we are trying to achieve by performance, better security, better code design in order to be able
228
+
229
+ 58
230
+ 00:04:46,000 --> 00:04:48,000
231
+ to scale application faster.
232
+
233
+ 59
234
+ 00:04:49,000 --> 00:04:53,000
235
+ This is super important and once goal is defined.
236
+
237
+ 60
238
+ 00:04:53,000 --> 00:04:56,000
239
+ Make measurements of the current system.
240
+
241
+ 61
242
+ 00:04:56,000 --> 00:04:58,000
243
+ You need to have something and other.
244
+
245
+ 62
246
+ 00:04:58,000 --> 00:05:00,000
247
+ You can say communication has been successful.
248
+
249
+ 63
250
+ 00:05:00,000 --> 00:05:06,000
251
+ Often, migration trends are the goals were achieved because at the end of the day, we never the a
252
+
253
+ 64
254
+ 00:05:06,000 --> 00:05:09,000
255
+ factor on migration just for fun.
256
+
257
+ 65
258
+ 00:05:09,000 --> 00:05:12,000
259
+ We do it to get advantage of measurable benefits.
260
+
261
+ 66
262
+ 00:05:13,000 --> 00:05:14,000
263
+ Never forget about this.
264
+
265
+ 67
266
+ 00:05:15,000 --> 00:05:21,000
267
+ Let's agree it's within the scope of this particular demo will hold migration to another long term support
268
+
269
+ 68
270
+ 00:05:21,000 --> 00:05:28,000
271
+ Java release in order to achieve better structure in order to simplify introducing of new features,
272
+
273
+ 69
274
+ 00:05:29,000 --> 00:05:35,000
275
+ improving court architecture to make each release predictable and reduce impact of introducing new changes
276
+
277
+ 70
278
+ 00:05:35,000 --> 00:05:37,000
279
+ on already released codes.
280
+
281
+ 71
282
+ 00:05:38,000 --> 00:05:39,000
283
+ Improved security.
284
+
285
+ 72
286
+ 00:05:39,000 --> 00:05:46,000
287
+ We are achieving better encapsulation of components, greater platform integrity, improved performance.
288
+
289
+ 73
290
+ 00:05:47,000 --> 00:05:52,000
291
+ These are goals of Java platform Model S system and in case you missed the previous lesson.
292
+
293
+ 74
294
+ 00:05:52,000 --> 00:06:00,000
295
+ Please watch it because we discussed goals and benefits of modules in detail in previous lesson, and
296
+
297
+ 75
298
+ 00:06:00,000 --> 00:06:03,000
299
+ we agreed to migrate our app to the modular architecture.
300
+
301
+ 76
302
+ 00:06:04,000 --> 00:06:06,000
303
+ Let's review the following steps for this.
304
+
305
+ 77
306
+ 00:06:07,000 --> 00:06:14,000
307
+ The next thing that we need to do is to download the updated JDK version Java Platform Modular System
308
+
309
+ 78
310
+ 00:06:14,000 --> 00:06:17,000
311
+ finally was introduced in Java version nine.
312
+
313
+ 79
314
+ 00:06:18,000 --> 00:06:25,000
315
+ But as we discussed in the first lesson about JDK, I would recommend you to use long term support Java
316
+
317
+ 80
318
+ 00:06:25,000 --> 00:06:25,000
319
+ versions.
320
+
321
+ 81
322
+ 00:06:26,000 --> 00:06:28,000
323
+ Nowadays, we have two long term support versions.
324
+
325
+ 82
326
+ 00:06:29,000 --> 00:06:35,000
327
+ They are eight and 11 considering that we want to migrate our app to have modular application.
328
+
329
+ 83
330
+ 00:06:36,000 --> 00:06:39,000
331
+ Most likely, we would opt for Java version 11.
332
+
333
+ 84
334
+ 00:06:39,000 --> 00:06:43,000
335
+ But you also can opt for Java version nine if you wish.
336
+
337
+ 85
338
+ 00:06:44,000 --> 00:06:46,000
339
+ Wrong application was near adjudicate.
340
+
341
+ 86
342
+ 00:06:46,000 --> 00:06:48,000
343
+ This is also important step.
344
+
345
+ 87
346
+ 00:06:48,000 --> 00:06:54,000
347
+ Java ensures backwards compatibility, but still, there might be some changes.
348
+
349
+ 88
350
+ 00:06:55,000 --> 00:07:02,000
351
+ For example, if you used some options for garbage collector, pay attention that, for example, indicate,
352
+
353
+ 89
354
+ 00:07:02,000 --> 00:07:04,000
355
+ well, some of them removed.
356
+
357
+ 90
358
+ 00:07:05,000 --> 00:07:11,000
359
+ That's why, even despite Java guarantees backwards compatibility, it is never redundant to compile
360
+
361
+ 91
362
+ 00:07:12,000 --> 00:07:14,000
363
+ and run your app with new adjudication.
364
+
365
+ 92
366
+ 00:07:15,000 --> 00:07:20,000
367
+ Also, this might be important to ensure compatibility was a by your libraries.
368
+
369
+ 93
370
+ 00:07:20,000 --> 00:07:26,000
371
+ So the main goal is to run your app on the use adjudicate mission and to deal with this task.
372
+
373
+ 94
374
+ 00:07:26,000 --> 00:07:32,000
375
+ You need to be aware about new features in Japanese that you want to use for immigration.
376
+
377
+ 95
378
+ 00:07:32,000 --> 00:07:35,000
379
+ This can be easily found on the official websites.
380
+
381
+ 96
382
+ 00:07:36,000 --> 00:07:40,000
383
+ The first step would be to update third party dependencies if needed.
384
+
385
+ 97
386
+ 00:07:40,000 --> 00:07:47,000
387
+ So we need to make sure that your app was all external dependencies may be compiled, built and started
388
+
389
+ 98
390
+ 00:07:47,000 --> 00:07:51,000
391
+ successfully Ranji DApps against your project.
392
+
393
+ 99
394
+ 00:07:52,000 --> 00:07:53,000
395
+ Enthusiasm for familiar with J.
396
+
397
+ 100
398
+ 00:07:53,000 --> 00:07:55,000
399
+ DApps and don't know what it is.
400
+
401
+ 101
402
+ 00:07:56,000 --> 00:07:57,000
403
+ Let me quickly explain.
404
+
405
+ 102
406
+ 00:07:58,000 --> 00:08:05,000
407
+ Basically, this is a tool that is present in JDK to identify dependencies between classes, modules,
408
+
409
+ 103
410
+ 00:08:05,000 --> 00:08:07,000
411
+ packages in your app.
412
+
413
+ 104
414
+ 00:08:07,000 --> 00:08:12,000
415
+ It is a common line to runs a Java Class Dependency Analyzer tool.
416
+
417
+ 105
418
+ 00:08:13,000 --> 00:08:20,000
419
+ It processes Java bytecode, meaning the class files all the jars that contains them and analyzes the
420
+
421
+ 106
422
+ 00:08:20,000 --> 00:08:23,000
423
+ statically declared dependencies between the classes.
424
+
425
+ 107
426
+ 00:08:23,000 --> 00:08:30,000
427
+ The results can be filtered in various ways and can be aggregated to package or jar level.
428
+
429
+ 108
430
+ 00:08:31,000 --> 00:08:34,000
431
+ Knapp's is also fully aware of the module system.
432
+
433
+ 109
434
+ 00:08:34,000 --> 00:08:41,000
435
+ This is super important and useful for you to understand before you plan and immigration, and before
436
+
437
+ 110
438
+ 00:08:41,000 --> 00:08:47,000
439
+ you make any final decision about your modules and packages structured a little bit later.
440
+
441
+ 111
442
+ 00:08:47,000 --> 00:08:54,000
443
+ In this lesson, I am going to show you how to work with Jade DApps program Ramji that are scrum against
444
+
445
+ 112
446
+ 00:08:54,000 --> 00:08:55,000
447
+ your project.
448
+
449
+ 113
450
+ 00:08:55,000 --> 00:08:59,000
451
+ If you're not familiar with this, though, let me quickly explain what it is.
452
+
453
+ 114
454
+ 00:09:00,000 --> 00:09:07,000
455
+ This tool is a static analysis tools its concept jar file or some other aggregation of class files for
456
+
457
+ 115
458
+ 00:09:07,000 --> 00:09:10,000
459
+ usages of deprecated API elements.
460
+
461
+ 116
462
+ 00:09:10,000 --> 00:09:18,000
463
+ When you upgrade to the new version, you might be interested in this information to to update your
464
+
465
+ 117
466
+ 00:09:18,000 --> 00:09:19,000
467
+ code accordingly.
468
+
469
+ 118
470
+ 00:09:19,000 --> 00:09:26,000
471
+ Do not accumulate dependencies on deprecated classes and masses a little bit later today on the real
472
+
473
+ 119
474
+ 00:09:26,000 --> 00:09:30,000
475
+ example, I'm going to show you how to apply this to now.
476
+
477
+ 120
478
+ 00:09:30,000 --> 00:09:36,000
479
+ After all these steps, we're safe to proceed with the next steps on this stage.
480
+
481
+ 121
482
+ 00:09:36,000 --> 00:09:43,000
483
+ Having all necessary input information, we are ready to make a decision and plan the duration we need
484
+
485
+ 122
486
+ 00:09:43,000 --> 00:09:45,000
487
+ to select the migration strategy.
488
+
489
+ 123
490
+ 00:09:45,000 --> 00:09:47,000
491
+ Today, we'll discuss a few of them.
492
+
493
+ 124
494
+ 00:09:48,000 --> 00:09:53,000
495
+ Once you select migration strategy and plan migration steps, we're going to proceed with migration
496
+
497
+ 125
498
+ 00:09:53,000 --> 00:09:54,000
499
+ execution.
500
+
501
+ 126
502
+ 00:09:55,000 --> 00:10:02,000
503
+ Usually, Oracle and community release migration guides for each new version that contains important
504
+
505
+ 127
506
+ 00:10:02,000 --> 00:10:06,000
507
+ information that you need to consider during the migration of your app.
508
+
509
+ 128
510
+ 00:10:06,000 --> 00:10:10,000
511
+ One of such goods, I will leave in attachments to the lesson.
512
+
513
+ 129
514
+ 00:10:10,000 --> 00:10:17,000
515
+ But you can easily find similar guides for other versions, and each migration should be followed by
516
+
517
+ 130
518
+ 00:10:17,000 --> 00:10:18,000
519
+ regression testing.
520
+
521
+ 131
522
+ 00:10:18,000 --> 00:10:25,000
523
+ We already discussed that even before starting doing steps like this, we need to make sure that we
524
+
525
+ 132
526
+ 00:10:25,000 --> 00:10:32,000
527
+ have reliable sort of tests that will allow us to confirm that at least nothing is broken and migration
528
+
529
+ 133
530
+ 00:10:32,000 --> 00:10:33,000
531
+ goals are achieved.
532
+
533
+ 134
534
+ 00:10:34,000 --> 00:10:39,000
535
+ After that, we are ready to proceed with a step where you can apply measurements that you did before
536
+
537
+ 135
538
+ 00:10:39,000 --> 00:10:42,000
539
+ migration to verify region of migration goals.
540
+
541
+ 136
542
+ 00:10:43,000 --> 00:10:49,000
543
+ For example, if the goal was to improve performance, measure performance of your app after migration
544
+
545
+ 137
546
+ 00:10:49,000 --> 00:10:52,000
547
+ and if performance become even worse.
548
+
549
+ 138
550
+ 00:10:52,000 --> 00:10:55,000
551
+ The question is was immigration was successful?
552
+
553
+ 139
554
+ 00:10:55,000 --> 00:10:57,000
555
+ I don't think so.
556
+
557
+ 140
558
+ 00:10:57,000 --> 00:11:02,000
559
+ That means is that some steps still need to be done and planned.
560
+
561
+ 141
562
+ 00:11:02,000 --> 00:11:08,000
563
+ This migration should be adjusted to include additional steps to reach the goal of migration.
564
+
565
+ 142
566
+ 00:11:08,000 --> 00:11:09,000
567
+ Does it make sense?
568
+
569
+ 143
570
+ 00:11:10,000 --> 00:11:14,000
571
+ So now, like the reviews it, I'll Google one more time.
572
+
573
+ 144
574
+ 00:11:15,000 --> 00:11:16,000
575
+ Press pause if needed.
576
+
577
+ 145
578
+ 00:11:17,000 --> 00:11:24,000
579
+ And once you are sure about each step and the sequence of actions we are glad to proceed is a step number
580
+
581
+ 146
582
+ 00:11:24,000 --> 00:11:25,000
583
+ zero.
584
+
585
+ 147
586
+ 00:11:25,000 --> 00:11:26,000
587
+ I have separate course for that.
588
+
589
+ 148
590
+ 00:11:27,000 --> 00:11:30,000
591
+ You can check my course got and test during development.
592
+
593
+ 149
594
+ 00:11:30,000 --> 00:11:33,000
595
+ I elaborated a lot on this topic.
596
+
597
+ 150
598
+ 00:11:33,000 --> 00:11:36,000
599
+ Step number one is up to you and your organization.
600
+
601
+ 151
602
+ 00:11:37,000 --> 00:11:42,000
603
+ You should identify goals of migration internally, and I wouldn't be able to help you with that.
604
+
605
+ 152
606
+ 00:11:43,000 --> 00:11:45,000
607
+ Do not forget to perform any measurements.
608
+
609
+ 153
610
+ 00:11:45,000 --> 00:11:51,000
611
+ How long was a goal to compare these before immigration and after migration?
612
+
613
+ 154
614
+ 00:11:52,000 --> 00:11:57,000
615
+ Regarding the loading of the latest duplicate version, I believe if you already watching this lesson,
616
+
617
+ 155
618
+ 00:11:58,000 --> 00:12:03,000
619
+ you are smart and mature enough to download Oracle JDK or open JDK.
620
+
621
+ 156
622
+ 00:12:04,000 --> 00:12:07,000
623
+ After that, you need to run your project with new JDK.
624
+
625
+ 157
626
+ 00:12:07,000 --> 00:12:13,000
627
+ I'm sure you will be able to those that want the same as updates and third party dependencies too,
628
+
629
+ 158
630
+ 00:12:14,000 --> 00:12:18,000
631
+ and with the next step, probably let me help you with that one.
632
+
633
+ 159
634
+ 00:12:19,000 --> 00:12:26,000
635
+ Let me explain to you more about the app's program, how to use it and show this on live demo.
636
+
637
+ 160
638
+ 00:12:27,000 --> 00:12:33,000
639
+ So as we have discussed, GDP is a Java dependency analysis tool, probably the first questions that
640
+
641
+ 161
642
+ 00:12:33,000 --> 00:12:39,000
643
+ students ask me is where they can get the depth and the words they should download.
644
+
645
+ 162
646
+ 00:12:39,000 --> 00:12:45,000
647
+ I want to say that you don't need to worry about that if you have dedicated, download it on your PC.
648
+
649
+ 163
650
+ 00:12:46,000 --> 00:12:47,000
651
+ This program is already is.
652
+
653
+ 164
654
+ 00:12:47,000 --> 00:12:55,000
655
+ They're waiting for you in bin folder since Java version eight will work with this tool directly from
656
+
657
+ 165
658
+ 00:12:55,000 --> 00:12:56,000
659
+ Command Prompt.
660
+
661
+ 166
662
+ 00:12:57,000 --> 00:13:03,000
663
+ So make sure that you JDK pass configure it properly and that Jane Daps Version Command returns your
664
+
665
+ 167
666
+ 00:13:04,000 --> 00:13:05,000
667
+ result in command line.
668
+
669
+ 168
670
+ 00:13:06,000 --> 00:13:11,000
671
+ Let me show you a quick them in order you could understand how to work with this still.
672
+
673
+ 169
674
+ 00:13:12,000 --> 00:13:15,000
675
+ This told me on the last group of classes.
676
+
677
+ 170
678
+ 00:13:15,000 --> 00:13:21,000
679
+ Let me show you two examples now in the first example, I will show you how to analyze old fashioned
680
+
681
+ 171
682
+ 00:13:21,000 --> 00:13:25,000
683
+ clean Java project as a simple project we are going to use.
684
+
685
+ 172
686
+ 00:13:25,000 --> 00:13:32,000
687
+ My Java project was examples, the ones that are used to demonstrate different topics to students of
688
+
689
+ 173
690
+ 00:13:32,000 --> 00:13:32,000
691
+ mine.
692
+
693
+ 174
694
+ 00:13:33,000 --> 00:13:40,000
695
+ And then the second example will analyze more single modular project that doesn't have too much dependencies
696
+
697
+ 175
698
+ 00:13:40,000 --> 00:13:44,000
699
+ between different packages and modules in case you have a general project.
700
+
701
+ 176
702
+ 00:13:44,000 --> 00:13:51,000
703
+ The first thing that you need to do is to aggregate all components resources in one folder miserably
704
+
705
+ 177
706
+ 00:13:51,000 --> 00:14:01,000
707
+ Jr. Archive in separate lessons were learned such build tools and maven granule, et cetera, that those
708
+
709
+ 178
710
+ 00:14:01,000 --> 00:14:08,000
711
+ in charge of building your project, creating some deployable pieces like jars or walls, and now a
712
+
713
+ 179
714
+ 00:14:08,000 --> 00:14:14,000
715
+ specific case would need to generate just by our cells in the clips.
716
+
717
+ 180
718
+ 00:14:14,000 --> 00:14:21,000
719
+ I can easily do this by mouse, right click on the project, find them experts option and select the
720
+
721
+ 181
722
+ 00:14:21,000 --> 00:14:21,000
723
+ jar.
724
+
725
+ 182
726
+ 00:14:21,000 --> 00:14:23,000
727
+ File some options here.
728
+
729
+ 183
730
+ 00:14:23,000 --> 00:14:32,000
731
+ Now we need to specify jar pots and place where archive will be located and generated zen numerous of
732
+
733
+ 184
734
+ 00:14:32,000 --> 00:14:32,000
735
+ other options.
736
+
737
+ 185
738
+ 00:14:33,000 --> 00:14:37,000
739
+ Majority of them are so describing I want a stop on those.
740
+
741
+ 186
742
+ 00:14:37,000 --> 00:14:44,000
743
+ But even in case you have some questions, let me know in comments below this video and I will be happy
744
+
745
+ 187
746
+ 00:14:44,000 --> 00:14:44,000
747
+ to answer.
748
+
749
+ 188
750
+ 00:14:45,000 --> 00:14:47,000
751
+ Now one, we have jar file.
752
+
753
+ 189
754
+ 00:14:47,000 --> 00:14:49,000
755
+ We are ready to analyze it.
756
+
757
+ 190
758
+ 00:14:49,000 --> 00:14:56,000
759
+ I open it bush terminal in this folder and now executes my script in this directory.
760
+
761
+ 191
762
+ 00:14:57,000 --> 00:15:02,000
763
+ Commands that I'm going to execute is stored in a common dirt file.
764
+
765
+ 192
766
+ 00:15:03,000 --> 00:15:08,000
767
+ I store the script on the Zagat index so that you could investigate it later.
768
+
769
+ 193
770
+ 00:15:08,000 --> 00:15:12,000
771
+ Let me open this script and I will explain what is the reason here.
772
+
773
+ 194
774
+ 00:15:13,000 --> 00:15:16,000
775
+ This is actually to invoke Java dependency analysis.
776
+
777
+ 195
778
+ 00:15:17,000 --> 00:15:25,000
779
+ That output is a command line option to specify a destination directory for the file output, not file
780
+
781
+ 196
782
+ 00:15:25,000 --> 00:15:32,000
783
+ content is simple tags that can be copied and pasted into the online editor, for example, or other
784
+
785
+ 197
786
+ 00:15:32,000 --> 00:15:39,000
787
+ editors to generate graphs that visualizes dependencies will generate one in the middle.
788
+
789
+ 198
790
+ 00:15:40,000 --> 00:15:44,000
791
+ You can see that they use Dot after dot output option.
792
+
793
+ 199
794
+ 00:15:44,000 --> 00:15:51,000
795
+ If you are familiar with this character, then you already know that Daughtery first is a current directory.
796
+
797
+ 200
798
+ 00:15:52,000 --> 00:15:59,000
799
+ So this means is a dirt file will be generated in the current directory, whereas this command will
800
+
801
+ 201
802
+ 00:15:59,000 --> 00:16:00,000
803
+ be executed.
804
+
805
+ 202
806
+ 00:16:01,000 --> 00:16:03,000
807
+ The next option is recursive.
808
+
809
+ 203
810
+ 00:16:03,000 --> 00:16:11,000
811
+ This option recursive the traverses or runtime dependencies plus force option specifies directory was
812
+
813
+ 204
814
+ 00:16:11,000 --> 00:16:19,000
815
+ ClassPass, including external dependencies in our particular cases, with few external dependencies
816
+
817
+ 205
818
+ 00:16:19,000 --> 00:16:20,000
819
+ on different lessons.
820
+
821
+ 206
822
+ 00:16:20,000 --> 00:16:24,000
823
+ And I don't know that these jurors into my downloads folder.
824
+
825
+ 207
826
+ 00:16:25,000 --> 00:16:32,000
827
+ That's why I also included those here, and the last program argument is just to analyze.
828
+
829
+ 208
830
+ 00:16:33,000 --> 00:16:35,000
831
+ Basically, that is the ones that we built.
832
+
833
+ 209
834
+ 00:16:36,000 --> 00:16:42,000
835
+ It contains all classes from all packages of my training project that's executed the script.
836
+
837
+ 210
838
+ 00:16:43,000 --> 00:16:48,000
839
+ I wrote the name of the script to console and press enter.
840
+
841
+ 211
842
+ 00:16:49,000 --> 00:16:56,000
843
+ It takes some time to analyze dependencies, but finally, not file is generated in the current directory.
844
+
845
+ 212
846
+ 00:16:57,000 --> 00:17:02,000
847
+ Let's open it, and you can see that the content of this file is just text.
848
+
849
+ 213
850
+ 00:17:03,000 --> 00:17:05,000
851
+ It contains some specific structure.
852
+
853
+ 214
854
+ 00:17:06,000 --> 00:17:13,000
855
+ You can see dependency of each package on another package, probably when you have session load of packages.
856
+
857
+ 215
858
+ 00:17:14,000 --> 00:17:21,000
859
+ It is even better to use this text representation to analyze this data and think about structuring new
860
+
861
+ 216
862
+ 00:17:21,000 --> 00:17:21,000
863
+ modules.
864
+
865
+ 217
866
+ 00:17:22,000 --> 00:17:27,000
867
+ But still, if you want to visualize it, let's use special tools for that.
868
+
869
+ 218
870
+ 00:17:27,000 --> 00:17:31,000
871
+ We can find online tools to visualize our dependencies.
872
+
873
+ 219
874
+ 00:17:32,000 --> 00:17:36,000
875
+ For example, we can use just one of those I'm talking about.
876
+
877
+ 220
878
+ 00:17:36,000 --> 00:17:45,000
879
+ Map Graph is just Scorpion's based content of the file based here and press generate graphs button.
880
+
881
+ 221
882
+ 00:17:45,000 --> 00:17:50,000
883
+ That was easy, but you can see how much gross dependencies we are.
884
+
885
+ 222
886
+ 00:17:51,000 --> 00:17:51,000
887
+ Definitely.
888
+
889
+ 223
890
+ 00:17:51,000 --> 00:17:57,000
891
+ There is a lot of work here, considering this is a project and a lot of different topics.
892
+
893
+ 224
894
+ 00:17:57,000 --> 00:18:04,000
895
+ Some of them very often reuses some common glosses or packages, and that's why we have something like
896
+
897
+ 225
898
+ 00:18:04,000 --> 00:18:04,000
899
+ this.
900
+
901
+ 226
902
+ 00:18:05,000 --> 00:18:08,000
903
+ You can spend time after the lesson and used to get this.
904
+
905
+ 227
906
+ 00:18:09,000 --> 00:18:11,000
907
+ I added these files in to get this.
908
+
909
+ 228
910
+ 00:18:12,000 --> 00:18:16,000
911
+ So you will be able to find those in the directory of the project.
912
+
913
+ 229
914
+ 00:18:17,000 --> 00:18:23,000
915
+ Most likely, if you would, any great all project that doesn't have more destruction, you would see
916
+
917
+ 230
918
+ 00:18:23,000 --> 00:18:24,000
919
+ something like this.
920
+
921
+ 231
922
+ 00:18:25,000 --> 00:18:26,000
923
+ Or even worse.
924
+
925
+ 232
926
+ 00:18:26,000 --> 00:18:29,000
927
+ Well, most likely you will see worse.
928
+
929
+ 233
930
+ 00:18:30,000 --> 00:18:31,000
931
+ Sorry, but this is true.
932
+
933
+ 234
934
+ 00:18:32,000 --> 00:18:39,000
935
+ OK, let's move on, and now I'd like to show you how to work with this, though, if you would like
936
+
937
+ 235
938
+ 00:18:39,000 --> 00:18:41,000
939
+ to analyze modular application.
940
+
941
+ 236
942
+ 00:18:41,000 --> 00:18:46,000
943
+ And you remember, is it a previous lesson of the creative modular application?
944
+
945
+ 237
946
+ 00:18:46,000 --> 00:18:49,000
947
+ Let's analyze dependencies for that app.
948
+
949
+ 238
950
+ 00:18:50,000 --> 00:18:56,000
951
+ The idea is similar, but instead of Java, you can pass a reference to the director with your modules
952
+
953
+ 239
954
+ 00:18:56,000 --> 00:18:59,000
955
+ so you already can make a conclusion.
956
+
957
+ 240
958
+ 00:18:59,000 --> 00:19:06,000
959
+ ZG Depths Program has separate group of command line options for modular and non modular applications.
960
+
961
+ 241
962
+ 00:19:07,000 --> 00:19:12,000
963
+ These are common ones that they want to execute is also stored in shell script.
964
+
965
+ 242
966
+ 00:19:12,000 --> 00:19:16,000
967
+ Let me open the file and we'll discuss what is written here.
968
+
969
+ 243
970
+ 00:19:17,000 --> 00:19:22,000
971
+ Also to execute shell script in the other directory, I open terminal.
972
+
973
+ 244
974
+ 00:19:23,000 --> 00:19:30,000
975
+ As you can see, I use Module First Command Line option and pauses a reference to the directory where
976
+
977
+ 245
978
+ 00:19:30,000 --> 00:19:32,000
979
+ all my module is located.
980
+
981
+ 246
982
+ 00:19:33,000 --> 00:19:39,000
983
+ Another option is that modules to add modules to zero set for analysis.
984
+
985
+ 247
986
+ 00:19:39,000 --> 00:19:46,000
987
+ I use custom to add all modules in the directory as the last option here is the list is pretty familiar
988
+
989
+ 248
990
+ 00:19:46,000 --> 00:19:47,000
991
+ to you.
992
+
993
+ 249
994
+ 00:19:47,000 --> 00:19:49,000
995
+ This is for the output.
996
+
997
+ 250
998
+ 00:19:49,000 --> 00:19:55,000
999
+ Let's execute this script in the terminal and we have generated summary file.
1000
+
1001
+ 251
1002
+ 00:19:55,000 --> 00:20:02,000
1003
+ Let's copy content from here and let me paste this content on the website to generate the graph.
1004
+
1005
+ 252
1006
+ 00:20:03,000 --> 00:20:09,000
1007
+ As you can see, code I think moves at depends on coal.
1008
+
1009
+ 253
1010
+ 00:20:09,000 --> 00:20:16,000
1011
+ I think moves greetings module and Moses and the pass on Java based module.
1012
+
1013
+ 254
1014
+ 00:20:16,000 --> 00:20:18,000
1015
+ Is it clear for you?
1016
+
1017
+ 255
1018
+ 00:20:18,000 --> 00:20:23,000
1019
+ Press a pause for a minute and sync one more time about this live demo.
1020
+
1021
+ 256
1022
+ 00:20:24,000 --> 00:20:24,000
1023
+ Thank you.
1024
+
1025
+ 257
1026
+ 00:20:24,000 --> 00:20:26,000
1027
+ Samsung is still not clear for you.
1028
+
1029
+ 258
1030
+ 00:20:27,000 --> 00:20:32,000
1031
+ Please do not hesitate to pose your question below this video, and I will be happy to answer.
1032
+
1033
+ 259
1034
+ 00:20:34,000 --> 00:20:40,000
1035
+ On the screen, you can find common long options that you may use with great depths on the slide, you
1036
+
1037
+ 260
1038
+ 00:20:40,000 --> 00:20:42,000
1039
+ can find possible options.
1040
+
1041
+ 261
1042
+ 00:20:43,000 --> 00:20:45,000
1043
+ Module dependency analysis options.
1044
+
1045
+ 262
1046
+ 00:20:46,000 --> 00:20:48,000
1047
+ Options to filter dependencies.
1048
+
1049
+ 263
1050
+ 00:20:48,000 --> 00:20:51,000
1051
+ Options to filter closest to be analyzed.
1052
+
1053
+ 264
1054
+ 00:20:51,000 --> 00:20:54,000
1055
+ And as you can see, there are a lot of them.
1056
+
1057
+ 265
1058
+ 00:20:54,000 --> 00:20:58,000
1059
+ Probably it doesn't make any sense to me holding them off each option.
1060
+
1061
+ 266
1062
+ 00:20:58,000 --> 00:21:03,000
1063
+ I believe you understood the main principle, and so I would demo was few options.
1064
+
1065
+ 267
1066
+ 00:21:03,000 --> 00:21:06,000
1067
+ You can just play with other options if you want.
1068
+
1069
+ 268
1070
+ 00:21:07,000 --> 00:21:11,000
1071
+ Feel free to pause the Ouija if you want to read all comments on the slide.
1072
+
1073
+ 269
1074
+ 00:21:12,000 --> 00:21:14,000
1075
+ OK, let's proceed.
1076
+
1077
+ 270
1078
+ 00:21:15,000 --> 00:21:21,000
1079
+ The next thing that I am going to demo you is depressed, can't program, you have a deprecated API
1080
+
1081
+ 271
1082
+ 00:21:21,000 --> 00:21:25,000
1083
+ kind of tool is a common line tool to scan for users.
1084
+
1085
+ 272
1086
+ 00:21:25,000 --> 00:21:29,000
1087
+ So deprecated API elements of given Java class files.
1088
+
1089
+ 273
1090
+ 00:21:29,000 --> 00:21:38,000
1091
+ Input glosses can be given as a bosnich to a class file and directory or jar file, the same as G Deps
1092
+
1093
+ 274
1094
+ 00:21:38,000 --> 00:21:44,000
1095
+ G Deeper Scan also has been included in genica installation since adjudicate.
1096
+
1097
+ 275
1098
+ 00:21:44,000 --> 00:21:48,000
1099
+ That means you can find that in bin folder of Dedicate.
1100
+
1101
+ 276
1102
+ 00:21:48,000 --> 00:21:54,000
1103
+ And if you configure Java POS properly, you can access it from command line.
1104
+
1105
+ 277
1106
+ 00:21:55,000 --> 00:22:01,000
1107
+ I'm going to show you example, Wisconsin, of my learning project, I put Judy Proskauer in Shell script.
1108
+
1109
+ 278
1110
+ 00:22:02,000 --> 00:22:08,000
1111
+ The simplest way how to use this command is to invoke it and pass journal names that we would like to
1112
+
1113
+ 279
1114
+ 00:22:08,000 --> 00:22:09,000
1115
+ scan.
1116
+
1117
+ 280
1118
+ 00:22:09,000 --> 00:22:12,000
1119
+ I want to execute this script and get the bus.
1120
+
1121
+ 281
1122
+ 00:22:12,000 --> 00:22:21,000
1123
+ And again, it takes some time because Project has a lot of files and it is done on the top.
1124
+
1125
+ 282
1126
+ 00:22:21,000 --> 00:22:24,000
1127
+ You can see notifications in which classes are used.
1128
+
1129
+ 283
1130
+ 00:22:24,000 --> 00:22:32,000
1131
+ Deprecated masses Knowing this information, you can just check deprecated masses, usually in documentation
1132
+
1133
+ 284
1134
+ 00:22:32,000 --> 00:22:38,000
1135
+ is deprecated mass that it is specified which other mass that you should use instead.
1136
+
1137
+ 285
1138
+ 00:22:38,000 --> 00:22:39,000
1139
+ That is simple.
1140
+
1141
+ 286
1142
+ 00:22:40,000 --> 00:22:40,000
1143
+ I agree.
1144
+
1145
+ 287
1146
+ 00:22:41,000 --> 00:22:45,000
1147
+ And this command also has few important command line options.
1148
+
1149
+ 288
1150
+ 00:22:45,000 --> 00:22:47,000
1151
+ Definitely Zionism's MS engine.
1152
+
1153
+ 289
1154
+ 00:22:47,000 --> 00:22:55,000
1155
+ That program has but still something for you, at least to be aware of response if you want to explore
1156
+
1157
+ 290
1158
+ 00:22:55,000 --> 00:22:56,000
1159
+ all these in details.
1160
+
1161
+ 291
1162
+ 00:22:57,000 --> 00:22:59,000
1163
+ And if you're OK, I will continue.
1164
+
1165
+ 292
1166
+ 00:23:00,000 --> 00:23:03,000
1167
+ Now, let's review immigration strategies.
1168
+
1169
+ 293
1170
+ 00:23:03,000 --> 00:23:09,000
1171
+ We will cover case when a regional application is based on gender versions that is less than juvenile
1172
+
1173
+ 294
1174
+ 00:23:10,000 --> 00:23:17,000
1175
+ or it is Java nine or higher, but the modular approach wasn't originally implemented since the use
1176
+
1177
+ 295
1178
+ 00:23:17,000 --> 00:23:19,000
1179
+ of this mechanism is fully optional.
1180
+
1181
+ 296
1182
+ 00:23:20,000 --> 00:23:26,000
1183
+ M. relearned tools and went through the step where we did the line, which modules draft files are present
1184
+
1185
+ 297
1186
+ 00:23:26,000 --> 00:23:30,000
1187
+ in application and what dependencies exist between them.
1188
+
1189
+ 298
1190
+ 00:23:30,000 --> 00:23:37,000
1191
+ Also, another way to do that besides such automated tools of static code analysis as DApps is through
1192
+
1193
+ 299
1194
+ 00:23:37,000 --> 00:23:42,000
1195
+ an Iraqi eagle diagram, whereas these dependencies are represented in their way.
1196
+
1197
+ 300
1198
+ 00:23:43,000 --> 00:23:49,000
1199
+ This will help give an overview of the components of the application and of each of them, and in which
1200
+
1201
+ 301
1202
+ 00:23:49,000 --> 00:23:51,000
1203
+ orders it can be migrated.
1204
+
1205
+ 302
1206
+ 00:23:51,000 --> 00:23:57,000
1207
+ Identifying those who will not be able to adopt temporally or definitively.
1208
+
1209
+ 303
1210
+ 00:23:58,000 --> 00:24:04,000
1211
+ The later case can be given, for example, insert various libraries that have stopped offering support,
1212
+
1213
+ 304
1214
+ 00:24:04,000 --> 00:24:06,000
1215
+ and that will hardly become modules.
1216
+
1217
+ 305
1218
+ 00:24:07,000 --> 00:24:12,000
1219
+ There are two different migration mechanisms that responds to different initial situations.
1220
+
1221
+ 306
1222
+ 00:24:13,000 --> 00:24:20,000
1223
+ To illustrate the process in each of them, let's imagine the next scenario we plan to migrate an application
1224
+
1225
+ 307
1226
+ 00:24:20,000 --> 00:24:25,000
1227
+ that consists of three jars representing the different layers of the application.
1228
+
1229
+ 308
1230
+ 00:24:26,000 --> 00:24:32,000
1231
+ They are application services and utilize the diagrams that you can see on the screen.
1232
+
1233
+ 309
1234
+ 00:24:32,000 --> 00:24:35,000
1235
+ Now shows the dependencies between these lists.
1236
+
1237
+ 310
1238
+ 00:24:36,000 --> 00:24:42,000
1239
+ Where application depends on services and the tiers and services depends on the utils only.
1240
+
1241
+ 311
1242
+ 00:24:42,000 --> 00:24:45,000
1243
+ Let's review Bottom-Up migration first.
1244
+
1245
+ 312
1246
+ 00:24:45,000 --> 00:24:52,000
1247
+ In this strategy, initially, all jar files that are part of the application will be located at its
1248
+
1249
+ 313
1250
+ 00:24:52,000 --> 00:24:53,000
1251
+ ClassPass.
1252
+
1253
+ 314
1254
+ 00:24:54,000 --> 00:24:56,000
1255
+ All of them can be migrated one by one.
1256
+
1257
+ 315
1258
+ 00:24:56,000 --> 00:24:58,000
1259
+ Does the module POS?
1260
+
1261
+ 316
1262
+ 00:24:58,000 --> 00:25:01,000
1263
+ To do this, we need to follow describes steps.
1264
+
1265
+ 317
1266
+ 00:25:02,000 --> 00:25:08,000
1267
+ The first thing that we need to do is to choose a project package or layer was the lowest position in
1268
+
1269
+ 318
1270
+ 00:25:08,000 --> 00:25:09,000
1271
+ dependencies.
1272
+
1273
+ 319
1274
+ 00:25:09,000 --> 00:25:12,000
1275
+ Iraqi yet has not yet been migrated to module.
1276
+
1277
+ 320
1278
+ 00:25:13,000 --> 00:25:17,000
1279
+ That means to select the project that has less dependencies.
1280
+
1281
+ 321
1282
+ 00:25:17,000 --> 00:25:20,000
1283
+ In our case, this is your deals there.
1284
+
1285
+ 322
1286
+ 00:25:20,000 --> 00:25:26,000
1287
+ After that and the module info Java file to the project, it will be needed to.
1288
+
1289
+ 323
1290
+ 00:25:26,000 --> 00:25:33,000
1291
+ Ads are quite explicit statements to make current module packages available to Iraqi Higher Level Modules
1292
+
1293
+ 324
1294
+ 00:25:33,000 --> 00:25:41,000
1295
+ Moves Integrated Project as a named module from application's class bus to its module bus ensure that
1296
+
1297
+ 325
1298
+ 00:25:41,000 --> 00:25:43,000
1299
+ all not yet migrated.
1300
+
1301
+ 326
1302
+ 00:25:43,000 --> 00:25:48,000
1303
+ The modules remain as unnamed modules in application's class bus.
1304
+
1305
+ 327
1306
+ 00:25:48,000 --> 00:25:52,000
1307
+ What is unnamed modules were discussed in previous lesson.
1308
+
1309
+ 328
1310
+ 00:25:52,000 --> 00:26:00,000
1311
+ One of the learned modules types please refer to the previous lesson through use that, if needed after
1312
+
1313
+ 329
1314
+ 00:26:00,000 --> 00:26:07,000
1315
+ we did all this is this seems it remains to do is to repeat this process was the next lowest level packages
1316
+
1317
+ 330
1318
+ 00:26:08,000 --> 00:26:10,000
1319
+ list of projects in the Iraqi.
1320
+
1321
+ 331
1322
+ 00:26:10,000 --> 00:26:15,000
1323
+ That is not migrated yet, and we are progressing in the bottom direction.
1324
+
1325
+ 332
1326
+ 00:26:15,000 --> 00:26:23,000
1327
+ Can you understand now why this strategy is called bottom up when this approach works the best and when
1328
+
1329
+ 333
1330
+ 00:26:23,000 --> 00:26:24,000
1331
+ we need to apply?
1332
+
1333
+ 334
1334
+ 00:26:24,000 --> 00:26:27,000
1335
+ The bottom up migration strategy was the best one.
1336
+
1337
+ 335
1338
+ 00:26:27,000 --> 00:26:33,000
1339
+ We have the ability to modify any jar that has not yet been converted to module.
1340
+
1341
+ 336
1342
+ 00:26:33,000 --> 00:26:41,000
1343
+ It makes easier as a migration of the project's packages was a whole layers that are at the top of the
1344
+
1345
+ 337
1346
+ 00:26:41,000 --> 00:26:47,000
1347
+ dependency diagram and encourages care in what is exposed to other modules.
1348
+
1349
+ 338
1350
+ 00:26:48,000 --> 00:26:54,000
1351
+ The modules of the lower levels of the Iraqi will be found in the module costs without access to the
1352
+
1353
+ 339
1354
+ 00:26:54,000 --> 00:26:56,000
1355
+ packages of unnamed modules.
1356
+
1357
+ 340
1358
+ 00:26:57,000 --> 00:27:03,000
1359
+ While these unnamed modules that have not been migrated and allocated in the class, ClassPass will
1360
+
1361
+ 341
1362
+ 00:27:03,000 --> 00:27:09,000
1363
+ be able to access zip packages located in both class and module bus.
1364
+
1365
+ 342
1366
+ 00:27:10,000 --> 00:27:11,000
1367
+ Does it make sense so far?
1368
+
1369
+ 343
1370
+ 00:27:13,000 --> 00:27:19,000
1371
+ And now is immigration strategy would be top down in this strategy, initially, all jar files that
1372
+
1373
+ 344
1374
+ 00:27:19,000 --> 00:27:25,000
1375
+ are part of the application will be located at its model bus, so all non-immigrant its projects are
1376
+
1377
+ 345
1378
+ 00:27:25,000 --> 00:27:27,000
1379
+ treated as automatic modules.
1380
+
1381
+ 346
1382
+ 00:27:28,000 --> 00:27:31,000
1383
+ Greatest lesson I current or what automatic modules are.
1384
+
1385
+ 347
1386
+ 00:27:32,000 --> 00:27:36,000
1387
+ So please make sure you watch the previous lesson about modules.
1388
+
1389
+ 348
1390
+ 00:27:36,000 --> 00:27:44,000
1391
+ If you forget, this is example when I didn't use modular approach since it is optional in this case,
1392
+
1393
+ 349
1394
+ 00:27:44,000 --> 00:27:47,000
1395
+ it is recommended to frozen next steps.
1396
+
1397
+ 350
1398
+ 00:27:47,000 --> 00:27:54,000
1399
+ The first thing to do is to choose a high level project and the dependencies Iraqi that has not yet
1400
+
1401
+ 351
1402
+ 00:27:54,000 --> 00:27:56,000
1403
+ been integrated the module.
1404
+
1405
+ 352
1406
+ 00:27:56,000 --> 00:28:03,000
1407
+ After that, we need to add some module info gel file to the project to transform it from an automatic
1408
+
1409
+ 353
1410
+ 00:28:03,000 --> 00:28:05,000
1411
+ module to a named module.
1412
+
1413
+ 354
1414
+ 00:28:06,000 --> 00:28:12,000
1415
+ Also, we shouldn't forget to add necessary expert statements to make current module packages available
1416
+
1417
+ 355
1418
+ 00:28:12,000 --> 00:28:20,000
1419
+ to other modules and the necessary require statements that makes available OSM modules expose packages
1420
+
1421
+ 356
1422
+ 00:28:20,000 --> 00:28:25,000
1423
+ to the current one in case of the reference to a module not yet migrated.
1424
+
1425
+ 357
1426
+ 00:28:26,000 --> 00:28:29,000
1427
+ It should be done through its automatic module name.
1428
+
1429
+ 358
1430
+ 00:28:29,000 --> 00:28:36,000
1431
+ Once these have been migrated, these references should be changed to Z definitive module names.
1432
+
1433
+ 359
1434
+ 00:28:37,000 --> 00:28:41,000
1435
+ Repeat this process was the next high level component.
1436
+
1437
+ 360
1438
+ 00:28:41,000 --> 00:28:44,000
1439
+ Is Iraqi citizens not migrated yet?
1440
+
1441
+ 361
1442
+ 00:28:44,000 --> 00:28:49,000
1443
+ Then the stunt in which case is top down strategy needs to be applied and robust at best.
1444
+
1445
+ 362
1446
+ 00:28:50,000 --> 00:28:55,000
1447
+ This strategy is the best when you don't have the possibility of one day on the horizon.
1448
+
1449
+ 363
1450
+ 00:28:55,000 --> 00:29:00,000
1451
+ All the dependencies of the application was a temporarily or definitively.
1452
+
1453
+ 364
1454
+ 00:29:01,000 --> 00:29:06,000
1455
+ Also, the lower dependencies of the application have not yet been modularized.
1456
+
1457
+ 365
1458
+ 00:29:06,000 --> 00:29:10,000
1459
+ The application itself can be converted into morning.
1460
+
1461
+ 366
1462
+ 00:29:10,000 --> 00:29:15,000
1463
+ Named modules that have already been integrated will be found in the module.
1464
+
1465
+ 367
1466
+ 00:29:15,000 --> 00:29:22,000
1467
+ Boss was access to the entire code contained in the automatic modules that are also found in module
1468
+
1469
+ 368
1470
+ 00:29:22,000 --> 00:29:22,000
1471
+ path.
1472
+
1473
+ 369
1474
+ 00:29:23,000 --> 00:29:23,000
1475
+ Is that clear?
1476
+
1477
+ 370
1478
+ 00:29:24,000 --> 00:29:26,000
1479
+ And remember another important sync?
1480
+
1481
+ 371
1482
+ 00:29:27,000 --> 00:29:31,000
1483
+ In all cases, we have to avoid circle of dependencies between modules.
1484
+
1485
+ 372
1486
+ 00:29:32,000 --> 00:29:34,000
1487
+ That's all what I wanted to share with you in this lesson.
1488
+
1489
+ 373
1490
+ 00:29:35,000 --> 00:29:37,000
1491
+ Let's recap what we have learned today.
1492
+
1493
+ 374
1494
+ 00:29:38,000 --> 00:29:44,000
1495
+ After this lesson, you know, general algorithm to follow during the platform, migration to the new
1496
+
1497
+ 375
1498
+ 00:29:44,000 --> 00:29:48,000
1499
+ environment or in US adjudicate version in particular.
1500
+
1501
+ 376
1502
+ 00:29:48,000 --> 00:29:57,000
1503
+ I showed you how to use in practice Java Class Dependency Analyzer to also we used how to use Java deprecated
1504
+
1505
+ 377
1506
+ 00:29:57,000 --> 00:30:05,000
1507
+ API second to review of different migration strategies, namely, we bottom up and top down migration
1508
+
1509
+ 378
1510
+ 00:30:05,000 --> 00:30:05,000
1511
+ strategies.
1512
+
1513
+ 379
1514
+ 00:30:06,000 --> 00:30:11,000
1515
+ I hope you'll love this lesson and learned a lot of new useful sinks.
1516
+
1517
+ 380
1518
+ 00:30:12,000 --> 00:30:13,000
1519
+ Thanks a lot for your attention.
1520
+
1521
+ 381
1522
+ 00:30:14,000 --> 00:30:17,000
1523
+ Have a great day and see you in the next lesson.
1524
+
32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 Modular-application-example-with-bash-scripts.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/java-modules
32 - Java Platform Module System Modules in Java & Migration of Java Apps/002 Non-modular-application-example-with-bash-scripts.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core
32 - Java Platform Module System Modules in Java & Migration of Java Apps/external-links.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ 001 Source-code-examples-from-the-lesson-Modular-Project
3
+ https://github.com/AndriiPiatakha/java-modules
4
+
5
+ 002 -Example-Migration-Guide-by-Oracle
6
+ https://docs.oracle.com/en/java/javase/12/migrate/index.html#JSMIG-GUID-C25E2B1D-6C24-4403-8540-CFEA875B994A
7
+
8
+ 002 Non-modular-application-example-with-bash-scripts
9
+ https://github.com/AndriiPiatakha/learnit_java_core
10
+
11
+ 002 Modular-application-example-with-bash-scripts
12
+ https://github.com/AndriiPiatakha/java-modules
33 - Testing for Software Engineers/001 Testing for software engineers Overview_en.srt ADDED
@@ -0,0 +1,1308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:06,000
3
+ Hello, dissidents.
4
+
5
+ 2
6
+ 00:00:07,000 --> 00:00:10,000
7
+ Today we start an important topic for each software engineer.
8
+
9
+ 3
10
+ 00:00:10,000 --> 00:00:15,000
11
+ We are going to learn with your tools and techniques that will help you to make sure that your codes
12
+
13
+ 4
14
+ 00:00:15,000 --> 00:00:22,000
15
+ work as expected and to guarantee that each new change didn't break old code already released features.
16
+
17
+ 5
18
+ 00:00:22,000 --> 00:00:24,000
19
+ We'll talk about testing today.
20
+
21
+ 6
22
+ 00:00:25,000 --> 00:00:28,000
23
+ Don't worry, this is not cause for quality assurance engineers.
24
+
25
+ 7
26
+ 00:00:29,000 --> 00:00:31,000
27
+ This is still cause for software developers.
28
+
29
+ 8
30
+ 00:00:32,000 --> 00:00:35,000
31
+ You're saying that this is cause for fear automation engineers.
32
+
33
+ 9
34
+ 00:00:35,000 --> 00:00:36,000
35
+ You're wrong again.
36
+
37
+ 10
38
+ 00:00:37,000 --> 00:00:42,000
39
+ The first thing you have to learn is that software engineers also write tests on regular basis.
40
+
41
+ 11
42
+ 00:00:42,000 --> 00:00:47,000
43
+ This is a little bit different kind of tests that usually perform key engineers.
44
+
45
+ 12
46
+ 00:00:47,000 --> 00:00:51,000
47
+ And today we're going to learn what testing is after this lesson.
48
+
49
+ 13
50
+ 00:00:51,000 --> 00:00:54,000
51
+ You understand why we need to write this.
52
+
53
+ 14
54
+ 00:00:54,000 --> 00:00:57,000
55
+ I will elaborate on different functions of testing.
56
+
57
+ 15
58
+ 00:00:57,000 --> 00:01:02,000
59
+ You will get a full picture of different types and different levels of testing, and you will understand
60
+
61
+ 16
62
+ 00:01:02,000 --> 00:01:04,000
63
+ what testing is.
64
+
65
+ 17
66
+ 00:01:04,000 --> 00:01:09,000
67
+ And this lesson will run main principles and rules that should be followed during the testing.
68
+
69
+ 18
70
+ 00:01:10,000 --> 00:01:15,000
71
+ By the end of this lesson, you will understand what kind of tests software engineers usually write.
72
+
73
+ 19
74
+ 00:01:16,000 --> 00:01:21,000
75
+ Also, you're going to understand the structure of our following lessons and what we will learn first.
76
+
77
+ 20
78
+ 00:01:22,000 --> 00:01:26,000
79
+ Let's start and to start with, let's define the goal of testing.
80
+
81
+ 21
82
+ 00:01:26,000 --> 00:01:29,000
83
+ How do think why we are so buzzer?
84
+
85
+ 22
86
+ 00:01:29,000 --> 00:01:32,000
87
+ It's about testing and what its main goal?
88
+
89
+ 23
90
+ 00:01:32,000 --> 00:01:37,000
91
+ Take a second and think to at least a few options and choose the main one, in your opinion.
92
+
93
+ 24
94
+ 00:01:38,000 --> 00:01:40,000
95
+ My answer would be the next one.
96
+
97
+ 25
98
+ 00:01:40,000 --> 00:01:47,000
99
+ The main goal is to verify that application works as expected, and the key to your success is to make
100
+
101
+ 26
102
+ 00:01:47,000 --> 00:01:54,000
103
+ sure that the last part of this sentence, namely, as expected, is defined clearly and the same for
104
+
105
+ 27
106
+ 00:01:54,000 --> 00:01:55,000
107
+ you and product owner.
108
+
109
+ 28
110
+ 00:01:55,000 --> 00:02:00,000
111
+ In this course, we will learn a few techniques like behavior driven development and acceptance during
112
+
113
+ 29
114
+ 00:02:00,000 --> 00:02:06,000
115
+ development that should eliminate the gap in the understanding of the final product between you and
116
+
117
+ 30
118
+ 00:02:06,000 --> 00:02:07,000
119
+ product owner.
120
+
121
+ 31
122
+ 00:02:08,000 --> 00:02:14,000
123
+ And that is our goal that uses a proper set of tests that will verify various scenarios to make sure
124
+
125
+ 32
126
+ 00:02:14,000 --> 00:02:18,000
127
+ that behavior of our application meets expectations of the product owner.
128
+
129
+ 33
130
+ 00:02:19,000 --> 00:02:21,000
131
+ In this lesson, I will use product owner.
132
+
133
+ 34
134
+ 00:02:21,000 --> 00:02:23,000
135
+ Time to time my senses.
136
+
137
+ 35
138
+ 00:02:23,000 --> 00:02:29,000
139
+ I'm a person who is in charge of final acceptance of the software that you and your team will create
140
+
141
+ 36
142
+ 00:02:30,000 --> 00:02:30,000
143
+ products on.
144
+
145
+ 37
146
+ 00:02:30,000 --> 00:02:35,000
147
+ There can be within your organization or outside of your organization, like it usually happens if you
148
+
149
+ 38
150
+ 00:02:35,000 --> 00:02:37,000
151
+ work in outsourcing company.
152
+
153
+ 39
154
+ 00:02:37,000 --> 00:02:44,000
155
+ Usually, product owner is closer to the business side in the war, in the commercial side, and how
156
+
157
+ 40
158
+ 00:02:44,000 --> 00:02:47,000
159
+ application will satisfy needs of potential customers.
160
+
161
+ 41
162
+ 00:02:48,000 --> 00:02:54,000
163
+ Also, product owner worried about features, user experience and all that is related to the application.
164
+
165
+ 42
166
+ 00:02:55,000 --> 00:02:57,000
167
+ But Pure is not a technical person.
168
+
169
+ 43
170
+ 00:02:58,000 --> 00:03:02,000
171
+ You're going to be able to explain to people that something is not possible because it will require
172
+
173
+ 44
174
+ 00:03:02,000 --> 00:03:06,000
175
+ to implement a lot of classes and use a lot of external libraries.
176
+
177
+ 45
178
+ 00:03:07,000 --> 00:03:10,000
179
+ Usually you are doesn't care about all technical stuff.
180
+
181
+ 46
182
+ 00:03:11,000 --> 00:03:16,000
183
+ He cares only about end product and about meetings of functional and non-functional requirements.
184
+
185
+ 47
186
+ 00:03:17,000 --> 00:03:21,000
187
+ Understanding that your work should be accepted by non-technical person is a key.
188
+
189
+ 48
190
+ 00:03:22,000 --> 00:03:27,000
191
+ Usually only see you guys can learn how to talk with product owners, but not always, unfortunately.
192
+
193
+ 49
194
+ 00:03:28,000 --> 00:03:35,000
195
+ But understanding your PR and preparing a set of tests that verifies expected behavior will help you
196
+
197
+ 50
198
+ 00:03:35,000 --> 00:03:37,000
199
+ to reach the expected quality level.
200
+
201
+ 51
202
+ 00:03:37,000 --> 00:03:41,000
203
+ We have just said something about quality and reached an expected quality level.
204
+
205
+ 52
206
+ 00:03:42,000 --> 00:03:47,000
207
+ But what is actually a quality that different definitions of a quality?
208
+
209
+ 53
210
+ 00:03:47,000 --> 00:03:52,000
211
+ But my own you finish that, in my opinion, describes the quality and software engineer is the most
212
+
213
+ 54
214
+ 00:03:52,000 --> 00:03:53,000
215
+ accurate way.
216
+
217
+ 55
218
+ 00:03:54,000 --> 00:03:58,000
219
+ It sounds like the following quality is a degree of compliance with the requirements.
220
+
221
+ 56
222
+ 00:03:59,000 --> 00:04:02,000
223
+ Good quality means complete compliance with requirements.
224
+
225
+ 57
226
+ 00:04:03,000 --> 00:04:05,000
227
+ That quality means opposite.
228
+
229
+ 58
230
+ 00:04:05,000 --> 00:04:07,000
231
+ Does it make sense homes?
232
+
233
+ 59
234
+ 00:04:07,000 --> 00:04:13,000
235
+ Does it use your understanding what quality is and what we as developers will try to pursue?
236
+
237
+ 60
238
+ 00:04:13,000 --> 00:04:17,000
239
+ And we need to right this to meet the expected level of quality?
240
+
241
+ 61
242
+ 00:04:17,000 --> 00:04:19,000
243
+ What else do we need?
244
+
245
+ 62
246
+ 00:04:19,000 --> 00:04:25,000
247
+ The right tests thus have their own users to understand why we have to write this.
248
+
249
+ 63
250
+ 00:04:25,000 --> 00:04:30,000
251
+ Let's review functions that are in charge of increasing team productivity.
252
+
253
+ 64
254
+ 00:04:30,000 --> 00:04:36,000
255
+ Team productivity is increased with tests because time spent on regression and manual testing is significantly
256
+
257
+ 65
258
+ 00:04:36,000 --> 00:04:37,000
259
+ reduced.
260
+
261
+ 66
262
+ 00:04:38,000 --> 00:04:44,000
263
+ I believe that you would love to perform some testing after implementation of a new feature or after
264
+
265
+ 67
266
+ 00:04:44,000 --> 00:04:45,000
267
+ small changes, don't you?
268
+
269
+ 68
270
+ 00:04:46,000 --> 00:04:49,000
271
+ And as your program grew, it will take more time to test average soon.
272
+
273
+ 69
274
+ 00:04:50,000 --> 00:04:57,000
275
+ That's why we developers want to put automated tests on place that will help us to perform checks and
276
+
277
+ 70
278
+ 00:04:57,000 --> 00:05:01,000
279
+ now multiplies this benefit by each team member with.
280
+
281
+ 71
282
+ 00:05:02,000 --> 00:05:10,000
283
+ Each team member would have a possibility to run them and verify state of the app in no time limit need
284
+
285
+ 72
286
+ 00:05:10,000 --> 00:05:10,000
287
+ for the bargain.
288
+
289
+ 73
290
+ 00:05:11,000 --> 00:05:17,000
291
+ This is super important in case you've found some defect in your program haven't pursued the course.
292
+
293
+ 74
294
+ 00:05:17,000 --> 00:05:23,000
295
+ All your application can help you easily identify where defect is in the best case.
296
+
297
+ 75
298
+ 00:05:23,000 --> 00:05:29,000
299
+ Some specific test will be failed, and you will find defect instantly without debugging.
300
+
301
+ 76
302
+ 00:05:29,000 --> 00:05:32,000
303
+ In case your tests, you didn't intend to find the defect.
304
+
305
+ 77
306
+ 00:05:33,000 --> 00:05:39,000
307
+ That means some test case is missed, and the first thing you have to do in this case is write new tests
308
+
309
+ 78
310
+ 00:05:39,000 --> 00:05:42,000
311
+ that will cover an error that was missed.
312
+
313
+ 79
314
+ 00:05:42,000 --> 00:05:49,000
315
+ Instead of running and fixing this defect as fast as possible, confidence during the refactoring Rifaximin
316
+
317
+ 80
318
+ 00:05:49,000 --> 00:05:56,000
319
+ is a process of restructuring existing code without changing its external behavior and joins a refactoring,
320
+
321
+ 81
322
+ 00:05:56,000 --> 00:06:00,000
323
+ you have to be sure that you didn't break any existing functionality.
324
+
325
+ 82
326
+ 00:06:01,000 --> 00:06:08,000
327
+ For example, you want to remove redundant code duplication or you want to regroup files in one package
328
+
329
+ 83
330
+ 00:06:08,000 --> 00:06:14,000
331
+ or something else, and you have to be sure that you didn't accidentally remove code that is needed.
332
+
333
+ 84
334
+ 00:06:14,000 --> 00:06:19,000
335
+ Having ensued of tests, you can constantly run them to make sure you didn't break ineson.
336
+
337
+ 85
338
+ 00:06:20,000 --> 00:06:25,000
339
+ Clean cut and good architecture design in this course, we will also learn test driven development and
340
+
341
+ 86
342
+ 00:06:25,000 --> 00:06:26,000
343
+ how it works.
344
+
345
+ 87
346
+ 00:06:26,000 --> 00:06:33,000
347
+ The huge advantage of this approach is that it fosters being caught and the reliable architecture design.
348
+
349
+ 88
350
+ 00:06:34,000 --> 00:06:35,000
351
+ In simple words, right?
352
+
353
+ 89
354
+ 00:06:35,000 --> 00:06:41,000
355
+ And this make you think what level of abstraction is needed in your application, how you would like
356
+
357
+ 90
358
+ 00:06:41,000 --> 00:06:43,000
359
+ to group classes into packages.
360
+
361
+ 91
362
+ 00:06:44,000 --> 00:06:47,000
363
+ What access modifiers should be used for fields and masses and so on.
364
+
365
+ 92
366
+ 00:06:48,000 --> 00:06:55,000
367
+ And writing does first helps you to create more usable architecture of your application name and task
368
+
369
+ 93
370
+ 00:06:56,000 --> 00:06:57,000
371
+ coverage matchweek.
372
+
373
+ 94
374
+ 00:06:57,000 --> 00:07:04,000
375
+ This function seems to be not very useful for you, but sometimes it's important for our customers when
376
+
377
+ 95
378
+ 00:07:04,000 --> 00:07:09,000
379
+ you work in outsourcing, company managers from customer site would require from you to provide such
380
+
381
+ 96
382
+ 00:07:09,000 --> 00:07:15,000
383
+ metric as desk with coverage that will show how much of the code and application are covered with tests.
384
+
385
+ 97
386
+ 00:07:16,000 --> 00:07:22,000
387
+ By the end of this course, you will learn that there is no direct dependency between test code coverage,
388
+
389
+ 98
390
+ 00:07:22,000 --> 00:07:24,000
391
+ magic and quality of your application.
392
+
393
+ 99
394
+ 00:07:24,000 --> 00:07:30,000
395
+ Also, tests could be written in order to just increase desk with coverage metric, but not actually
396
+
397
+ 100
398
+ 00:07:30,000 --> 00:07:31,000
399
+ test your code.
400
+
401
+ 101
402
+ 00:07:31,000 --> 00:07:37,000
403
+ I'll show you how this can be, and I'll teach you how to write tests that will actually help you to
404
+
405
+ 102
406
+ 00:07:37,000 --> 00:07:40,000
407
+ decrease potential number of defects and the last.
408
+
409
+ 103
410
+ 00:07:40,000 --> 00:07:46,000
411
+ But in my opinion, one of the most important duties of tests is to serve as a documentation for your
412
+
413
+ 104
414
+ 00:07:46,000 --> 00:07:47,000
415
+ application.
416
+
417
+ 105
418
+ 00:07:47,000 --> 00:07:51,000
419
+ Very often, engineers don't write tests for their code.
420
+
421
+ 106
422
+ 00:07:51,000 --> 00:07:58,000
423
+ But when generation of people who support this project is changed, nobody can understand why they need
424
+
425
+ 107
426
+ 00:07:58,000 --> 00:08:04,000
427
+ this class or why they need this private method and how critical it is or why.
428
+
429
+ 108
430
+ 00:08:04,000 --> 00:08:07,000
431
+ Before storing the database, some additional request is sent.
432
+
433
+ 109
434
+ 00:08:08,000 --> 00:08:12,000
435
+ Is that business requirements or just redundant method invocation?
436
+
437
+ 110
438
+ 00:08:12,000 --> 00:08:19,000
439
+ Well, I imagine that you want on board new team member and instead of telling him or her how to initialize
440
+
441
+ 111
442
+ 00:08:19,000 --> 00:08:25,000
443
+ some objects or what should happen to calculate discount for specific user, you just provide him with
444
+
445
+ 112
446
+ 00:08:25,000 --> 00:08:26,000
447
+ a link to your test.
448
+
449
+ 113
450
+ 00:08:26,000 --> 00:08:33,000
451
+ Well, and as described writing tests, it is similar to having the client that is using your code,
452
+
453
+ 114
454
+ 00:08:33,000 --> 00:08:36,000
455
+ and everyone can investigate how to use your code.
456
+
457
+ 115
458
+ 00:08:37,000 --> 00:08:40,000
459
+ Oh, now you have full and clear picture why we need that.
460
+
461
+ 116
462
+ 00:08:41,000 --> 00:08:46,000
463
+ Let me remind you that in case you have any questions regarding materials that I have shared, you can
464
+
465
+ 117
466
+ 00:08:46,000 --> 00:08:49,000
467
+ always ask it in the Q&A section of this lesson.
468
+
469
+ 118
470
+ 00:08:49,000 --> 00:08:51,000
471
+ Let's move on now.
472
+
473
+ 119
474
+ 00:08:51,000 --> 00:08:54,000
475
+ I want to discuss with you different approaches in testing.
476
+
477
+ 120
478
+ 00:08:55,000 --> 00:08:58,000
479
+ This will help you to better understand different levels of testing.
480
+
481
+ 121
482
+ 00:08:59,000 --> 00:09:04,000
483
+ There are two main methods of testing Ziya black box testing and one box testing.
484
+
485
+ 122
486
+ 00:09:04,000 --> 00:09:10,000
487
+ Black box testing is a method of software testing that examines the functionality of an application
488
+
489
+ 123
490
+ 00:09:10,000 --> 00:09:14,000
491
+ without peer into its internal structures or workings.
492
+
493
+ 124
494
+ 00:09:14,000 --> 00:09:18,000
495
+ There is no need to have all specifics and details of the code structure.
496
+
497
+ 125
498
+ 00:09:19,000 --> 00:09:23,000
499
+ Testers should be aware of expected the behavior of the application.
500
+
501
+ 126
502
+ 00:09:23,000 --> 00:09:29,000
503
+ In other words, according to black box approach, testers should know what applications should do,
504
+
505
+ 127
506
+ 00:09:29,000 --> 00:09:32,000
507
+ but not necessarily how application does this.
508
+
509
+ 128
510
+ 00:09:33,000 --> 00:09:39,000
511
+ On the other hand, white box testing that is also known as a glass box test and transparent box testing
512
+
513
+ 129
514
+ 00:09:39,000 --> 00:09:46,000
515
+ is a method of software testing that test in general structures or rockets of an application as opposed
516
+
517
+ 130
518
+ 00:09:46,000 --> 00:09:49,000
519
+ to its functionality and black box testing.
520
+
521
+ 131
522
+ 00:09:50,000 --> 00:09:55,000
523
+ Depending on which level of testing you perform verification activities, you can apply one or another
524
+
525
+ 132
526
+ 00:09:55,000 --> 00:09:56,000
527
+ method.
528
+
529
+ 133
530
+ 00:09:56,000 --> 00:09:59,000
531
+ Let's hear on what levels of testing exist.
532
+
533
+ 134
534
+ 00:09:59,000 --> 00:10:02,000
535
+ There are multiple testing levels in some literature.
536
+
537
+ 135
538
+ 00:10:02,000 --> 00:10:08,000
539
+ You might find four levels, zero unit integration system and acceptance testing.
540
+
541
+ 136
542
+ 00:10:09,000 --> 00:10:14,000
543
+ Let's review each layer one by one and understand what is the difference between the levels.
544
+
545
+ 137
546
+ 00:10:15,000 --> 00:10:17,000
547
+ Each of the level has its own purpose.
548
+
549
+ 138
550
+ 00:10:17,000 --> 00:10:22,000
551
+ For example, goal of unit testing is to test the smallest unit.
552
+
553
+ 139
554
+ 00:10:22,000 --> 00:10:26,000
555
+ Usually, it is considered to be the completion unit in Jawa.
556
+
557
+ 140
558
+ 00:10:26,000 --> 00:10:27,000
559
+ This is one class.
560
+
561
+ 141
562
+ 00:10:28,000 --> 00:10:32,000
563
+ Typically, this type of testing is performed by a programmer, but not a tester.
564
+
565
+ 142
566
+ 00:10:32,000 --> 00:10:37,000
567
+ And there's an understanding that on this level, you may want to apply white box approach you as a
568
+
569
+ 143
570
+ 00:10:37,000 --> 00:10:44,000
571
+ test, and you have to verify that all massive in this unit works as expected and unifies this without
572
+
573
+ 144
574
+ 00:10:44,000 --> 00:10:46,000
575
+ any interaction with other components.
576
+
577
+ 145
578
+ 00:10:47,000 --> 00:10:50,000
579
+ Just testing of one single unit is elation.
580
+
581
+ 146
582
+ 00:10:50,000 --> 00:10:55,000
583
+ The next level of testing is integration testing on this level of testing.
584
+
585
+ 147
586
+ 00:10:55,000 --> 00:11:00,000
587
+ Our goal is to make sure that components work together and may interact between each other.
588
+
589
+ 148
590
+ 00:11:01,000 --> 00:11:07,000
591
+ For example, you want to test that after user registration, he or she receives welcome email, and
592
+
593
+ 149
594
+ 00:11:07,000 --> 00:11:09,000
595
+ this amount is sent by another class.
596
+
597
+ 150
598
+ 00:11:09,000 --> 00:11:15,000
599
+ Your test should include scenarios that will verify that after registration, email is sent.
600
+
601
+ 151
602
+ 00:11:16,000 --> 00:11:18,000
603
+ That's why it is called integration testing.
604
+
605
+ 152
606
+ 00:11:19,000 --> 00:11:25,000
607
+ The next level of testing is a system testing system, testing is performed on a complete integrated
608
+
609
+ 153
610
+ 00:11:25,000 --> 00:11:26,000
611
+ system.
612
+
613
+ 154
614
+ 00:11:26,000 --> 00:11:30,000
615
+ It allows checking systems compliance as per the requirements.
616
+
617
+ 155
618
+ 00:11:30,000 --> 00:11:37,000
619
+ Usually, system testing includes performance security testing, system testing most often the final
620
+
621
+ 156
622
+ 00:11:37,000 --> 00:11:44,000
623
+ test to verify that the system is a specification, it verifies both functional and non-functional requirements.
624
+
625
+ 157
626
+ 00:11:44,000 --> 00:11:50,000
627
+ And finally, acceptance testing acceptance testing is a test conducted to find if all requirements
628
+
629
+ 158
630
+ 00:11:50,000 --> 00:11:50,000
631
+ are met.
632
+
633
+ 159
634
+ 00:11:51,000 --> 00:11:54,000
635
+ That's final level of testing before acceptance.
636
+
637
+ 160
638
+ 00:11:54,000 --> 00:11:59,000
639
+ Software product unions acceptance testing, we have to give an answer whether product is ready for
640
+
641
+ 161
642
+ 00:11:59,000 --> 00:12:00,000
643
+ release.
644
+
645
+ 162
646
+ 00:12:00,000 --> 00:12:02,000
647
+ That's it regarding testing levels.
648
+
649
+ 163
650
+ 00:12:02,000 --> 00:12:05,000
651
+ I hope this gives you an understanding of the whole test process.
652
+
653
+ 164
654
+ 00:12:06,000 --> 00:12:10,000
655
+ Usually, software developers are in charge or writing unit integration.
656
+
657
+ 165
658
+ 00:12:10,000 --> 00:12:15,000
659
+ That's sometimes functional tests can be written by key automation engineers.
660
+
661
+ 166
662
+ 00:12:15,000 --> 00:12:20,000
663
+ And then the course we're going to learn the tools and techniques that will help you to write tests.
664
+
665
+ 167
666
+ 00:12:21,000 --> 00:12:24,000
667
+ Also, I'd like to cover today was your test and concept.
668
+
669
+ 168
670
+ 00:12:25,000 --> 00:12:26,000
671
+ What is this?
672
+
673
+ 169
674
+ 00:12:26,000 --> 00:12:33,000
675
+ Impairment test impairment is a framework that can help both developers and kids to create high quality
676
+
677
+ 170
678
+ 00:12:33,000 --> 00:12:34,000
679
+ software.
680
+
681
+ 171
682
+ 00:12:34,000 --> 00:12:41,000
683
+ It reduces the time required for developers to identify if a change they introduce Brexit code.
684
+
685
+ 172
686
+ 00:12:41,000 --> 00:12:45,000
687
+ It can also be helpful in building a more reliable tests.
688
+
689
+ 173
690
+ 00:12:46,000 --> 00:12:52,000
691
+ Essentially, the testing permit also referred to as test automation pyramid.
692
+
693
+ 174
694
+ 00:12:52,000 --> 00:12:59,000
695
+ These are the types of tests that should be included in an automated tests used on different test levels.
696
+
697
+ 175
698
+ 00:12:59,000 --> 00:13:03,000
699
+ It also outlines a sequence and frequency of these tests.
700
+
701
+ 176
702
+ 00:13:04,000 --> 00:13:11,000
703
+ The whole point is to offer immediate feedback to ensure that the code changes do not disrupt existing
704
+
705
+ 177
706
+ 00:13:11,000 --> 00:13:19,000
707
+ features so we can treat this impairment as way of thinking how we can balance different types of tests
708
+
709
+ 178
710
+ 00:13:19,000 --> 00:13:26,000
711
+ on different levels and important conclusions that we can make out of the testing pyramid is that we
712
+
713
+ 179
714
+ 00:13:26,000 --> 00:13:29,000
715
+ have to have solid layer of unit tests.
716
+
717
+ 180
718
+ 00:13:29,000 --> 00:13:35,000
719
+ And on the basis of unit tests, you build your pyramid on ozone levels of testing.
720
+
721
+ 181
722
+ 00:13:35,000 --> 00:13:42,000
723
+ This pyramid provides all team was right priorities in case the management team puts significant focus
724
+
725
+ 182
726
+ 00:13:42,000 --> 00:13:49,000
727
+ on the tests without paying attention, the unit does the higher chances of missing some critical defect.
728
+
729
+ 183
730
+ 00:13:49,000 --> 00:13:54,000
731
+ You must say that in case you will have only internal tests, that means you are completely covered
732
+
733
+ 184
734
+ 00:13:54,000 --> 00:13:57,000
735
+ from defects that important customer and product owner.
736
+
737
+ 185
738
+ 00:13:57,000 --> 00:13:59,000
739
+ But what about functions of testing?
740
+
741
+ 186
742
+ 00:14:00,000 --> 00:14:02,000
743
+ Yet this serves as a documentation.
744
+
745
+ 187
746
+ 00:14:02,000 --> 00:14:05,000
747
+ Two unit tests are forced to execute.
748
+
749
+ 188
750
+ 00:14:06,000 --> 00:14:13,000
751
+ Usually, internal tests requires all components of application up and running, and this could be not
752
+
753
+ 189
754
+ 00:14:13,000 --> 00:14:13,000
755
+ the case.
756
+
757
+ 190
758
+ 00:14:13,000 --> 00:14:19,000
759
+ One hundred percent of your work and time because other parts of the system are also in progress of
760
+
761
+ 191
762
+ 00:14:19,000 --> 00:14:26,000
763
+ development and the parallel development e.g. develop a test its own human that was written by an after
764
+
765
+ 192
766
+ 00:14:26,000 --> 00:14:32,000
767
+ that goes integration tests and after that go system testing and acceptance testing.
768
+
769
+ 193
770
+ 00:14:32,000 --> 00:14:38,000
771
+ There is one interesting metric that the so-called defect cost increase the cost of fixing the book
772
+
773
+ 194
774
+ 00:14:38,000 --> 00:14:44,000
775
+ or defect is lower if you catch it in the design phase, but higher in later phases of the software
776
+
777
+ 195
778
+ 00:14:44,000 --> 00:14:46,000
779
+ development lifecycle.
780
+
781
+ 196
782
+ 00:14:46,000 --> 00:14:52,000
783
+ The cost of detecting and fixing defects in software increases exponentially, with time in the software
784
+
785
+ 197
786
+ 00:14:52,000 --> 00:15:00,000
787
+ development workflow fixing box and the field is incredibly costly and risky, often by an order of
788
+
789
+ 198
790
+ 00:15:00,000 --> 00:15:01,000
791
+ magnitude or two.
792
+
793
+ 199
794
+ 00:15:01,000 --> 00:15:07,000
795
+ The cost is not just in the form of time and resources wasted in the present, but also in the form
796
+
797
+ 200
798
+ 00:15:07,000 --> 00:15:10,000
799
+ of lost opportunities in the future.
800
+
801
+ 201
802
+ 00:15:10,000 --> 00:15:18,000
803
+ For example, imagine that you have a bank that some mobile Mac and one user noticed that when he sends
804
+
805
+ 202
806
+ 00:15:18,000 --> 00:15:24,000
807
+ one hundred dollars, he got extra charged for money transfer for ten more dollars.
808
+
809
+ 203
810
+ 00:15:24,000 --> 00:15:30,000
811
+ And there were no end in the case about extra charge for money transfer of specific money amount.
812
+
813
+ 204
814
+ 00:15:30,000 --> 00:15:31,000
815
+ Do not the banks.
816
+
817
+ 205
818
+ 00:15:32,000 --> 00:15:38,000
819
+ And this is a bug because users should have seen this notification not pop up the items.
820
+
821
+ 206
822
+ 00:15:39,000 --> 00:15:44,000
823
+ Your team submitted a defect, but how much will it cost to you at the end of the day?
824
+
825
+ 207
826
+ 00:15:45,000 --> 00:15:51,000
827
+ Well, you can come up with some other example like user downloaded app to send money, but he can't
828
+
829
+ 208
830
+ 00:15:51,000 --> 00:15:53,000
831
+ because app is not working.
832
+
833
+ 209
834
+ 00:15:54,000 --> 00:15:56,000
835
+ User just removes app, and that's it.
836
+
837
+ 210
838
+ 00:15:57,000 --> 00:16:02,000
839
+ You spend so much money on advertisement domains as client download your app.
840
+
841
+ 211
842
+ 00:16:02,000 --> 00:16:08,000
843
+ And now he just left, and he will never install the app one more time again in the future.
844
+
845
+ 212
846
+ 00:16:08,000 --> 00:16:15,000
847
+ Moreover, this guide may leave bad feedback on different portals and new clients will doubt in your
848
+
849
+ 213
850
+ 00:16:15,000 --> 00:16:16,000
851
+ app.
852
+
853
+ 214
854
+ 00:16:16,000 --> 00:16:20,000
855
+ This also, of course, is that you have lost the understands this.
856
+
857
+ 215
858
+ 00:16:21,000 --> 00:16:25,000
859
+ Remember that the price of fixing the effect is increasing from an environment environment.
860
+
861
+ 216
862
+ 00:16:26,000 --> 00:16:32,000
863
+ The cheapest price you can pay is to figure out the effect on local computer in case the effect was
864
+
865
+ 217
866
+ 00:16:32,000 --> 00:16:34,000
867
+ discovered on a service.
868
+
869
+ 218
870
+ 00:16:34,000 --> 00:16:40,000
871
+ It requires additional a force to use to gauge in the effort to fix it, to deploy it on key environment,
872
+
873
+ 219
874
+ 00:16:41,000 --> 00:16:45,000
875
+ to perform some testing, to make sure that other features are not broken.
876
+
877
+ 220
878
+ 00:16:45,000 --> 00:16:51,000
879
+ If the effect was discovered during user acceptance testing, that's completely another procedure.
880
+
881
+ 221
882
+ 00:16:51,000 --> 00:16:57,000
883
+ We'll talk another lessons about continuous integration and continuous delivery and deployment, and
884
+
885
+ 222
886
+ 00:16:57,000 --> 00:17:02,000
887
+ we'll elaborate more on different environments that we use during the development.
888
+
889
+ 223
890
+ 00:17:02,000 --> 00:17:09,000
891
+ But the things that you should remember right now is that you have to be able to identify a potential
892
+
893
+ 224
894
+ 00:17:09,000 --> 00:17:16,000
895
+ defect as early as possible and and Pyramid set the right priorities for us while writing our series
896
+
897
+ 225
898
+ 00:17:16,000 --> 00:17:17,000
899
+ of tests.
900
+
901
+ 226
902
+ 00:17:18,000 --> 00:17:24,000
903
+ Before moving further and learning other classifications related to Destin, I want to understand a
904
+
905
+ 227
906
+ 00:17:24,000 --> 00:17:26,000
907
+ few more basic concepts.
908
+
909
+ 228
910
+ 00:17:26,000 --> 00:17:31,000
911
+ I want to discuss with you what functional and non-functional requirements are.
912
+
913
+ 229
914
+ 00:17:31,000 --> 00:17:33,000
915
+ Let's start from running functional requirements.
916
+
917
+ 230
918
+ 00:17:34,000 --> 00:17:37,000
919
+ Functional requirements defines a basic system behavior.
920
+
921
+ 231
922
+ 00:17:38,000 --> 00:17:46,000
923
+ Essentially, Zara, what system does or must not do and can be sought often in terms of how the system
924
+
925
+ 232
926
+ 00:17:46,000 --> 00:17:47,000
927
+ responds to inputs.
928
+
929
+ 233
930
+ 00:17:48,000 --> 00:17:55,000
931
+ Functional requirements user to define exact behaviors and includes calculations, data input and business
932
+
933
+ 234
934
+ 00:17:55,000 --> 00:17:56,000
935
+ processes.
936
+
937
+ 235
938
+ 00:17:56,000 --> 00:18:03,000
939
+ In other more simple words, we can treat functional requirements as features that allows the system
940
+
941
+ 236
942
+ 00:18:03,000 --> 00:18:05,000
943
+ to function as it was intended.
944
+
945
+ 237
946
+ 00:18:06,000 --> 00:18:10,000
947
+ Simply said it was the functional requirements are not met.
948
+
949
+ 238
950
+ 00:18:10,000 --> 00:18:12,000
951
+ This system will not work.
952
+
953
+ 239
954
+ 00:18:12,000 --> 00:18:19,000
955
+ Functional requirements are product features and focus on user requirements, while functional requirements
956
+
957
+ 240
958
+ 00:18:19,000 --> 00:18:22,000
959
+ define what the system does or must not do.
960
+
961
+ 241
962
+ 00:18:23,000 --> 00:18:27,000
963
+ Non-functional requirements specify how this system should do it.
964
+
965
+ 242
966
+ 00:18:27,000 --> 00:18:32,000
967
+ Non-functional requirements do not affect the basic functionality of the system.
968
+
969
+ 243
970
+ 00:18:33,000 --> 00:18:38,000
971
+ Hence the name is non-functional requirements even if the non-functional requirements are not met.
972
+
973
+ 244
974
+ 00:18:39,000 --> 00:18:42,000
975
+ The system will still perform its basic purpose.
976
+
977
+ 245
978
+ 00:18:42,000 --> 00:18:46,000
979
+ If a system will still perform results, meetings is non-functional requirements.
980
+
981
+ 246
982
+ 00:18:47,000 --> 00:18:48,000
983
+ Why are they important?
984
+
985
+ 247
986
+ 00:18:49,000 --> 00:18:51,000
987
+ The answer is usability.
988
+
989
+ 248
990
+ 00:18:51,000 --> 00:18:57,000
991
+ Non-functional requirements define system behaviour, features and general characteristics that affect
992
+
993
+ 249
994
+ 00:18:57,000 --> 00:18:58,000
995
+ the user experience.
996
+
997
+ 250
998
+ 00:18:59,000 --> 00:19:06,000
999
+ How well known functional requirements are defined and executed determines how easily this system used
1000
+
1001
+ 251
1002
+ 00:19:06,000 --> 00:19:09,000
1003
+ to use and is used to judge system performance.
1004
+
1005
+ 252
1006
+ 00:19:10,000 --> 00:19:16,000
1007
+ Non-functional requirements are product properties and focus on user expectations.
1008
+
1009
+ 253
1010
+ 00:19:17,000 --> 00:19:18,000
1011
+ Great.
1012
+
1013
+ 254
1014
+ 00:19:18,000 --> 00:19:22,000
1015
+ You know what, functional and non-functional requirements are.
1016
+
1017
+ 255
1018
+ 00:19:22,000 --> 00:19:26,000
1019
+ Now let's learn what functional and non-functional destiny is.
1020
+
1021
+ 256
1022
+ 00:19:26,000 --> 00:19:33,000
1023
+ One more important things that we need to understand about testing software testing is broadly categorised
1024
+
1025
+ 257
1026
+ 00:19:33,000 --> 00:19:35,000
1027
+ into functional and non-functional testing.
1028
+
1029
+ 258
1030
+ 00:19:36,000 --> 00:19:38,000
1031
+ You already know different testing levels.
1032
+
1033
+ 259
1034
+ 00:19:38,000 --> 00:19:43,000
1035
+ Also, you know what functional and non-functional requirements are, and I believe it will be easier
1036
+
1037
+ 260
1038
+ 00:19:43,000 --> 00:19:48,000
1039
+ for you to understand such categories as functional and non-functional testing.
1040
+
1041
+ 261
1042
+ 00:19:49,000 --> 00:19:55,000
1043
+ Let's discuss in detail about these testing types functional testing because the type of test and which
1044
+
1045
+ 262
1046
+ 00:19:55,000 --> 00:20:01,000
1047
+ verifies that each function of the software application operates in conformance with the requirements
1048
+
1049
+ 263
1050
+ 00:20:01,000 --> 00:20:02,000
1051
+ specification.
1052
+
1053
+ 264
1054
+ 00:20:03,000 --> 00:20:10,000
1055
+ This test mainly involves black box testing, and it is not concerned about the source code of the application.
1056
+
1057
+ 265
1058
+ 00:20:11,000 --> 00:20:14,000
1059
+ Usually, this is verification of entry and snares.
1060
+
1061
+ 266
1062
+ 00:20:15,000 --> 00:20:22,000
1063
+ So you test behavior of the system according to the requirements, and to end, every functionality
1064
+
1065
+ 267
1066
+ 00:20:22,000 --> 00:20:25,000
1067
+ of this system is tested by providing appropriate input.
1068
+
1069
+ 268
1070
+ 00:20:25,000 --> 00:20:30,000
1071
+ Verifying the output and comparing the actual result was expected to results.
1072
+
1073
+ 269
1074
+ 00:20:31,000 --> 00:20:39,000
1075
+ This test involves chicken of user interface APIs, database client server applications and functionality
1076
+
1077
+ 270
1078
+ 00:20:39,000 --> 00:20:41,000
1079
+ of the application on the test.
1080
+
1081
+ 271
1082
+ 00:20:42,000 --> 00:20:43,000
1083
+ The testing can be done.
1084
+
1085
+ 272
1086
+ 00:20:43,000 --> 00:20:45,000
1087
+ Is it manually or using automation?
1088
+
1089
+ 273
1090
+ 00:20:46,000 --> 00:20:51,000
1091
+ Non-functional testing checks all the aspects not covered in functional tests.
1092
+
1093
+ 274
1094
+ 00:20:52,000 --> 00:20:56,000
1095
+ In other words, not a functional test and covers verification of non-functional requirements.
1096
+
1097
+ 275
1098
+ 00:20:57,000 --> 00:21:02,000
1099
+ There are some aspects which are complex, such as performance of an application, etc. and this test
1100
+
1101
+ 276
1102
+ 00:21:02,000 --> 00:21:05,000
1103
+ and check the quality of the software to be tested.
1104
+
1105
+ 277
1106
+ 00:21:06,000 --> 00:21:13,000
1107
+ Quality majorly depends on time, accuracy, stability, correctness and durability of a product and
1108
+
1109
+ 278
1110
+ 00:21:13,000 --> 00:21:17,000
1111
+ the various adverse circumstances in software terms.
1112
+
1113
+ 279
1114
+ 00:21:17,000 --> 00:21:24,000
1115
+ When an application works as per the user expectation, smoothly and efficiently under any condition,
1116
+
1117
+ 280
1118
+ 00:21:24,000 --> 00:21:30,000
1119
+ then it is stated as a reliable application based on these aspects of quality.
1120
+
1121
+ 281
1122
+ 00:21:31,000 --> 00:21:34,000
1123
+ It is very critical to test under these parameters.
1124
+
1125
+ 282
1126
+ 00:21:34,000 --> 00:21:38,000
1127
+ This type of testing is called non-functional testing.
1128
+
1129
+ 283
1130
+ 00:21:38,000 --> 00:21:41,000
1131
+ It is not feasible to test this type manually.
1132
+
1133
+ 284
1134
+ 00:21:41,000 --> 00:21:48,000
1135
+ Hence, some special automated tools are used to test it to help you understand the difference between
1136
+
1137
+ 285
1138
+ 00:21:48,000 --> 00:21:51,000
1139
+ functional and non-functional testing matter.
1140
+
1141
+ 286
1142
+ 00:21:51,000 --> 00:21:54,000
1143
+ Let me demonstrate its unreal example.
1144
+
1145
+ 287
1146
+ 00:21:54,000 --> 00:22:02,000
1147
+ Imagine that we are testing system, and here are questions that we will ask ourselves Do you functional
1148
+
1149
+ 288
1150
+ 00:22:02,000 --> 00:22:03,000
1151
+ and non-functional testing?
1152
+
1153
+ 289
1154
+ 00:22:04,000 --> 00:22:11,000
1155
+ Thus, this will impact on the way how we approach our testing functional testing questions.
1156
+
1157
+ 290
1158
+ 00:22:11,000 --> 00:22:16,000
1159
+ Are these a confirmation email sent after the user registers on the website?
1160
+
1161
+ 291
1162
+ 00:22:17,000 --> 00:22:19,000
1163
+ Does a feedback notification appear?
1164
+
1165
+ 292
1166
+ 00:22:19,000 --> 00:22:26,000
1167
+ Is a user uploads a larger files and the system asks when the user clicks on the icons that is supposed
1168
+
1169
+ 293
1170
+ 00:22:26,000 --> 00:22:27,000
1171
+ to be clickable.
1172
+
1173
+ 294
1174
+ 00:22:27,000 --> 00:22:29,000
1175
+ Does a new page load?
1176
+
1177
+ 295
1178
+ 00:22:30,000 --> 00:22:33,000
1179
+ As you can see, all questions are behavior oriented.
1180
+
1181
+ 296
1182
+ 00:22:34,000 --> 00:22:40,000
1183
+ Non-functional testing questions are how much time does it take for the user to receive a registration
1184
+
1185
+ 297
1186
+ 00:22:40,000 --> 00:22:42,000
1187
+ confirmation email?
1188
+
1189
+ 298
1190
+ 00:22:42,000 --> 00:22:47,000
1191
+ Does the feedback notification comply with the principles of user friendly push notifications?
1192
+
1193
+ 299
1194
+ 00:22:47,000 --> 00:22:50,000
1195
+ Design the transparency for the user?
1196
+
1197
+ 300
1198
+ 00:22:50,000 --> 00:22:52,000
1199
+ Where to click the lower than you page.
1200
+
1201
+ 301
1202
+ 00:22:53,000 --> 00:23:00,000
1203
+ I believe you noticed that non-functional testing questions are more about how program works rather
1204
+
1205
+ 302
1206
+ 00:23:00,000 --> 00:23:01,000
1207
+ than what it does.
1208
+
1209
+ 303
1210
+ 00:23:02,000 --> 00:23:03,000
1211
+ It feels the difference.
1212
+
1213
+ 304
1214
+ 00:23:03,000 --> 00:23:06,000
1215
+ I believe you do now.
1216
+
1217
+ 305
1218
+ 00:23:06,000 --> 00:23:11,000
1219
+ When you understand the difference between a functional and non-functional testing, let's group different
1220
+
1221
+ 306
1222
+ 00:23:11,000 --> 00:23:14,000
1223
+ testing strategies into two categories.
1224
+
1225
+ 307
1226
+ 00:23:14,000 --> 00:23:22,000
1227
+ Such testing strategies can be added to functional testing group smoke testing, sanity testing, unit
1228
+
1229
+ 308
1230
+ 00:23:22,000 --> 00:23:31,000
1231
+ testing, integration testing, boundary value testing, API testing, user acceptance testing, regression
1232
+
1233
+ 309
1234
+ 00:23:31,000 --> 00:23:38,000
1235
+ testing, interoperability, testing and such testing strategies can be considered as non-functional
1236
+
1237
+ 310
1238
+ 00:23:38,000 --> 00:23:46,000
1239
+ testing activities and reliability testing, performance, testing, compatibility, testing, localization,
1240
+
1241
+ 311
1242
+ 00:23:46,000 --> 00:23:54,000
1243
+ testing, William testing, scalability, testing, usability testing, reliability testing, security
1244
+
1245
+ 312
1246
+ 00:23:54,000 --> 00:24:02,000
1247
+ testing, penetration testing, accessibility testing, load testing, endurance testing, compliance
1248
+
1249
+ 313
1250
+ 00:24:02,000 --> 00:24:09,000
1251
+ testing, stress testing, Menton ability testing, portability testing, disaster recovery testing
1252
+
1253
+ 314
1254
+ 00:24:09,000 --> 00:24:12,000
1255
+ is everything clear to you anyway.
1256
+
1257
+ 315
1258
+ 00:24:12,000 --> 00:24:16,000
1259
+ Even in case you still have any questions, do not hesitate to ask me in.
1260
+
1261
+ 316
1262
+ 00:24:17,000 --> 00:24:20,000
1263
+ Comments on this video, and I will be happy to answer.
1264
+
1265
+ 317
1266
+ 00:24:22,000 --> 00:24:22,000
1267
+ That's it.
1268
+
1269
+ 318
1270
+ 00:24:22,000 --> 00:24:29,000
1271
+ Now let's recap what we have learned today to live and learn what testing is and why do we need it now,
1272
+
1273
+ 319
1274
+ 00:24:29,000 --> 00:24:36,000
1275
+ you know what goes of testing are worthy of testing approaches and testing levels after today's lesson.
1276
+
1277
+ 320
1278
+ 00:24:36,000 --> 00:24:40,000
1279
+ You know what level of tests are usually written by developers?
1280
+
1281
+ 321
1282
+ 00:24:40,000 --> 00:24:43,000
1283
+ Besides that, you learned what quality is.
1284
+
1285
+ 322
1286
+ 00:24:43,000 --> 00:24:46,000
1287
+ We learned what tests impairment is.
1288
+
1289
+ 323
1290
+ 00:24:46,000 --> 00:24:50,000
1291
+ Also, we discussed the difference between functional and non-functional requirements.
1292
+
1293
+ 324
1294
+ 00:24:51,000 --> 00:24:55,000
1295
+ And at the end of the lesson, we have learnt what functional and non-functional testing is.
1296
+
1297
+ 325
1298
+ 00:24:56,000 --> 00:24:58,000
1299
+ That's all for this lesson.
1300
+
1301
+ 326
1302
+ 00:24:58,000 --> 00:24:59,000
1303
+ Thanks a lot for your attention.
1304
+
1305
+ 327
1306
+ 00:25:00,000 --> 00:25:01,000
1307
+ See you in the next lesson.
1308
+
34 - Unit Testing & JUnit 5/001 Unit Testing & JUnit Overview_en.srt ADDED
@@ -0,0 +1,1372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:10,000
3
+ Heard yesterday in this lesson, we learned basics of human testing.
4
+
5
+ 2
6
+ 00:00:10,000 --> 00:00:12,000
7
+ We are going to learn today what unit testing is.
8
+
9
+ 3
10
+ 00:00:12,000 --> 00:00:16,000
11
+ You understand basic principles of unit testing.
12
+
13
+ 4
14
+ 00:00:16,000 --> 00:00:20,000
15
+ And after that, we are going to review libraries for unit testing in Java.
16
+
17
+ 5
18
+ 00:00:20,000 --> 00:00:26,000
19
+ We'll focus our attention on the one of the most popular libraries for unit testing and Java G unit.
20
+
21
+ 6
22
+ 00:00:26,000 --> 00:00:32,000
23
+ I will explain the basic structure of this library and we'll teach you how that extra libraries to your
24
+
25
+ 7
26
+ 00:00:32,000 --> 00:00:34,000
27
+ project in Eclipse by the end of the.
28
+
29
+ 8
30
+ 00:00:35,000 --> 00:00:38,000
31
+ And you'll write your first unit test during the lesson.
32
+
33
+ 9
34
+ 00:00:38,000 --> 00:00:42,000
35
+ I will share with you tips and best practices of writing unit tests.
36
+
37
+ 10
38
+ 00:00:42,000 --> 00:00:46,000
39
+ So be prepared for interesting lecture and learn a lot of new things.
40
+
41
+ 11
42
+ 00:00:46,000 --> 00:00:49,000
43
+ Let's start at the beginning of the lesson.
44
+
45
+ 12
46
+ 00:00:49,000 --> 00:00:55,000
47
+ We'll talk about Syria of testing to make sure that by the moment we start right, our first test,
48
+
49
+ 13
50
+ 00:00:55,000 --> 00:00:59,000
51
+ you understand what we are going to do in the middle of our lesson.
52
+
53
+ 14
54
+ 00:00:59,000 --> 00:01:03,000
55
+ We'll learn how to use Genin by refining and testing in Java.
56
+
57
+ 15
58
+ 00:01:03,000 --> 00:01:09,000
59
+ And at the end of the lesson, we'll dive deeper into the specifics of new tests from the previous class.
60
+
61
+ 16
62
+ 00:01:09,000 --> 00:01:14,000
63
+ And you remember that new testing help us to test each specific unit of completion.
64
+
65
+ 17
66
+ 00:01:15,000 --> 00:01:17,000
67
+ That is our classes with unit tests.
68
+
69
+ 18
70
+ 00:01:17,000 --> 00:01:23,000
71
+ We have the ability and to to verify that each unit behaves in the way it expects to behave.
72
+
73
+ 19
74
+ 00:01:24,000 --> 00:01:26,000
75
+ Does that mean that your program works 100 percent?
76
+
77
+ 20
78
+ 00:01:26,000 --> 00:01:26,000
79
+ Correct?
80
+
81
+ 21
82
+ 00:01:27,000 --> 00:01:28,000
83
+ Not necessarily.
84
+
85
+ 22
86
+ 00:01:28,000 --> 00:01:29,000
87
+ Why?
88
+
89
+ 23
90
+ 00:01:29,000 --> 00:01:35,000
91
+ Because each specific unit can work as expected, but together a few classes don't work as expected
92
+
93
+ 24
94
+ 00:01:36,000 --> 00:01:42,000
95
+ is a some invalid input or one module works with a specific range of data that is invalid relative to
96
+
97
+ 25
98
+ 00:01:42,000 --> 00:01:43,000
99
+ another class.
100
+
101
+ 26
102
+ 00:01:43,000 --> 00:01:45,000
103
+ Or we missed some specific test case.
104
+
105
+ 27
106
+ 00:01:45,000 --> 00:01:52,000
107
+ And the only reason our unit test passed successfully is that because it's simply absent a test is a
108
+
109
+ 28
110
+ 00:01:52,000 --> 00:01:59,000
111
+ piece of good reason by a developer that executes a specific functionality in the code to be tested
112
+
113
+ 29
114
+ 00:01:59,000 --> 00:02:02,000
115
+ and asserts a certain behavior or state.
116
+
117
+ 30
118
+ 00:02:03,000 --> 00:02:07,000
119
+ Each test contains specific research that will verify specific state.
120
+
121
+ 31
122
+ 00:02:08,000 --> 00:02:14,000
123
+ The percentage of code which is tested by unit tests is typically called test coverage will learn tools
124
+
125
+ 32
126
+ 00:02:14,000 --> 00:02:17,000
127
+ that help us to verify test got coverage in adolescence.
128
+
129
+ 33
130
+ 00:02:18,000 --> 00:02:24,000
131
+ Any tests are not suitable for testing complex user interfaces or component interactions.
132
+
133
+ 34
134
+ 00:02:24,000 --> 00:02:27,000
135
+ For this, you should develop integration tests.
136
+
137
+ 35
138
+ 00:02:27,000 --> 00:02:31,000
139
+ But unit tests can detect issues as early as possible.
140
+
141
+ 36
142
+ 00:02:31,000 --> 00:02:33,000
143
+ They form the base of our test permit.
144
+
145
+ 37
146
+ 00:02:34,000 --> 00:02:41,000
147
+ Now let's review basic principles of unit testing, the simple rules that we need to follow to make
148
+
149
+ 38
150
+ 00:02:41,000 --> 00:02:43,000
151
+ sure our unit tests efficient.
152
+
153
+ 39
154
+ 00:02:43,000 --> 00:02:49,000
155
+ Zaya the first through one assertion per test or single concept by test.
156
+
157
+ 40
158
+ 00:02:49,000 --> 00:02:55,000
159
+ That means in case we test discount calculation, we don't have to create one test.
160
+
161
+ 41
162
+ 00:02:55,000 --> 00:03:01,000
163
+ The test calculation of this controversial card was one product with total price of hundred bucks and
164
+
165
+ 42
166
+ 00:03:01,000 --> 00:03:07,000
167
+ in the same tests verify amount of discount in case of the card with total price one thousand bucks.
168
+
169
+ 43
170
+ 00:03:08,000 --> 00:03:13,000
171
+ In other words, one test shouldn't verify different test cases in scope of the same test.
172
+
173
+ 44
174
+ 00:03:14,000 --> 00:03:20,000
175
+ There are some exceptions when this single concept by test in this case with this money transferring
176
+
177
+ 45
178
+ 00:03:20,000 --> 00:03:25,000
179
+ from one account to another and we have test case that should verify my transaction.
180
+
181
+ 46
182
+ 00:03:25,000 --> 00:03:31,000
183
+ In this case, we have to check that on one account amount of money was decreased because we sent them
184
+
185
+ 47
186
+ 00:03:31,000 --> 00:03:36,000
187
+ to another account and on that last account, amount of money should be increased.
188
+
189
+ 48
190
+ 00:03:37,000 --> 00:03:39,000
191
+ That's called single concept by test.
192
+
193
+ 49
194
+ 00:03:40,000 --> 00:03:44,000
195
+ And we have to verifications in scope of the same test.
196
+
197
+ 50
198
+ 00:03:44,000 --> 00:03:51,000
199
+ We need to separate test based scenarios to be able to catch error faster and to understand what specific
200
+
201
+ 51
202
+ 00:03:51,000 --> 00:03:52,000
203
+ scenario didn't pass.
204
+
205
+ 52
206
+ 00:03:53,000 --> 00:03:59,000
207
+ The second rule of human testing is that we have to test one single object at a time in case with some
208
+
209
+ 53
210
+ 00:03:59,000 --> 00:04:05,000
211
+ service, for example, or the management service we shouldn't test or the store and service at the
212
+
213
+ 54
214
+ 00:04:05,000 --> 00:04:06,000
215
+ same time.
216
+
217
+ 55
218
+ 00:04:06,000 --> 00:04:13,000
219
+ Unit testing is about testing one single unit in isolation and without testing simultaneously different
220
+
221
+ 56
222
+ 00:04:13,000 --> 00:04:14,000
223
+ units.
224
+
225
+ 57
226
+ 00:04:14,000 --> 00:04:20,000
227
+ We have to test each unit separately and independently to make sure that the root cause of the error
228
+
229
+ 58
230
+ 00:04:20,000 --> 00:04:22,000
231
+ is in this specific unit.
232
+
233
+ 59
234
+ 00:04:22,000 --> 00:04:24,000
235
+ And that's the test case.
236
+
237
+ 60
238
+ 00:04:24,000 --> 00:04:26,000
239
+ Failure is not caused by another class.
240
+
241
+ 61
242
+ 00:04:27,000 --> 00:04:29,000
243
+ That's why you run the unit testing.
244
+
245
+ 62
246
+ 00:04:29,000 --> 00:04:34,000
247
+ You want to isolate units from each other and test only one object at a time.
248
+
249
+ 63
250
+ 00:04:35,000 --> 00:04:40,000
251
+ And the surge rule, one of the most important ones, choose meaningful test method names.
252
+
253
+ 64
254
+ 00:04:41,000 --> 00:04:42,000
255
+ Why it is so important?
256
+
257
+ 65
258
+ 00:04:42,000 --> 00:04:47,000
259
+ Because, as you remember, one of the functions of testing is to serve as a documentation.
260
+
261
+ 66
262
+ 00:04:48,000 --> 00:04:52,000
263
+ That's why it is critically important to give meaningful names to each test.
264
+
265
+ 67
266
+ 00:04:53,000 --> 00:04:54,000
267
+ Test should be readable.
268
+
269
+ 68
270
+ 00:04:54,000 --> 00:04:59,000
271
+ Well, all codes should be readable, but this is critical, especially for tests.
272
+
273
+ 69
274
+ 00:05:00,000 --> 00:05:06,000
275
+ That's why it is okay to have extremely long, massive names in unit tests that clearly describes a
276
+
277
+ 70
278
+ 00:05:06,000 --> 00:05:06,000
279
+ test case.
280
+
281
+ 71
282
+ 00:05:07,000 --> 00:05:10,000
283
+ It is also important to give clear names to all constants.
284
+
285
+ 72
286
+ 00:05:11,000 --> 00:05:16,000
287
+ There is also Antipodeans that is called magic numbers, magic numbers and numbers.
288
+
289
+ 73
290
+ 00:05:16,000 --> 00:05:18,000
291
+ It is not clear where do they come from?
292
+
293
+ 74
294
+ 00:05:18,000 --> 00:05:24,000
295
+ Where does this maximum relative value or minimum value or this is just a random value.
296
+
297
+ 75
298
+ 00:05:24,000 --> 00:05:25,000
299
+ What does it mean?
300
+
301
+ 76
302
+ 00:05:26,000 --> 00:05:32,000
303
+ That's why each number should be assigned to a specific constant with the relevant name, especially
304
+
305
+ 77
306
+ 00:05:32,000 --> 00:05:33,000
307
+ in tests.
308
+
309
+ 78
310
+ 00:05:33,000 --> 00:05:37,000
311
+ Now, you know, Maine rules that can be applied to each year union test.
312
+
313
+ 79
314
+ 00:05:38,000 --> 00:05:39,000
315
+ Let's proceed.
316
+
317
+ 80
318
+ 00:05:39,000 --> 00:05:43,000
319
+ Now, I'd like to discuss with you a few more testing principles.
320
+
321
+ 81
322
+ 00:05:43,000 --> 00:05:50,000
323
+ There are a set of principles called First Leavis acronym, composed from the first letters of the principal's
324
+
325
+ 82
326
+ 00:05:50,000 --> 00:05:50,000
327
+ name.
328
+
329
+ 83
330
+ 00:05:50,000 --> 00:05:56,000
331
+ And the minute you will believe me that this is not just offensive word, but indeed a set of useful
332
+
333
+ 84
334
+ 00:05:56,000 --> 00:05:56,000
335
+ principles.
336
+
337
+ 85
338
+ 00:05:57,000 --> 00:06:00,000
339
+ Let's start from the first one F stands for first.
340
+
341
+ 86
342
+ 00:06:01,000 --> 00:06:06,000
343
+ A developer should not hesitate to run the unit tests because they are very slow and you need to grab
344
+
345
+ 87
346
+ 00:06:06,000 --> 00:06:08,000
347
+ a cup of coffee to wake you.
348
+
349
+ 88
350
+ 00:06:08,000 --> 00:06:10,000
351
+ All verifications will be done.
352
+
353
+ 89
354
+ 00:06:10,000 --> 00:06:18,000
355
+ Nobody should be scared of running a union test because of the time they take the top of each preconditioning
356
+
357
+ 90
358
+ 00:06:18,000 --> 00:06:21,000
359
+ test and gear down should execute really fast.
360
+
361
+ 91
362
+ 00:06:22,000 --> 00:06:27,000
363
+ I mean, it is a matter of milliseconds because there are thousands of units in one project.
364
+
365
+ 92
366
+ 00:06:28,000 --> 00:06:30,000
367
+ The next letter is I.
368
+
369
+ 93
370
+ 00:06:30,000 --> 00:06:33,000
371
+ I stands for independent or isolated.
372
+
373
+ 94
374
+ 00:06:33,000 --> 00:06:37,000
375
+ Each test should be isolated from external environment.
376
+
377
+ 95
378
+ 00:06:37,000 --> 00:06:43,000
379
+ Each test should be independent of anything else, like another test environment for a specific user
380
+
381
+ 96
382
+ 00:06:43,000 --> 00:06:51,000
383
+ input and so on, in case you expect from user input simulated for each specific test, because it may
384
+
385
+ 97
386
+ 00:06:51,000 --> 00:06:57,000
387
+ be different shows that your code can work with the range of values and the result will be different.
388
+
389
+ 98
390
+ 00:06:57,000 --> 00:07:03,000
391
+ We'll talk a little bit later how to make sure that we wrote enough tests to avoid the case.
392
+
393
+ 99
394
+ 00:07:03,000 --> 00:07:06,000
395
+ When you write hundreds of tests, the test actually is the same thing.
396
+
397
+ 100
398
+ 00:07:07,000 --> 00:07:12,000
399
+ There was a case in my life when a colleague of mine from United Kingdom wrote a test that successfully
400
+
401
+ 101
402
+ 00:07:13,000 --> 00:07:18,000
403
+ only in his time zone, in time zone of team members from other countries, it failed.
404
+
405
+ 102
406
+ 00:07:19,000 --> 00:07:25,000
407
+ Remember, if you use time in assertion of your test, make sure it doesn't depend from the time zone.
408
+
409
+ 103
410
+ 00:07:26,000 --> 00:07:31,000
411
+ JDK contains a lot of classes and tools to work with time and to imitate specific time zone.
412
+
413
+ 104
414
+ 00:07:31,000 --> 00:07:35,000
415
+ So make sure your tests are independent.
416
+
417
+ 105
418
+ 00:07:35,000 --> 00:07:36,000
419
+ Let's go forward.
420
+
421
+ 106
422
+ 00:07:37,000 --> 00:07:39,000
423
+ Are stands for repeatable?
424
+
425
+ 107
426
+ 00:07:39,000 --> 00:07:45,000
427
+ That means that multiple execution of tests should provide us with the same result in case nothing was
428
+
429
+ 108
430
+ 00:07:45,000 --> 00:07:46,000
431
+ changed in the source code.
432
+
433
+ 109
434
+ 00:07:46,000 --> 00:07:53,000
435
+ For example, you wrote test that checks registration process after user sign up information about users
436
+
437
+ 110
438
+ 00:07:53,000 --> 00:07:59,000
439
+ should be inserted in database and after you paste that user info in the database and run test one more
440
+
441
+ 111
442
+ 00:07:59,000 --> 00:08:05,000
443
+ time, it failed because user research A or email already exist in database.
444
+
445
+ 112
446
+ 00:08:05,000 --> 00:08:06,000
447
+ Can you understand this example?
448
+
449
+ 113
450
+ 00:08:07,000 --> 00:08:14,000
451
+ That means even if you perform any data manipulations with database in our example, you have to clean
452
+
453
+ 114
454
+ 00:08:14,000 --> 00:08:16,000
455
+ up everything after each test is finished.
456
+
457
+ 115
458
+ 00:08:16,000 --> 00:08:21,000
459
+ And I believe that you understood that database is just one of examples.
460
+
461
+ 116
462
+ 00:08:21,000 --> 00:08:23,000
463
+ The main idea is the following.
464
+
465
+ 117
466
+ 00:08:24,000 --> 00:08:29,000
467
+ In case your test in some way changed the environment, you have to clean up everything after test is
468
+
469
+ 118
470
+ 00:08:29,000 --> 00:08:30,000
471
+ finished.
472
+
473
+ 119
474
+ 00:08:30,000 --> 00:08:33,000
475
+ Result of each test should be deterministic.
476
+
477
+ 120
478
+ 00:08:33,000 --> 00:08:36,000
479
+ Developers should take control of everything.
480
+
481
+ 121
482
+ 00:08:36,000 --> 00:08:38,000
483
+ What is going on in the test?
484
+
485
+ 122
486
+ 00:08:38,000 --> 00:08:40,000
487
+ To reproduce different life cases?
488
+
489
+ 123
490
+ 00:08:40,000 --> 00:08:44,000
491
+ Each test should set up its own data and should.
492
+
493
+ 124
494
+ 00:08:44,000 --> 00:08:50,000
495
+ Not depend on any external factors to run its test, the next letter is S.
496
+
497
+ 125
498
+ 00:08:50,000 --> 00:08:56,000
499
+ S stands for self validating no manual inspection where the test is passed on what is required.
500
+
501
+ 126
502
+ 00:08:57,000 --> 00:09:02,000
503
+ The same manual configuration is required to execute test, to run tests.
504
+
505
+ 127
506
+ 00:09:02,000 --> 00:09:04,000
507
+ Make sure that database is clear.
508
+
509
+ 128
510
+ 00:09:04,000 --> 00:09:06,000
511
+ What run this test.
512
+
513
+ 129
514
+ 00:09:06,000 --> 00:09:08,000
515
+ Make sure that resourceful clean.
516
+
517
+ 130
518
+ 00:09:08,000 --> 00:09:11,000
519
+ You shouldn't declare any conditions like this.
520
+
521
+ 131
522
+ 00:09:11,000 --> 00:09:15,000
523
+ And the last letter is key in different sources of literature.
524
+
525
+ 132
526
+ 00:09:15,000 --> 00:09:17,000
527
+ It is explained in a different way.
528
+
529
+ 133
530
+ 00:09:18,000 --> 00:09:24,000
531
+ Somebody tells the G stands for Sulloway and somebody tells the T stands for timely.
532
+
533
+ 134
534
+ 00:09:24,000 --> 00:09:27,000
535
+ I would say that both of these statements are important.
536
+
537
+ 135
538
+ 00:09:28,000 --> 00:09:32,000
539
+ SORU means the next should cover all the happy pass.
540
+
541
+ 136
542
+ 00:09:32,000 --> 00:09:37,000
543
+ Try covering all the edge cases where the author would feel the function would fail.
544
+
545
+ 137
546
+ 00:09:38,000 --> 00:09:40,000
547
+ Test for legal arguments and variables.
548
+
549
+ 138
550
+ 00:09:40,000 --> 00:09:42,000
551
+ Test for security and other issues.
552
+
553
+ 139
554
+ 00:09:43,000 --> 00:09:44,000
555
+ Test for launch failures.
556
+
557
+ 140
558
+ 00:09:44,000 --> 00:09:51,000
559
+ What would a launch in that program should try to cover every use case scenario and not just aim for
560
+
561
+ 141
562
+ 00:09:51,000 --> 00:09:58,000
563
+ one hundred percent test got coverage and timely means that test should be written right on time.
564
+
565
+ 142
566
+ 00:09:59,000 --> 00:10:04,000
567
+ That means together with the code creation and even better before code creation.
568
+
569
+ 143
570
+ 00:10:05,000 --> 00:10:08,000
571
+ I'm talking about so-called test development.
572
+
573
+ 144
574
+ 00:10:08,000 --> 00:10:10,000
575
+ We'll talk about this in a separate lesson.
576
+
577
+ 145
578
+ 00:10:11,000 --> 00:10:13,000
579
+ So don't be bothered about it right now.
580
+
581
+ 146
582
+ 00:10:13,000 --> 00:10:21,000
583
+ Just remember that the best practice is to write test even before you created code on this slide.
584
+
585
+ 147
586
+ 00:10:21,000 --> 00:10:24,000
587
+ I would like to talk with you about each test case structure.
588
+
589
+ 148
590
+ 00:10:24,000 --> 00:10:27,000
591
+ I am talking about so-called built separate check partan.
592
+
593
+ 149
594
+ 00:10:28,000 --> 00:10:31,000
595
+ Somebody also called this three a pattern.
596
+
597
+ 150
598
+ 00:10:31,000 --> 00:10:36,000
599
+ Also, it is similar to even when Zen approach described in vague technique.
600
+
601
+ 151
602
+ 00:10:36,000 --> 00:10:41,000
603
+ What all this say about these patterns are about basic test structure.
604
+
605
+ 152
606
+ 00:10:42,000 --> 00:10:44,000
607
+ Let's review first built separate check pattern.
608
+
609
+ 153
610
+ 00:10:44,000 --> 00:10:46,000
611
+ We build up test data first.
612
+
613
+ 154
614
+ 00:10:47,000 --> 00:10:50,000
615
+ That is so-called precondition for each test.
616
+
617
+ 155
618
+ 00:10:50,000 --> 00:10:56,000
619
+ We have to reproduce specific state of the system as a specific moment of time to verify how the system
620
+
621
+ 156
622
+ 00:10:56,000 --> 00:10:56,000
623
+ behaves.
624
+
625
+ 157
626
+ 00:10:57,000 --> 00:11:03,000
627
+ For example, we set amount of products in our virtual car and we associate this card with a specific
628
+
629
+ 158
630
+ 00:11:03,000 --> 00:11:07,000
631
+ user and after that we operate on that data.
632
+
633
+ 159
634
+ 00:11:07,000 --> 00:11:09,000
635
+ We perform some action.
636
+
637
+ 160
638
+ 00:11:09,000 --> 00:11:14,000
639
+ In this part, we call some specific method to change the state of our test object.
640
+
641
+ 161
642
+ 00:11:15,000 --> 00:11:17,000
643
+ And in the last part it is called check.
644
+
645
+ 162
646
+ 00:11:18,000 --> 00:11:19,000
647
+ We perform validation.
648
+
649
+ 163
650
+ 00:11:20,000 --> 00:11:23,000
651
+ Specific assertion should be performed in this part of the test.
652
+
653
+ 164
654
+ 00:11:24,000 --> 00:11:31,000
655
+ We verify that actual state of our test object is equal to our expected state to make sure the test
656
+
657
+ 165
658
+ 00:11:31,000 --> 00:11:32,000
659
+ passed successfully.
660
+
661
+ 166
662
+ 00:11:33,000 --> 00:11:35,000
663
+ The next pardon is called 3A.
664
+
665
+ 167
666
+ 00:11:36,000 --> 00:11:44,000
667
+ This is about the same three a stands for a act and asserts in the range part, we prepared data in
668
+
669
+ 168
670
+ 00:11:44,000 --> 00:11:47,000
671
+ ACT part, modify that data by calling some assets.
672
+
673
+ 169
674
+ 00:11:47,000 --> 00:11:50,000
675
+ And in a certain part, we perform assertion.
676
+
677
+ 170
678
+ 00:11:50,000 --> 00:11:53,000
679
+ And bit later in this course, we are going to learn.
680
+
681
+ 171
682
+ 00:11:54,000 --> 00:11:59,000
683
+ But already now you can understand that to describe expected behavior, we can use a given Van Zandt
684
+
685
+ 172
686
+ 00:11:59,000 --> 00:12:00,000
687
+ pardon.
688
+
689
+ 173
690
+ 00:12:00,000 --> 00:12:06,000
691
+ Even part describes what we have at the beginning what a regional state of our system is.
692
+
693
+ 174
694
+ 00:12:07,000 --> 00:12:14,000
695
+ One part describes a specific action when something this happened, then it turns out that we have such
696
+
697
+ 175
698
+ 00:12:14,000 --> 00:12:15,000
699
+ results.
700
+
701
+ 176
702
+ 00:12:15,000 --> 00:12:20,000
703
+ So in Zenker, we have assertion to verify our behavior.
704
+
705
+ 177
706
+ 00:12:21,000 --> 00:12:24,000
707
+ Now, you know, basic structure of each test case.
708
+
709
+ 178
710
+ 00:12:24,000 --> 00:12:26,000
711
+ Let's get closer to the technical part now.
712
+
713
+ 179
714
+ 00:12:27,000 --> 00:12:31,000
715
+ The different libraries exist to write and run unit tests in Java.
716
+
717
+ 180
718
+ 00:12:31,000 --> 00:12:38,000
719
+ When I say library, I'm in code that was already written, compiled and packed into the archive.
720
+
721
+ 181
722
+ 00:12:39,000 --> 00:12:44,000
723
+ Today, we also are going to learn how to add these archives to our project to use code that wasn't
724
+
725
+ 182
726
+ 00:12:44,000 --> 00:12:45,000
727
+ really written.
728
+
729
+ 183
730
+ 00:12:45,000 --> 00:12:53,000
731
+ But first, let's review some of the library's J unit, probably the most popular library for unit testing
732
+
733
+ 184
734
+ 00:12:53,000 --> 00:12:54,000
735
+ in Java.
736
+
737
+ 185
738
+ 00:12:54,000 --> 00:13:01,000
739
+ And as a popular library for you, your testing is test and G Energy stands for new generation.
740
+
741
+ 186
742
+ 00:13:01,000 --> 00:13:06,000
743
+ These two libraries are both similar and provides the same list of features.
744
+
745
+ 187
746
+ 00:13:06,000 --> 00:13:12,000
747
+ You can make similar configurations, but in a different way in each of these libraries, with the exception
748
+
749
+ 188
750
+ 00:13:12,000 --> 00:13:16,000
751
+ that testing over some more features that Gene doesn't have.
752
+
753
+ 189
754
+ 00:13:17,000 --> 00:13:20,000
755
+ But in most cases, G unit is more popular for testing.
756
+
757
+ 190
758
+ 00:13:20,000 --> 00:13:26,000
759
+ In my opinion, you'll learn some basic principles and we are going to run your unit first.
760
+
761
+ 191
762
+ 00:13:26,000 --> 00:13:31,000
763
+ And after that it will be easier for you to apply this knowledge with other frameworks like Test and
764
+
765
+ 192
766
+ 00:13:31,000 --> 00:13:31,000
767
+ G.
768
+
769
+ 193
770
+ 00:13:32,000 --> 00:13:36,000
771
+ And this course, we're going to learn the latest based on today's version of the unit.
772
+
773
+ 194
774
+ 00:13:36,000 --> 00:13:41,000
775
+ I'm talking about the unit version five that's also called Jupiter.
776
+
777
+ 195
778
+ 00:13:41,000 --> 00:13:47,000
779
+ In case you use the unit for in your project, or probably a new version of the unit will be released
780
+
781
+ 196
782
+ 00:13:47,000 --> 00:13:48,000
783
+ in the near future.
784
+
785
+ 197
786
+ 00:13:48,000 --> 00:13:51,000
787
+ I would say that updates are not critical.
788
+
789
+ 198
790
+ 00:13:51,000 --> 00:13:56,000
791
+ Moreover, core principles are the same in every framework for unit testing.
792
+
793
+ 199
794
+ 00:13:56,000 --> 00:14:02,000
795
+ There might be specifics in the implementation of one or another method, a new version and probably
796
+
797
+ 200
798
+ 00:14:02,000 --> 00:14:04,000
799
+ some new annotations or methods.
800
+
801
+ 201
802
+ 00:14:04,000 --> 00:14:08,000
803
+ But again, it is not critical for understanding of the whole picture.
804
+
805
+ 202
806
+ 00:14:09,000 --> 00:14:12,000
807
+ So don't worry and proceed with learning a unit.
808
+
809
+ 203
810
+ 00:14:12,000 --> 00:14:18,000
811
+ On the example of the unit version five eight five consists of different modules.
812
+
813
+ 204
814
+ 00:14:18,000 --> 00:14:28,000
815
+ Zaya Unit Platform Jupiter unit will touch the unit platform serves as a foundation for launch and testing
816
+
817
+ 205
818
+ 00:14:28,000 --> 00:14:30,000
819
+ frameworks on the job of its own machine.
820
+
821
+ 206
822
+ 00:14:31,000 --> 00:14:37,000
823
+ It also defines the Test Engine API for development, a test and framework that runs on the platform.
824
+
825
+ 207
826
+ 00:14:38,000 --> 00:14:45,000
827
+ Also, the platform provides a console launcher to launch the platform from the command line Jupiter
828
+
829
+ 208
830
+ 00:14:45,000 --> 00:14:51,000
831
+ in the combination of the new programming model and extension model for writing test and extensions.
832
+
833
+ 209
834
+ 00:14:51,000 --> 00:14:58,000
835
+ In June five, the Jupiter project provides a test engine for running Jupiter based tests on the platform.
836
+
837
+ 210
838
+ 00:14:59,000 --> 00:15:07,000
839
+ G20 provides a test engine for running June three and June four based tests on the platform, the different
840
+
841
+ 211
842
+ 00:15:07,000 --> 00:15:09,000
843
+ API in different versions of the unit.
844
+
845
+ 212
846
+ 00:15:09,000 --> 00:15:13,000
847
+ And this module enables the compatibility between different APIs.
848
+
849
+ 213
850
+ 00:15:14,000 --> 00:15:19,000
851
+ In this course, we are going to learn the features of this powerful library on the real examples.
852
+
853
+ 214
854
+ 00:15:19,000 --> 00:15:25,000
855
+ For this course, I'm going to use official documentation in real life, examples I will share with
856
+
857
+ 215
858
+ 00:15:25,000 --> 00:15:30,000
859
+ you experience from my projects to help you learn best practices of writing unit tests.
860
+
861
+ 216
862
+ 00:15:30,000 --> 00:15:37,000
863
+ Now I suggest jump directly to examples to help you understand technical part of your testing.
864
+
865
+ 217
866
+ 00:15:37,000 --> 00:15:40,000
867
+ Let's create first simple class that we are going to test.
868
+
869
+ 218
870
+ 00:15:41,000 --> 00:15:45,000
871
+ I created all classes before the lesson, but I will walk you through all of them.
872
+
873
+ 219
874
+ 00:15:45,000 --> 00:15:47,000
875
+ Here is simple class calculator.
876
+
877
+ 220
878
+ 00:15:48,000 --> 00:15:51,000
879
+ It contains one single method that performs addition.
880
+
881
+ 221
882
+ 00:15:51,000 --> 00:15:54,000
883
+ As you can see, nothing special here.
884
+
885
+ 222
886
+ 00:15:54,000 --> 00:16:01,000
887
+ Our main goal in this lesson to learn technical side of union task creation, usually for all tests,
888
+
889
+ 223
890
+ 00:16:01,000 --> 00:16:03,000
891
+ separate source folder is created.
892
+
893
+ 224
894
+ 00:16:03,000 --> 00:16:04,000
895
+ What do we need?
896
+
897
+ 225
898
+ 00:16:04,000 --> 00:16:05,000
899
+ Separate source folder.
900
+
901
+ 226
902
+ 00:16:06,000 --> 00:16:12,000
903
+ Because at the end of the day, you have to compile all your source code packet in one archive and deployed
904
+
905
+ 227
906
+ 00:16:12,000 --> 00:16:16,000
907
+ on the web server or on it separately on the desktop.
908
+
909
+ 228
910
+ 00:16:16,000 --> 00:16:19,000
911
+ And you don't need tests to make your code.
912
+
913
+ 229
914
+ 00:16:19,000 --> 00:16:24,000
915
+ Now, units usually needed during the development, but not in production.
916
+
917
+ 230
918
+ 00:16:24,000 --> 00:16:32,000
919
+ That's why I would love to test in the separate source folder to keep and track them separately when
920
+
921
+ 231
922
+ 00:16:32,000 --> 00:16:33,000
923
+ we learn to.
924
+
925
+ 232
926
+ 00:16:33,000 --> 00:16:39,000
927
+ And builds groups, you will see that it will be easy to separate source code of our program from the
928
+
929
+ 233
930
+ 00:16:39,000 --> 00:16:44,000
931
+ source code of our tests, and we will not include tests in our final program archive.
932
+
933
+ 234
934
+ 00:16:45,000 --> 00:16:47,000
935
+ It will help us to save some space and memory.
936
+
937
+ 235
938
+ 00:16:48,000 --> 00:16:53,000
939
+ That's why the first thing you have to do on your computer is to create another source folder.
940
+
941
+ 236
942
+ 00:16:53,000 --> 00:16:55,000
943
+ How to do this mouse right.
944
+
945
+ 237
946
+ 00:16:55,000 --> 00:17:02,000
947
+ Click on your project, then select new and select folder write test here and create this folder by
948
+
949
+ 238
950
+ 00:17:02,000 --> 00:17:04,000
951
+ present finish button.
952
+
953
+ 239
954
+ 00:17:04,000 --> 00:17:07,000
955
+ I will not create this folder because I already created it.
956
+
957
+ 240
958
+ 00:17:08,000 --> 00:17:14,000
959
+ The next thing I have to do is to tell the eclipse that I wanted to treat my new folder as a source
960
+
961
+ 241
962
+ 00:17:14,000 --> 00:17:14,000
963
+ folder.
964
+
965
+ 242
966
+ 00:17:15,000 --> 00:17:19,000
967
+ A source folder is marked by clips as containing Java sources.
968
+
969
+ 243
970
+ 00:17:19,000 --> 00:17:25,000
971
+ Then when you compile your project, Eclipse will look for your source code into all your source folders.
972
+
973
+ 244
974
+ 00:17:26,000 --> 00:17:28,000
975
+ You can make any folder become a source folder.
976
+
977
+ 245
978
+ 00:17:28,000 --> 00:17:31,000
979
+ I didn't need to see Java build pass zazz.
980
+
981
+ 246
982
+ 00:17:31,000 --> 00:17:33,000
983
+ Next time you compile your project.
984
+
985
+ 247
986
+ 00:17:33,000 --> 00:17:36,000
987
+ Eclipse will also look for Java classes in that folder.
988
+
989
+ 248
990
+ 00:17:37,000 --> 00:17:39,000
991
+ How to do this press mouse right.
992
+
993
+ 249
994
+ 00:17:39,000 --> 00:17:41,000
995
+ Click on your test folder.
996
+
997
+ 250
998
+ 00:17:41,000 --> 00:17:48,000
999
+ Hover over, build, pass and select use as a source folder and you can see that now this folder is
1000
+
1001
+ 251
1002
+ 00:17:48,000 --> 00:17:53,000
1003
+ marked as a source folder and all Java sources inside will be compiled.
1004
+
1005
+ 252
1006
+ 00:17:53,000 --> 00:17:57,000
1007
+ I already have here a lot of tests that test your homework.
1008
+
1009
+ 253
1010
+ 00:17:58,000 --> 00:17:59,000
1011
+ I will not focus on them today.
1012
+
1013
+ 254
1014
+ 00:18:00,000 --> 00:18:04,000
1015
+ Instead, we are going to create new test with you for our calculator.
1016
+
1017
+ 255
1018
+ 00:18:04,000 --> 00:18:05,000
1019
+ I press mouse right.
1020
+
1021
+ 256
1022
+ 00:18:05,000 --> 00:18:08,000
1023
+ Click on this folder and select new.
1024
+
1025
+ 257
1026
+ 00:18:08,000 --> 00:18:10,000
1027
+ And here I click on the union test case.
1028
+
1029
+ 258
1030
+ 00:18:11,000 --> 00:18:17,000
1031
+ The first thing that we have to understand that each test is a separate matter within the test class.
1032
+
1033
+ 259
1034
+ 00:18:17,000 --> 00:18:22,000
1035
+ So creating a test case, we created a class where we will describe methods.
1036
+
1037
+ 260
1038
+ 00:18:23,000 --> 00:18:28,000
1039
+ Usually test classes are placed in the same package as class that we want to test.
1040
+
1041
+ 261
1042
+ 00:18:28,000 --> 00:18:33,000
1043
+ In our particular case, it is a package where we created the calculator class.
1044
+
1045
+ 262
1046
+ 00:18:34,000 --> 00:18:40,000
1047
+ As you can see on the screen, it is the following package compatibles learning Java Core Jeanneret
1048
+
1049
+ 263
1050
+ 00:18:40,000 --> 00:18:41,000
1051
+ five.
1052
+
1053
+ 264
1054
+ 00:18:41,000 --> 00:18:45,000
1055
+ Let's write the package name in the relevant field in our results.
1056
+
1057
+ 265
1058
+ 00:18:46,000 --> 00:18:48,000
1059
+ Now we have to give our class and name.
1060
+
1061
+ 266
1062
+ 00:18:48,000 --> 00:18:54,000
1063
+ It is not a critical thing what name we are going to give, but it should be clear what class we are
1064
+
1065
+ 267
1066
+ 00:18:54,000 --> 00:18:55,000
1067
+ going to test.
1068
+
1069
+ 268
1070
+ 00:18:56,000 --> 00:18:58,000
1071
+ That's why let's call our new class.
1072
+
1073
+ 269
1074
+ 00:18:58,000 --> 00:18:59,000
1075
+ Calculate the test.
1076
+
1077
+ 270
1078
+ 00:19:00,000 --> 00:19:01,000
1079
+ Do not forget to select your unit.
1080
+
1081
+ 271
1082
+ 00:19:01,000 --> 00:19:10,000
1083
+ Jupiter Test Radio button on the top here, press Finnish button and now you can see another popup eclipse
1084
+
1085
+ 272
1086
+ 00:19:10,000 --> 00:19:16,000
1087
+ is smart enough to understand that we don't have Jupiter libraries in our class past and it will be
1088
+
1089
+ 273
1090
+ 00:19:16,000 --> 00:19:19,000
1091
+ impossible to run tests without these libraries.
1092
+
1093
+ 274
1094
+ 00:19:19,000 --> 00:19:23,000
1095
+ You can add unnecessary dependencies related to G and five.
1096
+
1097
+ 275
1098
+ 00:19:23,000 --> 00:19:27,000
1099
+ Just keep selected as the last radio button from this list and press a button.
1100
+
1101
+ 276
1102
+ 00:19:28,000 --> 00:19:30,000
1103
+ And here's our test is created.
1104
+
1105
+ 277
1106
+ 00:19:30,000 --> 00:19:32,000
1107
+ So what was changed?
1108
+
1109
+ 278
1110
+ 00:19:32,000 --> 00:19:34,000
1111
+ Let me show you mouse.
1112
+
1113
+ 279
1114
+ 00:19:34,000 --> 00:19:34,000
1115
+ Right.
1116
+
1117
+ 280
1118
+ 00:19:34,000 --> 00:19:40,000
1119
+ Click on any file in the project and select build pass configurability pass.
1120
+
1121
+ 281
1122
+ 00:19:40,000 --> 00:19:42,000
1123
+ Go to library, stop.
1124
+
1125
+ 282
1126
+ 00:19:42,000 --> 00:19:47,000
1127
+ And here on the class path, you can see all libraries that are added to your project.
1128
+
1129
+ 283
1130
+ 00:19:47,000 --> 00:19:48,000
1131
+ Right now.
1132
+
1133
+ 284
1134
+ 00:19:48,000 --> 00:19:53,000
1135
+ You can see that I will say that manually geoint for for some libraries.
1136
+
1137
+ 285
1138
+ 00:19:53,000 --> 00:19:56,000
1139
+ I will explain in adolescence what do we need it for.
1140
+
1141
+ 286
1142
+ 00:19:57,000 --> 00:20:00,000
1143
+ And there you can see that Unit five was added.
1144
+
1145
+ 287
1146
+ 00:20:00,000 --> 00:20:06,000
1147
+ You can see that each file has Zha extension jar stands for Java Archive.
1148
+
1149
+ 288
1150
+ 00:20:06,000 --> 00:20:09,000
1151
+ That is typical extension for the group of combined classes.
1152
+
1153
+ 289
1154
+ 00:20:10,000 --> 00:20:15,000
1155
+ In case you would need to add your custom library to a project, you always can do it by present on
1156
+
1157
+ 290
1158
+ 00:20:15,000 --> 00:20:22,000
1159
+ class first and after that press add external Jerse and here you will be able to specify the path to
1160
+
1161
+ 291
1162
+ 00:20:22,000 --> 00:20:24,000
1163
+ the jars that you want to add.
1164
+
1165
+ 292
1166
+ 00:20:25,000 --> 00:20:26,000
1167
+ That is simple.
1168
+
1169
+ 293
1170
+ 00:20:26,000 --> 00:20:29,000
1171
+ Now let me close all these widgets.
1172
+
1173
+ 294
1174
+ 00:20:29,000 --> 00:20:30,000
1175
+ Here is our test.
1176
+
1177
+ 295
1178
+ 00:20:31,000 --> 00:20:38,000
1179
+ By default, if you impose here they are static methods from assertions class and previous version of
1180
+
1181
+ 296
1182
+ 00:20:38,000 --> 00:20:45,000
1183
+ geo engineering information for there was an asset class with static methods that perform assertions.
1184
+
1185
+ 297
1186
+ 00:20:46,000 --> 00:20:49,000
1187
+ And our second impulse is a test annotation.
1188
+
1189
+ 298
1190
+ 00:20:49,000 --> 00:20:56,000
1191
+ This annotation is used to mock each test that should be performed separately as a single test specific
1192
+
1193
+ 299
1194
+ 00:20:56,000 --> 00:20:59,000
1195
+ class that runs our test and the schools run their class.
1196
+
1197
+ 300
1198
+ 00:21:00,000 --> 00:21:04,000
1199
+ It verifies all methods that have annotation test to run.
1200
+
1201
+ 301
1202
+ 00:21:04,000 --> 00:21:10,000
1203
+ All test independently will learn different trainers and how they work in the following lessons.
1204
+
1205
+ 302
1206
+ 00:21:11,000 --> 00:21:17,000
1207
+ After this annotation method is described in union documentation, you can see that each time they provide
1208
+
1209
+ 303
1210
+ 00:21:17,000 --> 00:21:21,000
1211
+ a good example, they use default access modifier for methods.
1212
+
1213
+ 304
1214
+ 00:21:22,000 --> 00:21:24,000
1215
+ Each test should avoid return type.
1216
+
1217
+ 305
1218
+ 00:21:25,000 --> 00:21:31,000
1219
+ In this particular case, stop method was generated and it calls method from assertions class that fails
1220
+
1221
+ 306
1222
+ 00:21:31,000 --> 00:21:32,000
1223
+ our test by the.
1224
+
1225
+ 307
1226
+ 00:21:33,000 --> 00:21:37,000
1227
+ Let's create our test to verify that the Utian works as expected.
1228
+
1229
+ 308
1230
+ 00:21:38,000 --> 00:21:43,000
1231
+ Let's create instance of our calculator type that is our build because of the test.
1232
+
1233
+ 309
1234
+ 00:21:44,000 --> 00:21:48,000
1235
+ After that, let's go at MassArt and pass through there.
1236
+
1237
+ 310
1238
+ 00:21:49,000 --> 00:21:55,000
1239
+ That is our operating path in the terms of build a separate check button will assign the value that
1240
+
1241
+ 311
1242
+ 00:21:55,000 --> 00:21:58,000
1243
+ is returned from this method to actual end variable.
1244
+
1245
+ 312
1246
+ 00:21:59,000 --> 00:22:02,000
1247
+ And now the final part of our test.
1248
+
1249
+ 313
1250
+ 00:22:02,000 --> 00:22:08,000
1251
+ It is chequerboard during the course we are going to run different assertions that will help you to
1252
+
1253
+ 314
1254
+ 00:22:08,000 --> 00:22:14,000
1255
+ perform verifications, majority of them from assertions class that we imparted on the top of our file.
1256
+
1257
+ 315
1258
+ 00:22:15,000 --> 00:22:21,000
1259
+ I call a service equals method to compare expected and actual values I expect expected where we first
1260
+
1261
+ 316
1262
+ 00:22:22,000 --> 00:22:24,000
1263
+ and after that I pass actual value.
1264
+
1265
+ 317
1266
+ 00:22:25,000 --> 00:22:26,000
1267
+ In the case they will be equal.
1268
+
1269
+ 318
1270
+ 00:22:27,000 --> 00:22:30,000
1271
+ Test will pass in case they won't be equal.
1272
+
1273
+ 319
1274
+ 00:22:30,000 --> 00:22:31,000
1275
+ Test will fail.
1276
+
1277
+ 320
1278
+ 00:22:32,000 --> 00:22:33,000
1279
+ Let's run our tests.
1280
+
1281
+ 321
1282
+ 00:22:33,000 --> 00:22:37,000
1283
+ I press control and F eleven together to run the tests.
1284
+
1285
+ 322
1286
+ 00:22:37,000 --> 00:22:42,000
1287
+ And here you can find specific gene to you to check result of our tests.
1288
+
1289
+ 323
1290
+ 00:22:42,000 --> 00:22:49,000
1291
+ I can see that my tests successfully passed in case expected value won't be equal to actual.
1292
+
1293
+ 324
1294
+ 00:22:49,000 --> 00:22:52,000
1295
+ The test would fail just for the sake of the demo.
1296
+
1297
+ 325
1298
+ 00:22:52,000 --> 00:22:54,000
1299
+ Let me change five to six here.
1300
+
1301
+ 326
1302
+ 00:22:54,000 --> 00:22:55,000
1303
+ As expected.
1304
+
1305
+ 327
1306
+ 00:22:55,000 --> 00:23:02,000
1307
+ The result I run test again and you can see assertion failed error expected six but was five.
1308
+
1309
+ 328
1310
+ 00:23:03,000 --> 00:23:07,000
1311
+ That's how you can customize data input to test different cases.
1312
+
1313
+ 329
1314
+ 00:23:07,000 --> 00:23:08,000
1315
+ Congratulations.
1316
+
1317
+ 330
1318
+ 00:23:09,000 --> 00:23:11,000
1319
+ We have just written your first union test.
1320
+
1321
+ 331
1322
+ 00:23:11,000 --> 00:23:15,000
1323
+ We still have a lot of things to learn, but we already wrote our first test.
1324
+
1325
+ 332
1326
+ 00:23:16,000 --> 00:23:18,000
1327
+ We learned a lot for the day.
1328
+
1329
+ 333
1330
+ 00:23:18,000 --> 00:23:24,000
1331
+ So I suggest the recap what we have learned in this lesson in pursuit with more information in the next
1332
+
1333
+ 334
1334
+ 00:23:24,000 --> 00:23:24,000
1335
+ lessons.
1336
+
1337
+ 335
1338
+ 00:23:25,000 --> 00:23:29,000
1339
+ Today, we learned what union testing is you learned in test rules.
1340
+
1341
+ 336
1342
+ 00:23:30,000 --> 00:23:35,000
1343
+ Also in this lesson, I explained to you what first principles are now.
1344
+
1345
+ 337
1346
+ 00:23:35,000 --> 00:23:41,000
1347
+ You know, the basic structure of your test review, such patterns as built operate check three eight.
1348
+
1349
+ 338
1350
+ 00:23:41,000 --> 00:23:48,000
1351
+ And given that, I hold an overview of two, the most popular libraries for unit testing in Java.
1352
+
1353
+ 339
1354
+ 00:23:48,000 --> 00:23:52,000
1355
+ After that, we dive into the details of the unit.
1356
+
1357
+ 340
1358
+ 00:23:52,000 --> 00:23:58,000
1359
+ You learn how to enable JI, you support an eclipse and we roll to your first test.
1360
+
1361
+ 341
1362
+ 00:23:59,000 --> 00:24:00,000
1363
+ That's all for this lesson.
1364
+
1365
+ 342
1366
+ 00:24:00,000 --> 00:24:02,000
1367
+ Thanks a lot for your attention.
1368
+
1369
+ 343
1370
+ 00:24:02,000 --> 00:24:04,000
1371
+ See you in the next lesson.
1372
+
34 - Unit Testing & JUnit 5/002 JUnit 5 examples VS JUnit 4 + Equivalence class partitioning_en.srt ADDED
@@ -0,0 +1,1144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:11,000
3
+ Hello, yes, students in this lesson, we are going to dive into specifics of the unique library and
4
+
5
+ 2
6
+ 00:00:11,000 --> 00:00:15,000
7
+ learn the Unit API by this lesson, you already know what unit testing is.
8
+
9
+ 3
10
+ 00:00:15,000 --> 00:00:18,000
11
+ You also know basic principles of unit testing.
12
+
13
+ 4
14
+ 00:00:18,000 --> 00:00:24,000
15
+ So in this lesson, we'll focus our attention on tools and APIs that is provided by the unit to help
16
+
17
+ 5
18
+ 00:00:24,000 --> 00:00:26,000
19
+ us create reliable use of tests.
20
+
21
+ 6
22
+ 00:00:27,000 --> 00:00:34,000
23
+ We'll learn specifics of Unit five and compared with Unit four, because even now in G four is very
24
+
25
+ 7
26
+ 00:00:34,000 --> 00:00:39,000
27
+ popular and Unit five has modules that helps us to run tests that are written.
28
+
29
+ 8
30
+ 00:00:39,000 --> 00:00:40,000
31
+ What do you need for?
32
+
33
+ 9
34
+ 00:00:40,000 --> 00:00:46,000
35
+ That's why knowing specifics of both libraries is important, in my opinion, in this class.
36
+
37
+ 10
38
+ 00:00:46,000 --> 00:00:51,000
39
+ And we are going to learn how to declare an assets in a unit that will help us to set up environment
40
+
41
+ 11
42
+ 00:00:51,000 --> 00:00:57,000
43
+ for execution of each test case and clean up environment after each test case execution during this
44
+
45
+ 12
46
+ 00:00:57,000 --> 00:00:58,000
47
+ class.
48
+
49
+ 13
50
+ 00:00:58,000 --> 00:01:02,000
51
+ And I'll show your code examples and we'll cover specific code with tests.
52
+
53
+ 14
54
+ 00:01:03,000 --> 00:01:10,000
55
+ You will learn how to use test annotation also on equivalence class partitioning technique on real examples.
56
+
57
+ 15
58
+ 00:01:10,000 --> 00:01:17,000
59
+ You see how it can help us to save time and write tests that really helps us to test all possible test
60
+
61
+ 16
62
+ 00:01:17,000 --> 00:01:17,000
63
+ cases.
64
+
65
+ 17
66
+ 00:01:18,000 --> 00:01:23,000
67
+ And at the end of the lesson, I'll show you how to test exceptions, which you we have a lot of things
68
+
69
+ 18
70
+ 00:01:23,000 --> 00:01:25,000
71
+ to learn in this lesson.
72
+
73
+ 19
74
+ 00:01:25,000 --> 00:01:28,000
75
+ We are going to have a lot of coding examples and live demo.
76
+
77
+ 20
78
+ 00:01:28,000 --> 00:01:35,000
79
+ So let's start first of all, I want to highlight you source of information to learn your unit always
80
+
81
+ 21
82
+ 00:01:35,000 --> 00:01:38,000
83
+ rely only on official documentation.
84
+
85
+ 22
86
+ 00:01:38,000 --> 00:01:44,000
87
+ Information and books may be not relevant information and some tutorials may not contain all the details
88
+
89
+ 23
90
+ 00:01:44,000 --> 00:01:45,000
91
+ and specifics.
92
+
93
+ 24
94
+ 00:01:45,000 --> 00:01:50,000
95
+ So knowing where official documentation is located is always useful.
96
+
97
+ 25
98
+ 00:01:50,000 --> 00:01:52,000
99
+ I will leave this link and attachments to the video.
100
+
101
+ 26
102
+ 00:01:53,000 --> 00:01:55,000
103
+ But let me also make a brief overview here.
104
+
105
+ 27
106
+ 00:01:55,000 --> 00:01:57,000
107
+ You can see a list of all modules.
108
+
109
+ 28
110
+ 00:01:57,000 --> 00:02:01,000
111
+ As we keep learning a unit, you will gradually learn all of these.
112
+
113
+ 29
114
+ 00:02:01,000 --> 00:02:04,000
115
+ We can explore each module by clicking on it.
116
+
117
+ 30
118
+ 00:02:04,000 --> 00:02:11,000
119
+ If you remember in previous lesson we wrote our first unit test and we used as equals message from assertions
120
+
121
+ 31
122
+ 00:02:11,000 --> 00:02:11,000
123
+ class.
124
+
125
+ 32
126
+ 00:02:12,000 --> 00:02:15,000
127
+ Let's find this class and learn what other methods allocated there.
128
+
129
+ 33
130
+ 00:02:16,000 --> 00:02:23,000
131
+ To find assertions class, just click on org unit Jupiter API module after choose or GIULIAN Jupiter
132
+
133
+ 34
134
+ 00:02:23,000 --> 00:02:24,000
135
+ API package.
136
+
137
+ 35
138
+ 00:02:24,000 --> 00:02:29,000
139
+ And here you can find a list of interfaces and list of classes from this package.
140
+
141
+ 36
142
+ 00:02:30,000 --> 00:02:31,000
143
+ Here is our sessions class.
144
+
145
+ 37
146
+ 00:02:32,000 --> 00:02:33,000
147
+ Let's open it.
148
+
149
+ 38
150
+ 00:02:33,000 --> 00:02:35,000
151
+ And here is a full list of matches.
152
+
153
+ 39
154
+ 00:02:35,000 --> 00:02:39,000
155
+ You can click on any method that is interesting for you to learn documentation.
156
+
157
+ 40
158
+ 00:02:40,000 --> 00:02:46,000
159
+ How this example helps you understand how you can find documentation by using module, name, package,
160
+
161
+ 41
162
+ 00:02:46,000 --> 00:02:47,000
163
+ name and class name.
164
+
165
+ 42
166
+ 00:02:47,000 --> 00:02:51,000
167
+ So and he Sampson will remain clear even after today's lesson.
168
+
169
+ 43
170
+ 00:02:51,000 --> 00:02:54,000
171
+ You can always open documentation to read it.
172
+
173
+ 44
174
+ 00:02:54,000 --> 00:02:55,000
175
+ Let's proceed.
176
+
177
+ 45
178
+ 00:02:55,000 --> 00:02:57,000
179
+ I open Eclipse.
180
+
181
+ 46
182
+ 00:02:57,000 --> 00:03:02,000
183
+ I suggest to learn the first two classes that we are going to cover with test today.
184
+
185
+ 47
186
+ 00:03:02,000 --> 00:03:05,000
187
+ We have class with name mining transaction service.
188
+
189
+ 48
190
+ 00:03:05,000 --> 00:03:07,000
191
+ It has one method to transfer money.
192
+
193
+ 49
194
+ 00:03:08,000 --> 00:03:12,000
195
+ This method takes two accounts as arguments they account from.
196
+
197
+ 50
198
+ 00:03:13,000 --> 00:03:20,000
199
+ That is from where money should be sent an account to this is where money should be sent and amount
200
+
201
+ 51
202
+ 00:03:20,000 --> 00:03:20,000
203
+ of money to send.
204
+
205
+ 52
206
+ 00:03:21,000 --> 00:03:23,000
207
+ Let me show you the source code of account.
208
+
209
+ 53
210
+ 00:03:23,000 --> 00:03:29,000
211
+ Class account is a separate class that is located in the same package with current example.
212
+
213
+ 54
214
+ 00:03:29,000 --> 00:03:32,000
215
+ For the sake of the damos, it contains only one field default.
216
+
217
+ 55
218
+ 00:03:32,000 --> 00:03:35,000
219
+ Constructor and constructor was one argument.
220
+
221
+ 56
222
+ 00:03:35,000 --> 00:03:38,000
223
+ Additionally, we have getters and setters here.
224
+
225
+ 57
226
+ 00:03:38,000 --> 00:03:39,000
227
+ That's it.
228
+
229
+ 58
230
+ 00:03:39,000 --> 00:03:44,000
231
+ Let's get back now to mining transaction service here and transfer money.
232
+
233
+ 59
234
+ 00:03:44,000 --> 00:03:46,000
235
+ Massata, you can see if few cheques.
236
+
237
+ 60
238
+ 00:03:46,000 --> 00:03:52,000
239
+ It is important to understand the logic of the method to be able to write a test for it in case account
240
+
241
+ 61
242
+ 00:03:52,000 --> 00:03:59,000
243
+ from our account is now we through legal argument, exception with this message in case money amount
244
+
245
+ 62
246
+ 00:03:59,000 --> 00:04:06,000
247
+ is less or equal to zero withdrawal illegal argument exception but with different error message in case
248
+
249
+ 63
250
+ 00:04:06,000 --> 00:04:12,000
251
+ account from doesn't have enough money for this transaction, we throw our custom exception, not enough
252
+
253
+ 64
254
+ 00:04:12,000 --> 00:04:13,000
255
+ money exception.
256
+
257
+ 65
258
+ 00:04:14,000 --> 00:04:18,000
259
+ And only after all these checks we can perform a transaction.
260
+
261
+ 66
262
+ 00:04:18,000 --> 00:04:24,000
263
+ We decrease amount of money for our account from and we increase amount of money for account to and
264
+
265
+ 67
266
+ 00:04:24,000 --> 00:04:27,000
267
+ we return true in case transaction is successful.
268
+
269
+ 68
270
+ 00:04:28,000 --> 00:04:31,000
271
+ The simple example that is really close to real life case.
272
+
273
+ 69
274
+ 00:04:31,000 --> 00:04:34,000
275
+ And today we are going to cover this unit with units.
276
+
277
+ 70
278
+ 00:04:35,000 --> 00:04:37,000
279
+ Let's start from previous lesson.
280
+
281
+ 71
282
+ 00:04:37,000 --> 00:04:41,000
283
+ You already know that it is recommended to create test in the separate source folder.
284
+
285
+ 72
286
+ 00:04:42,000 --> 00:04:48,000
287
+ I already created this test before the lesson to save time during the year I called this test class
288
+
289
+ 73
290
+ 00:04:48,000 --> 00:04:49,000
291
+ money transaction service test.
292
+
293
+ 74
294
+ 00:04:49,000 --> 00:04:52,000
295
+ I will walk you through each line one by one.
296
+
297
+ 75
298
+ 00:04:53,000 --> 00:04:56,000
299
+ First of all, I declare a field in my test class.
300
+
301
+ 76
302
+ 00:04:56,000 --> 00:05:02,000
303
+ This field has type of unit that we are going to test my transaction service I call variable test.
304
+
305
+ 77
306
+ 00:05:02,000 --> 00:05:08,000
307
+ For instance, I have to initialize it, don't pay attention to these concerns right now, you will
308
+
309
+ 78
310
+ 00:05:08,000 --> 00:05:11,000
311
+ understand a little bit later in this lesson, why do we need them?
312
+
313
+ 79
314
+ 00:05:12,000 --> 00:05:16,000
315
+ Usually we create a special message that will be executed before each test.
316
+
317
+ 80
318
+ 00:05:16,000 --> 00:05:18,000
319
+ That's why it is important.
320
+
321
+ 81
322
+ 00:05:19,000 --> 00:05:23,000
323
+ You remember first principles, each test should be isolated from another.
324
+
325
+ 82
326
+ 00:05:24,000 --> 00:05:26,000
327
+ That's why it is important that you're in each test.
328
+
329
+ 83
330
+ 00:05:26,000 --> 00:05:31,000
331
+ I create a new instance of mining transaction service because potentially this object may have some
332
+
333
+ 84
334
+ 00:05:31,000 --> 00:05:37,000
335
+ states that will be adjusted by one test and that will impact on the execution of another test.
336
+
337
+ 85
338
+ 00:05:38,000 --> 00:05:46,000
339
+ This special method has annotation before each annotations and that information for unit, namely for
340
+
341
+ 86
342
+ 00:05:46,000 --> 00:05:53,000
343
+ the class that is going to execute our tests is a group of classes that executes test called runners.
344
+
345
+ 87
346
+ 00:05:53,000 --> 00:05:58,000
347
+ The runner will verify what method and class has before each annotation.
348
+
349
+ 88
350
+ 00:05:58,000 --> 00:06:06,000
351
+ It will memorize it and will run this method before each test method in for there was a similar notation
352
+
353
+ 89
354
+ 00:06:06,000 --> 00:06:06,000
355
+ before.
356
+
357
+ 90
358
+ 00:06:07,000 --> 00:06:14,000
359
+ As you can see, there is no big difference between Unit four and five so far in this method, I initialize
360
+
361
+ 91
362
+ 00:06:14,000 --> 00:06:17,000
363
+ my test instance usually common configurations.
364
+
365
+ 92
366
+ 00:06:17,000 --> 00:06:22,000
367
+ It is important for each test is placed in this method, but we have only one line.
368
+
369
+ 93
370
+ 00:06:23,000 --> 00:06:26,000
371
+ Pay attention that this method has what return type?
372
+
373
+ 94
374
+ 00:06:26,000 --> 00:06:32,000
375
+ You can name this method as you wish, but I usually name it set up in the unit.
376
+
377
+ 95
378
+ 00:06:32,000 --> 00:06:36,000
379
+ We also can configure methods that will be executed after each test.
380
+
381
+ 96
382
+ 00:06:36,000 --> 00:06:41,000
383
+ This method has annotation after each injury unit five and after injury unit four.
384
+
385
+ 97
386
+ 00:06:42,000 --> 00:06:46,000
387
+ In our particular case, there is no need to perform any actions after each test.
388
+
389
+ 98
390
+ 00:06:46,000 --> 00:06:48,000
391
+ But you can clean up something.
392
+
393
+ 99
394
+ 00:06:48,000 --> 00:06:53,000
395
+ What was done by your test to stay aligned with repeatable and isolated principles?
396
+
397
+ 100
398
+ 00:06:53,000 --> 00:07:00,000
399
+ There are also two specific annotations that allows us to execute specific code before all test methods
400
+
401
+ 101
402
+ 00:07:00,000 --> 00:07:06,000
403
+ and after all, test matches we can create Masset and market was before all annotation.
404
+
405
+ 102
406
+ 00:07:06,000 --> 00:07:13,000
407
+ This method will be executed before all test methods pay attention to this method has static modifier
408
+
409
+ 103
410
+ 00:07:13,000 --> 00:07:17,000
411
+ in case you use it for you can use before class annotation.
412
+
413
+ 104
414
+ 00:07:18,000 --> 00:07:21,000
415
+ Similar to this annotation, we have another one.
416
+
417
+ 105
418
+ 00:07:21,000 --> 00:07:28,000
419
+ Marcu static method was, after all, annotation and this method will be executed after all test methods
420
+
421
+ 106
422
+ 00:07:28,000 --> 00:07:32,000
423
+ in unit four you can use after class annotation instead.
424
+
425
+ 107
426
+ 00:07:32,000 --> 00:07:35,000
427
+ To be honest, these cases are very specific.
428
+
429
+ 108
430
+ 00:07:35,000 --> 00:07:36,000
431
+ Why?
432
+
433
+ 109
434
+ 00:07:36,000 --> 00:07:39,000
435
+ Because you want to isolate each test case from Annisa.
436
+
437
+ 110
438
+ 00:07:40,000 --> 00:07:45,000
439
+ That's why performing some specific action before running all test cases and some method only.
440
+
441
+ 111
442
+ 00:07:45,000 --> 00:07:50,000
443
+ After all test cases means that all test cases have something in common.
444
+
445
+ 112
446
+ 00:07:50,000 --> 00:07:55,000
447
+ While this could be the case, sometimes this is very rare based on my experience.
448
+
449
+ 113
450
+ 00:07:56,000 --> 00:08:02,000
451
+ So remember, use annotations and use them when you need, but most likely before each and after each
452
+
453
+ 114
454
+ 00:08:02,000 --> 00:08:04,000
455
+ will be enough for you in most cases.
456
+
457
+ 115
458
+ 00:08:05,000 --> 00:08:07,000
459
+ Let's move on now.
460
+
461
+ 116
462
+ 00:08:07,000 --> 00:08:08,000
463
+ Let's write test.
464
+
465
+ 117
466
+ 00:08:08,000 --> 00:08:12,000
467
+ Each test is a separate method that is marked with annotation test.
468
+
469
+ 118
470
+ 00:08:13,000 --> 00:08:17,000
471
+ Each test method has void's return type in June five.
472
+
473
+ 119
474
+ 00:08:17,000 --> 00:08:22,000
475
+ It is important the test method has any access modifier that is not private in unit four.
476
+
477
+ 120
478
+ 00:08:23,000 --> 00:08:27,000
479
+ It is important the test method should have public access modifier.
480
+
481
+ 121
482
+ 00:08:27,000 --> 00:08:28,000
483
+ That is model changed.
484
+
485
+ 122
486
+ 00:08:28,000 --> 00:08:31,000
487
+ But still this is worse to mention in my opinion.
488
+
489
+ 123
490
+ 00:08:32,000 --> 00:08:38,000
491
+ As you remember, it is important to give meaningful names to our tests to make sure that everyone understands
492
+
493
+ 124
494
+ 00:08:38,000 --> 00:08:39,000
495
+ what this method is about.
496
+
497
+ 125
498
+ 00:08:40,000 --> 00:08:46,000
499
+ Some tutors and tutorials that teach you to test methods also teach you how to make masses in case with
500
+
501
+ 126
502
+ 00:08:46,000 --> 00:08:49,000
503
+ test transfer money method we have to write transfer money test.
504
+
505
+ 127
506
+ 00:08:50,000 --> 00:08:53,000
507
+ In other words, just a test suffix at the end of the method.
508
+
509
+ 128
510
+ 00:08:54,000 --> 00:09:00,000
511
+ But in my opinion, it is more important to not just make sure that you have a test for some specific
512
+
513
+ 129
514
+ 00:09:00,000 --> 00:09:00,000
515
+ method.
516
+
517
+ 130
518
+ 00:09:00,000 --> 00:09:05,000
519
+ I would rather prefer to make sure that method behaves in the way I expect it behaves.
520
+
521
+ 131
522
+ 00:09:06,000 --> 00:09:08,000
523
+ And I want to reflect this in Masaomi.
524
+
525
+ 132
526
+ 00:09:09,000 --> 00:09:14,000
527
+ That's why I recommend you to make sure that method names are named after expected behavior.
528
+
529
+ 133
530
+ 00:09:15,000 --> 00:09:21,000
531
+ Always remember that your tests are documentation, just telling this documentation what your test unit
532
+
533
+ 134
534
+ 00:09:21,000 --> 00:09:27,000
535
+ should be able to do and how it should behave in case how a unit should be able to transfer money.
536
+
537
+ 135
538
+ 00:09:27,000 --> 00:09:33,000
539
+ Let's call this method and this way should transfer money from one account to another.
540
+
541
+ 136
542
+ 00:09:33,000 --> 00:09:39,000
543
+ That's why one of the ways to name your methods is to start name it from should word and describe what
544
+
545
+ 137
546
+ 00:09:39,000 --> 00:09:41,000
547
+ your unit should be able to do.
548
+
549
+ 138
550
+ 00:09:41,000 --> 00:09:43,000
551
+ This makes things clearer, don't you think?
552
+
553
+ 139
554
+ 00:09:43,000 --> 00:09:46,000
555
+ So now let's explore the test itself.
556
+
557
+ 140
558
+ 00:09:47,000 --> 00:09:48,000
559
+ I write test accordingly.
560
+
561
+ 141
562
+ 00:09:48,000 --> 00:09:51,000
563
+ Even when then partan we have two accounts.
564
+
565
+ 142
566
+ 00:09:52,000 --> 00:09:55,000
567
+ Pay attention that I don't have any magic numbers in my code.
568
+
569
+ 143
570
+ 00:09:55,000 --> 00:10:00,000
571
+ Instead, I declare constants that clearly describe what this value for.
572
+
573
+ 144
574
+ 00:10:00,000 --> 00:10:02,000
575
+ For example, in my test I have.
576
+
577
+ 145
578
+ 00:10:02,000 --> 00:10:08,000
579
+ We have some random value for amount of money, and that's why I called this constant in the same way
580
+
581
+ 146
582
+ 00:10:08,000 --> 00:10:13,000
583
+ random money amount in case this is zero, I call it zero my amount.
584
+
585
+ 147
586
+ 00:10:14,000 --> 00:10:21,000
587
+ Here's one note samples for static analysis doesn't three zero and one will use as magic numbers because
588
+
589
+ 148
590
+ 00:10:21,000 --> 00:10:27,000
591
+ usually it is clear when you use zero and one, it is not so confusing as using another numbers.
592
+
593
+ 149
594
+ 00:10:27,000 --> 00:10:34,000
595
+ For example, in case you used zero, it is clear that you use to zero to zero money amount for a count.
596
+
597
+ 150
598
+ 00:10:35,000 --> 00:10:42,000
599
+ But in case you use three, it is not clear why you use three, but not five and not 10.
600
+
601
+ 151
602
+ 00:10:42,000 --> 00:10:46,000
603
+ Can you understand now what our magic numbers but still in tests?
604
+
605
+ 152
606
+ 00:10:47,000 --> 00:10:51,000
607
+ I prefer to give a name even to zero and one values is that's my style.
608
+
609
+ 153
610
+ 00:10:52,000 --> 00:10:53,000
611
+ But you can decide and choose.
612
+
613
+ 154
614
+ 00:10:53,000 --> 00:10:57,000
615
+ Your next part of the method is my when part.
616
+
617
+ 155
618
+ 00:10:58,000 --> 00:11:02,000
619
+ I want to execute method I pass to accounts there and money amount.
620
+
621
+ 156
622
+ 00:11:02,000 --> 00:11:08,000
623
+ I know that this money amount is valid money amount because I created the first account with such my
624
+
625
+ 157
626
+ 00:11:08,000 --> 00:11:09,000
627
+ amount.
628
+
629
+ 158
630
+ 00:11:09,000 --> 00:11:14,000
631
+ So I know that my transaction should be successful and my test should pass.
632
+
633
+ 159
634
+ 00:11:14,000 --> 00:11:21,000
635
+ Now I have final part of my test that is a certain part and this is the case when I can perform two
636
+
637
+ 160
638
+ 00:11:21,000 --> 00:11:27,000
639
+ assertions in one test because two assertions are connected with a single concept.
640
+
641
+ 161
642
+ 00:11:27,000 --> 00:11:33,000
643
+ I have to verify that amount of money is decreased to zero on the first account and the amount of money
644
+
645
+ 162
646
+ 00:11:33,000 --> 00:11:35,000
647
+ is increased on the second account.
648
+
649
+ 163
650
+ 00:11:35,000 --> 00:11:37,000
651
+ That's why I have these two assertions.
652
+
653
+ 164
654
+ 00:11:37,000 --> 00:11:43,000
655
+ In one test case, I use a service equals method and plus expected and actual value to it.
656
+
657
+ 165
658
+ 00:11:44,000 --> 00:11:49,000
659
+ You already know this assertion from previous lesson, so nothing special here.
660
+
661
+ 166
662
+ 00:11:49,000 --> 00:11:56,000
663
+ Now let me run this test one more time in case you work in Eclipse and you want to execute only one
664
+
665
+ 167
666
+ 00:11:56,000 --> 00:11:59,000
667
+ single test, but not all tests from the class.
668
+
669
+ 168
670
+ 00:12:00,000 --> 00:12:04,000
671
+ Make sure that your cursor is near the test method name, for example.
672
+
673
+ 169
674
+ 00:12:04,000 --> 00:12:05,000
675
+ Here is my cursor.
676
+
677
+ 170
678
+ 00:12:05,000 --> 00:12:06,000
679
+ Can I see it?
680
+
681
+ 171
682
+ 00:12:06,000 --> 00:12:08,000
683
+ You can run test by pressing the mouse, right?
684
+
685
+ 172
686
+ 00:12:08,000 --> 00:12:11,000
687
+ Click and choose and run as a unit test.
688
+
689
+ 173
690
+ 00:12:11,000 --> 00:12:15,000
691
+ But I love to use shortcuts and now I press control and f eleven.
692
+
693
+ 174
694
+ 00:12:16,000 --> 00:12:23,000
695
+ And here in test results you can see that only one method was executed and it passed in case I have
696
+
697
+ 175
698
+ 00:12:23,000 --> 00:12:31,000
699
+ cursor placed in any other place and I press control and then all tests are executed and then test results.
700
+
701
+ 176
702
+ 00:12:31,000 --> 00:12:33,000
703
+ Now you can see more than one test.
704
+
705
+ 177
706
+ 00:12:33,000 --> 00:12:34,000
707
+ Is that clear?
708
+
709
+ 178
710
+ 00:12:35,000 --> 00:12:41,000
711
+ So my test passed as I expected, but in this specific case, I still won't be happy.
712
+
713
+ 179
714
+ 00:12:42,000 --> 00:12:49,000
715
+ My experience tells me that I shouldn't believe to the test that I have never seen Rat or in other words,
716
+
717
+ 180
718
+ 00:12:49,000 --> 00:12:49,000
719
+ failed.
720
+
721
+ 181
722
+ 00:12:50,000 --> 00:12:50,000
723
+ Why?
724
+
725
+ 182
726
+ 00:12:51,000 --> 00:12:57,000
727
+ Because there are some cases when you run the test and it is green and you are happy, but when some
728
+
729
+ 183
730
+ 00:12:57,000 --> 00:13:03,000
731
+ defect is popped up, you are wondering why unit test was not failed and you learn that your test is
732
+
733
+ 184
734
+ 00:13:03,000 --> 00:13:07,000
735
+ never rat, even when you specify wrong expected value.
736
+
737
+ 185
738
+ 00:13:08,000 --> 00:13:14,000
739
+ Not delving into the details right now, but it could be that you wrote your test that is always passed
740
+
741
+ 186
742
+ 00:13:14,000 --> 00:13:16,000
743
+ because you missed some minor detail.
744
+
745
+ 187
746
+ 00:13:16,000 --> 00:13:23,000
747
+ That's why writing test first is good, because you are always sure that you saw this test firing and
748
+
749
+ 188
750
+ 00:13:23,000 --> 00:13:24,000
751
+ you saw this test passed.
752
+
753
+ 189
754
+ 00:13:25,000 --> 00:13:31,000
755
+ My advices in case you write your test after you already wrote the code, just spent two more seconds
756
+
757
+ 190
758
+ 00:13:31,000 --> 00:13:34,000
759
+ to test it with some invalid expected value.
760
+
761
+ 191
762
+ 00:13:34,000 --> 00:13:37,000
763
+ For example, here, unexpected value.
764
+
765
+ 192
766
+ 00:13:37,000 --> 00:13:40,000
767
+ I would specify some random value and will run the test one more time.
768
+
769
+ 193
770
+ 00:13:41,000 --> 00:13:45,000
771
+ Now I see the test has failed and I can be calm and sleep well.
772
+
773
+ 194
774
+ 00:13:45,000 --> 00:13:51,000
775
+ My test is useful and it will tell me in case something will go wrong during the transaction, I will
776
+
777
+ 195
778
+ 00:13:51,000 --> 00:13:55,000
779
+ return the valid expected value and will proceed with the next test.
780
+
781
+ 196
782
+ 00:13:55,000 --> 00:14:01,000
783
+ I want to ask you interesting question that I always ask during the interview when I want to verify
784
+
785
+ 197
786
+ 00:14:01,000 --> 00:14:03,000
787
+ whether a person can write test efficiently.
788
+
789
+ 198
790
+ 00:14:04,000 --> 00:14:08,000
791
+ The question is how you can be sure that you wrote enough tests.
792
+
793
+ 199
794
+ 00:14:09,000 --> 00:14:15,000
795
+ For example, we test my transaction with some random well, you this when the value is equal to the
796
+
797
+ 200
798
+ 00:14:15,000 --> 00:14:18,000
799
+ amount of money on the account before money transaction.
800
+
801
+ 201
802
+ 00:14:18,000 --> 00:14:22,000
803
+ How many more tests will you write when you arrive now?
804
+
805
+ 202
806
+ 00:14:22,000 --> 00:14:25,000
807
+ Test with transferring money was another random value.
808
+
809
+ 203
810
+ 00:14:25,000 --> 00:14:30,000
811
+ Or you would said twice as much money on the account and you would transfer only half of the money.
812
+
813
+ 204
814
+ 00:14:31,000 --> 00:14:37,000
815
+ Would this test have sense and do you need to write it or no press pause and take a minute to think
816
+
817
+ 205
818
+ 00:14:37,000 --> 00:14:38,000
819
+ about this question.
820
+
821
+ 206
822
+ 00:14:38,000 --> 00:14:39,000
823
+ How would you answer?
824
+
825
+ 207
826
+ 00:14:40,000 --> 00:14:44,000
827
+ I expect to hear that you know what equivalence class position is?
828
+
829
+ 208
830
+ 00:14:45,000 --> 00:14:46,000
831
+ What is this?
832
+
833
+ 209
834
+ 00:14:46,000 --> 00:14:51,000
835
+ This is software testing technique that divides the input data of a software unit.
836
+
837
+ 210
838
+ 00:14:51,000 --> 00:14:57,000
839
+ Interpretations of equivalent data from each test cases can be derived in principle.
840
+
841
+ 211
842
+ 00:14:57,000 --> 00:15:02,000
843
+ Test cases are designed to cover each partition at least once this.
844
+
845
+ 212
846
+ 00:15:03,000 --> 00:15:10,000
847
+ Tries to define test cases that uncover clusters of errors, thereby reducing the total number of test
848
+
849
+ 213
850
+ 00:15:10,000 --> 00:15:16,000
851
+ cases that must be developed, an advantage of this approach is a reduction in the time required for
852
+
853
+ 214
854
+ 00:15:16,000 --> 00:15:21,000
855
+ testing software use the less number of test cases, how to apply this knowledge while writing unit
856
+
857
+ 215
858
+ 00:15:22,000 --> 00:15:24,000
859
+ tests before writing any sort of test.
860
+
861
+ 216
862
+ 00:15:24,000 --> 00:15:28,000
863
+ Sit down and think about all possible inputs to your method.
864
+
865
+ 217
866
+ 00:15:29,000 --> 00:15:34,000
867
+ Group these inputs and write test for only one example of data input from each group.
868
+
869
+ 218
870
+ 00:15:35,000 --> 00:15:37,000
871
+ How to apply this knowledge in our example.
872
+
873
+ 219
874
+ 00:15:37,000 --> 00:15:43,000
875
+ Let me show you, for example, the need to write test the test transaction of another positive money
876
+
877
+ 220
878
+ 00:15:43,000 --> 00:15:44,000
879
+ amount.
880
+
881
+ 221
882
+ 00:15:44,000 --> 00:15:47,000
883
+ No, because one hundred that is our end.
884
+
885
+ 222
886
+ 00:15:47,000 --> 00:15:52,000
887
+ The value is the same as 50, the same as 20, all in the same equivalence class.
888
+
889
+ 223
890
+ 00:15:53,000 --> 00:15:58,000
891
+ These are all numbers that are greater than or equal to the amount of money that are currently on the
892
+
893
+ 224
894
+ 00:15:58,000 --> 00:15:59,000
895
+ account.
896
+
897
+ 225
898
+ 00:15:59,000 --> 00:16:01,000
899
+ Number one, by the way.
900
+
901
+ 226
902
+ 00:16:01,000 --> 00:16:03,000
903
+ Let me switch to the implementation class.
904
+
905
+ 227
906
+ 00:16:03,000 --> 00:16:04,000
907
+ Can I see this?
908
+
909
+ 228
910
+ 00:16:04,000 --> 00:16:11,000
911
+ If class I check was a money amount to transfer is no more than the current amount of money on the account.
912
+
913
+ 229
914
+ 00:16:12,000 --> 00:16:15,000
915
+ That means we defined our first equivalence class.
916
+
917
+ 230
918
+ 00:16:15,000 --> 00:16:16,000
919
+ Is that clear?
920
+
921
+ 231
922
+ 00:16:17,000 --> 00:16:22,000
923
+ And that is how this technique can help us to save time by writing less number of tests.
924
+
925
+ 232
926
+ 00:16:22,000 --> 00:16:27,000
927
+ But at the same time, be sure that we have a set of tests that will secure us.
928
+
929
+ 233
930
+ 00:16:27,000 --> 00:16:33,000
931
+ Let's now proceed with defining our next set of data for testing based on our source code.
932
+
933
+ 234
934
+ 00:16:33,000 --> 00:16:36,000
935
+ We also know that there are different conditions.
936
+
937
+ 235
938
+ 00:16:36,000 --> 00:16:39,000
939
+ One exception is thrown our next Test match.
940
+
941
+ 236
942
+ 00:16:39,000 --> 00:16:42,000
943
+ It sounds like this should throw exception.
944
+
945
+ 237
946
+ 00:16:42,000 --> 00:16:49,000
947
+ If I count from is now my great first account variable that is referencing to now I create the second
948
+
949
+ 238
950
+ 00:16:49,000 --> 00:16:53,000
951
+ account and now I call another method from assertions class.
952
+
953
+ 239
954
+ 00:16:53,000 --> 00:16:55,000
955
+ The method is called asserts rules.
956
+
957
+ 240
958
+ 00:16:56,000 --> 00:17:02,000
959
+ This method verifies that the US exceptions of specific type of identification of some method.
960
+
961
+ 241
962
+ 00:17:02,000 --> 00:17:05,000
963
+ The test will pass only in case error of this type.
964
+
965
+ 242
966
+ 00:17:05,000 --> 00:17:07,000
967
+ In our case, this is a legal argument.
968
+
969
+ 243
970
+ 00:17:07,000 --> 00:17:09,000
971
+ The exception is wrong.
972
+
973
+ 244
974
+ 00:17:09,000 --> 00:17:12,000
975
+ In case there were no exception or was the exception of another type.
976
+
977
+ 245
978
+ 00:17:13,000 --> 00:17:17,000
979
+ The test will be failed, asserts Rose, takes two arguments.
980
+
981
+ 246
982
+ 00:17:17,000 --> 00:17:23,000
983
+ The first argument is a class of expected exception, and the second argument is a function that will
984
+
985
+ 247
986
+ 00:17:23,000 --> 00:17:24,000
987
+ execute any MassArt unit.
988
+
989
+ 248
990
+ 00:17:25,000 --> 00:17:28,000
991
+ Usually we describe this with the help of lambda expression.
992
+
993
+ 249
994
+ 00:17:28,000 --> 00:17:31,000
995
+ As you can see, I call transfer money method from lambda function.
996
+
997
+ 250
998
+ 00:17:32,000 --> 00:17:33,000
999
+ Does it make sense?
1000
+
1001
+ 251
1002
+ 00:17:33,000 --> 00:17:36,000
1003
+ One more interesting thing to note here.
1004
+
1005
+ 252
1006
+ 00:17:36,000 --> 00:17:40,000
1007
+ Let me open the source code of our class that we are testing, if you remember.
1008
+
1009
+ 253
1010
+ 00:17:40,000 --> 00:17:47,000
1011
+ And our method was a legal argument, exception in three cases when I count from is now when I count
1012
+
1013
+ 254
1014
+ 00:17:47,000 --> 00:17:51,000
1015
+ two is now and when the money amount to transfer is less than or equal to zero.
1016
+
1017
+ 255
1018
+ 00:17:52,000 --> 00:17:58,000
1019
+ How to understand when I get exceptional because of invalid account argument or because of invalid money
1020
+
1021
+ 256
1022
+ 00:17:58,000 --> 00:18:03,000
1023
+ amount argument, especially for this I used messages in exceptions.
1024
+
1025
+ 257
1026
+ 00:18:03,000 --> 00:18:09,000
1027
+ Let's get back to our test, asserts Rosmus returns the reference to exception object.
1028
+
1029
+ 258
1030
+ 00:18:09,000 --> 00:18:12,000
1031
+ I can capture it and assign a variable.
1032
+
1033
+ 259
1034
+ 00:18:12,000 --> 00:18:16,000
1035
+ The next thing that I will do, I will check that message of exception.
1036
+
1037
+ 260
1038
+ 00:18:16,000 --> 00:18:20,000
1039
+ Exactly the message that I expect to have now.
1040
+
1041
+ 261
1042
+ 00:18:20,000 --> 00:18:23,000
1043
+ I can be sure, as it indicates this assertion will pass.
1044
+
1045
+ 262
1046
+ 00:18:23,000 --> 00:18:30,000
1047
+ That would mean that I received exactly the legal argument exception that I expected that it makes sense
1048
+
1049
+ 263
1050
+ 00:18:30,000 --> 00:18:31,000
1051
+ in for.
1052
+
1053
+ 264
1054
+ 00:18:31,000 --> 00:18:37,000
1055
+ You had an opportunity to specify type of expected exception, your test annotation just like this.
1056
+
1057
+ 265
1058
+ 00:18:37,000 --> 00:18:43,000
1059
+ You write expected words in parentheses and specify class of exception that you expect.
1060
+
1061
+ 266
1062
+ 00:18:43,000 --> 00:18:49,000
1063
+ You can see that in this case, I use annotation from another package that is used for package.
1064
+
1065
+ 267
1066
+ 00:18:50,000 --> 00:18:56,000
1067
+ I show that just for the sake of the example, how to test similar case in unit for the next test case
1068
+
1069
+ 268
1070
+ 00:18:56,000 --> 00:18:58,000
1071
+ is similar to the current one.
1072
+
1073
+ 269
1074
+ 00:18:58,000 --> 00:19:01,000
1075
+ We just test the same in case account two is now.
1076
+
1077
+ 270
1078
+ 00:19:02,000 --> 00:19:03,000
1079
+ What are the cases we have?
1080
+
1081
+ 271
1082
+ 00:19:04,000 --> 00:19:09,000
1083
+ We also thrown out enough money exception in case we want to transfer more monies and we actually have
1084
+
1085
+ 272
1086
+ 00:19:10,000 --> 00:19:16,000
1087
+ we have test to verify exception in case we try to send negative money amount and the same error in
1088
+
1089
+ 273
1090
+ 00:19:16,000 --> 00:19:17,000
1091
+ case we want to transfer zero.
1092
+
1093
+ 274
1094
+ 00:19:18,000 --> 00:19:21,000
1095
+ Now, it looks like we tested all possible cases.
1096
+
1097
+ 275
1098
+ 00:19:22,000 --> 00:19:23,000
1099
+ We learned a lot for today.
1100
+
1101
+ 276
1102
+ 00:19:23,000 --> 00:19:27,000
1103
+ Let's recap what we have learned today in this lesson.
1104
+
1105
+ 277
1106
+ 00:19:27,000 --> 00:19:31,000
1107
+ We learned where to find union documentation and how to use it.
1108
+
1109
+ 278
1110
+ 00:19:31,000 --> 00:19:37,000
1111
+ We learned annotations that will help us to set up an environment before each test and clean up environment
1112
+
1113
+ 279
1114
+ 00:19:37,000 --> 00:19:39,000
1115
+ after each test execution.
1116
+
1117
+ 280
1118
+ 00:19:39,000 --> 00:19:43,000
1119
+ During the lesson, we compared how to do the same things with Unit five.
1120
+
1121
+ 281
1122
+ 00:19:43,000 --> 00:19:48,000
1123
+ Indeed four, we learned test annotation and you understood how to create a test case.
1124
+
1125
+ 282
1126
+ 00:19:49,000 --> 00:19:53,000
1127
+ You learned what equivalence test partitioning and how to use this technique.
1128
+
1129
+ 283
1130
+ 00:19:53,000 --> 00:19:59,000
1131
+ And at the end of the lesson we learned how to test exceptions in and hope this lesson was interesting
1132
+
1133
+ 284
1134
+ 00:19:59,000 --> 00:20:00,000
1135
+ for you.
1136
+
1137
+ 285
1138
+ 00:20:00,000 --> 00:20:02,000
1139
+ Thanks a lot for your attention.
1140
+
1141
+ 286
1142
+ 00:20:02,000 --> 00:20:04,000
1143
+ Have a great day and see you in the next lesson.
1144
+
34 - Unit Testing & JUnit 5/002 JUnit-Documentation.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://junit.org/junit5/docs/current/api/
34 - Unit Testing & JUnit 5/002 Source-code-of-MoneyTransactionService.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/src/com/itbulls/learnit/javacore/junit5/MoneyTransactionService.java
34 - Unit Testing & JUnit 5/002 Source-code-of-MoneyTransactionServiceTest.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/MoneyTransactionServiceTest.java
34 - Unit Testing & JUnit 5/003 JUnit 5 API (Advanced) & Test Code Coverage_en.srt ADDED
@@ -0,0 +1,1128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:05,000 --> 00:00:11,000
3
+ Hello, dear students, in this lesson, we are going to proceed learning API will learn new annotations
4
+
5
+ 2
6
+ 00:00:11,000 --> 00:00:13,000
7
+ that will use to configure our tests.
8
+
9
+ 3
10
+ 00:00:13,000 --> 00:00:19,000
11
+ Yet I will show you on examples how the display name annotation helps us to make our test reports more
12
+
13
+ 4
14
+ 00:00:19,000 --> 00:00:20,000
15
+ readable.
16
+
17
+ 5
18
+ 00:00:20,000 --> 00:00:27,000
19
+ Also, we'll learn how to display name generation notation to help us improve our test report automatically
20
+
21
+ 6
22
+ 00:00:27,000 --> 00:00:28,000
23
+ during the class.
24
+
25
+ 7
26
+ 00:00:28,000 --> 00:00:32,000
27
+ And we'll talk about API that will help us to group assertions together.
28
+
29
+ 8
30
+ 00:00:32,000 --> 00:00:39,000
31
+ Besides that, you'll learn how to create dependent assertions in some cases in real life that in case
32
+
33
+ 9
34
+ 00:00:39,000 --> 00:00:46,000
35
+ requirements for test conditions are not met, there is no sense to verify other things and will learn
36
+
37
+ 10
38
+ 00:00:46,000 --> 00:00:47,000
39
+ how to configure this flow.
40
+
41
+ 11
42
+ 00:00:48,000 --> 00:00:53,000
43
+ Also, I will show you to the powerful mechanism of assumptions and how it works.
44
+
45
+ 12
46
+ 00:00:53,000 --> 00:00:58,000
47
+ After that, we'll dive deeper and will learn how to create parametrized tests.
48
+
49
+ 13
50
+ 00:00:58,000 --> 00:01:03,000
51
+ And at the end of the lesson, I will explain how we can measure test code coverage and what plugin
52
+
53
+ 14
54
+ 00:01:03,000 --> 00:01:04,000
55
+ will use for that.
56
+
57
+ 15
58
+ 00:01:05,000 --> 00:01:07,000
59
+ Sounds like we have a lot of things to do.
60
+
61
+ 16
62
+ 00:01:07,000 --> 00:01:08,000
63
+ Let's start.
64
+
65
+ 17
66
+ 00:01:08,000 --> 00:01:12,000
67
+ I really believe that it is better to learn this topic on examples.
68
+
69
+ 18
70
+ 00:01:12,000 --> 00:01:13,000
71
+ So let me open Eclipse.
72
+
73
+ 19
74
+ 00:01:14,000 --> 00:01:16,000
75
+ This is our test from the previous lesson.
76
+
77
+ 20
78
+ 00:01:17,000 --> 00:01:20,000
79
+ In case you missed first lesson, please get back and watch it.
80
+
81
+ 21
82
+ 00:01:21,000 --> 00:01:27,000
83
+ Meanwhile, will keep improving our tests here and assessing for visibility and for documentation.
84
+
85
+ 22
86
+ 00:01:27,000 --> 00:01:31,000
87
+ Your test properly we can use display name annotation.
88
+
89
+ 23
90
+ 00:01:31,000 --> 00:01:32,000
91
+ Let me show you this.
92
+
93
+ 24
94
+ 00:01:33,000 --> 00:01:37,000
95
+ You can apply this annotation to the class and specify clear name.
96
+
97
+ 25
98
+ 00:01:38,000 --> 00:01:41,000
99
+ Also, we can apply this notation for each specific test match.
100
+
101
+ 26
102
+ 00:01:41,000 --> 00:01:48,000
103
+ You can use any characters and even emoji if you wish, that also display name generators.
104
+
105
+ 27
106
+ 00:01:48,000 --> 00:01:50,000
107
+ You can use generators on the class level.
108
+
109
+ 28
110
+ 00:01:51,000 --> 00:01:55,000
111
+ For example, I use generators that substitutes underscores with spaces.
112
+
113
+ 29
114
+ 00:01:55,000 --> 00:02:02,000
115
+ As you can see, I use an annotation displaying the generation inside this annotation I use in a class
116
+
117
+ 30
118
+ 00:02:02,000 --> 00:02:10,000
119
+ of display name generator that is called replace underscores this auto display name generator can be
120
+
121
+ 31
122
+ 00:02:10,000 --> 00:02:16,000
123
+ helpful because on some project specific way of naming test methods can be used, namely sometimes in
124
+
125
+ 32
126
+ 00:02:16,000 --> 00:02:20,000
127
+ tests with name methods, with underscore to increase visibility.
128
+
129
+ 33
130
+ 00:02:20,000 --> 00:02:23,000
131
+ Let me run tests to show you the result.
132
+
133
+ 34
134
+ 00:02:24,000 --> 00:02:30,000
135
+ Here you can see the display name of our test class is changed, and inside you can see the display
136
+
137
+ 35
138
+ 00:02:30,000 --> 00:02:30,000
139
+ method.
140
+
141
+ 36
142
+ 00:02:30,000 --> 00:02:35,000
143
+ The first test is different and under scores are removed for the second test.
144
+
145
+ 37
146
+ 00:02:36,000 --> 00:02:41,000
147
+ Can you see now that readability is increased in comparison with other methods listed here?
148
+
149
+ 38
150
+ 00:02:42,000 --> 00:02:47,000
151
+ Instead of the display name generator, you can use other generators that are available here.
152
+
153
+ 39
154
+ 00:02:47,000 --> 00:02:50,000
155
+ Here is a list of other generators that you can use.
156
+
157
+ 40
158
+ 00:02:50,000 --> 00:02:51,000
159
+ Hope this is clear.
160
+
161
+ 41
162
+ 00:02:52,000 --> 00:02:52,000
163
+ Let's move on.
164
+
165
+ 42
166
+ 00:02:53,000 --> 00:03:00,000
167
+ Let's talk about assertions in unit where you saw how we wrote these tests in previous lesson.
168
+
169
+ 43
170
+ 00:03:00,000 --> 00:03:04,000
171
+ And you know that we have a lot of research and methods located in assertions class.
172
+
173
+ 44
174
+ 00:03:04,000 --> 00:03:09,000
175
+ All methods are static and usually we do static in parts of ascensions class.
176
+
177
+ 45
178
+ 00:03:09,000 --> 00:03:12,000
179
+ Let's look at assertions that we didn't talk about yet.
180
+
181
+ 46
182
+ 00:03:13,000 --> 00:03:16,000
183
+ I put all new examples at the bottom of this file.
184
+
185
+ 47
186
+ 00:03:16,000 --> 00:03:22,000
187
+ I will share with you link to the source code after the lesson so you could find these examples and
188
+
189
+ 48
190
+ 00:03:22,000 --> 00:03:23,000
191
+ investigate them separately.
192
+
193
+ 49
194
+ 00:03:24,000 --> 00:03:30,000
195
+ For example, you can group your assertions sometimes that is logical and more visible.
196
+
197
+ 50
198
+ 00:03:30,000 --> 00:03:36,000
199
+ I believe you remember our first test when we verify transaction here is a similar test.
200
+
201
+ 51
202
+ 00:03:36,000 --> 00:03:42,000
203
+ But in the last part I use a search all Masset to group my two assertions.
204
+
205
+ 52
206
+ 00:03:42,000 --> 00:03:49,000
207
+ This massive takes head that you will see in case one of the assertions will fail and you pass verbal
208
+
209
+ 53
210
+ 00:03:49,000 --> 00:03:51,000
211
+ Lancs argument of type executable.
212
+
213
+ 54
214
+ 00:03:52,000 --> 00:03:58,000
215
+ Usually object of this type is described with the help of the expression and you can see that in lambda
216
+
217
+ 55
218
+ 00:03:58,000 --> 00:03:58,000
219
+ function.
220
+
221
+ 56
222
+ 00:03:58,000 --> 00:04:03,000
223
+ I execute my own assertions in case one of these will be failed.
224
+
225
+ 57
226
+ 00:04:03,000 --> 00:04:08,000
227
+ In report you will see that group of assertions with this header is failed.
228
+
229
+ 58
230
+ 00:04:08,000 --> 00:04:10,000
231
+ Hope this is clearer with this example.
232
+
233
+ 59
234
+ 00:04:11,000 --> 00:04:16,000
235
+ In the next example, I am going to show you how you can write dependent assertions.
236
+
237
+ 60
238
+ 00:04:16,000 --> 00:04:18,000
239
+ Hammerson is easy here.
240
+
241
+ 61
242
+ 00:04:18,000 --> 00:04:22,000
243
+ We can use nested assertions qaisi example.
244
+
245
+ 62
246
+ 00:04:22,000 --> 00:04:31,000
247
+ We test the same money transaction I write asserts all and inside I have Asatru this assertion will
248
+
249
+ 63
250
+ 00:04:31,000 --> 00:04:33,000
251
+ check the transfer money returned.
252
+
253
+ 64
254
+ 00:04:33,000 --> 00:04:40,000
255
+ True, that would mean the transaction was successful and only after that I will check that amount of
256
+
257
+ 65
258
+ 00:04:40,000 --> 00:04:47,000
259
+ money exchanged for account one and the account to and in a all method will be executed only in case.
260
+
261
+ 66
262
+ 00:04:47,000 --> 00:04:52,000
263
+ First assertion that the seller Asatru method will pass.
264
+
265
+ 67
266
+ 00:04:52,000 --> 00:04:53,000
267
+ Does it make sense.
268
+
269
+ 68
270
+ 00:04:54,000 --> 00:04:54,000
271
+ Great.
272
+
273
+ 69
274
+ 00:04:55,000 --> 00:04:55,000
275
+ Let's continue.
276
+
277
+ 70
278
+ 00:04:56,000 --> 00:05:03,000
279
+ The next assertion will help us to be sure the time spent on execution of our method does not exceed
280
+
281
+ 71
282
+ 00:05:03,000 --> 00:05:05,000
283
+ specified by US amount of time.
284
+
285
+ 72
286
+ 00:05:05,000 --> 00:05:06,000
287
+ This is needed in the case.
288
+
289
+ 73
290
+ 00:05:06,000 --> 00:05:13,000
291
+ We want to be sure that, for example, some complex method with a lot of logic inside that it doesn't
292
+
293
+ 74
294
+ 00:05:13,000 --> 00:05:15,000
295
+ take more than one second to execute.
296
+
297
+ 75
298
+ 00:05:15,000 --> 00:05:18,000
299
+ In our particular case, I want to test transfer money.
300
+
301
+ 76
302
+ 00:05:18,000 --> 00:05:21,000
303
+ MassArt does not take more than one second to execute.
304
+
305
+ 77
306
+ 00:05:22,000 --> 00:05:26,000
307
+ I use a certain amount method and pass to arguments to it.
308
+
309
+ 78
310
+ 00:05:26,000 --> 00:05:29,000
311
+ The first argument is a duration object.
312
+
313
+ 79
314
+ 00:05:29,000 --> 00:05:33,000
315
+ In a separate lesson, we learn with the tools for time management in JDK.
316
+
317
+ 80
318
+ 00:05:33,000 --> 00:05:36,000
319
+ Right now you can just use duration class.
320
+
321
+ 81
322
+ 00:05:36,000 --> 00:05:39,000
323
+ Don't forget to make an impact from Java Time package.
324
+
325
+ 82
326
+ 00:05:39,000 --> 00:05:41,000
327
+ In case you use Eclipse.
328
+
329
+ 83
330
+ 00:05:41,000 --> 00:05:45,000
331
+ It will help you with other suggestion and will improve this class instead of you.
332
+
333
+ 84
334
+ 00:05:46,000 --> 00:05:53,000
335
+ You can use static methods, for example, of seconds to get duration in seconds of minutes to get duration
336
+
337
+ 85
338
+ 00:05:53,000 --> 00:05:55,000
339
+ in milliseconds and so on.
340
+
341
+ 86
342
+ 00:05:56,000 --> 00:06:03,000
343
+ I use of seconds method and the second argument similar to our previous examples, I pass lambda function
344
+
345
+ 87
346
+ 00:06:03,000 --> 00:06:10,000
347
+ and execute my method and sided test will pass in case this method execution took less than one second
348
+
349
+ 88
350
+ 00:06:10,000 --> 00:06:14,000
351
+ and it will fail in case method execution took longer.
352
+
353
+ 89
354
+ 00:06:14,000 --> 00:06:21,000
355
+ Talking about timeouts, it is also worth to mention that a certain mouth method returns the result.
356
+
357
+ 90
358
+ 00:06:21,000 --> 00:06:27,000
359
+ For example, in this case a certain amount will return the result of my transfer money method.
360
+
361
+ 91
362
+ 00:06:28,000 --> 00:06:31,000
363
+ That means that I am able to test time out of method.
364
+
365
+ 92
366
+ 00:06:31,000 --> 00:06:35,000
367
+ The execution and the actual result I test.
368
+
369
+ 93
370
+ 00:06:35,000 --> 00:06:38,000
371
+ The transaction was successful in a certain method.
372
+
373
+ 94
374
+ 00:06:39,000 --> 00:06:42,000
375
+ Also, there is another way to check them out.
376
+
377
+ 95
378
+ 00:06:42,000 --> 00:06:49,000
379
+ We can use annotation timeout right above the test method by default time use it and said the annotation
380
+
381
+ 96
382
+ 00:06:49,000 --> 00:06:51,000
383
+ is seconds, but it is configurable.
384
+
385
+ 97
386
+ 00:06:51,000 --> 00:06:57,000
387
+ And you can see in this command line how you can configure time unit for this annotation.
388
+
389
+ 98
390
+ 00:06:57,000 --> 00:07:00,000
391
+ Just your second argument as time unit.
392
+
393
+ 99
394
+ 00:07:00,000 --> 00:07:01,000
395
+ Does it make sense?
396
+
397
+ 100
398
+ 00:07:02,000 --> 00:07:02,000
399
+ Great.
400
+
401
+ 101
402
+ 00:07:03,000 --> 00:07:08,000
403
+ You already learned a lot of tools that will help you in daily activities while writing unit tests.
404
+
405
+ 102
406
+ 00:07:09,000 --> 00:07:15,000
407
+ Now I want to tell you about very interesting to injure Unit I talking about mechanism of assumptions.
408
+
409
+ 103
410
+ 00:07:15,000 --> 00:07:22,000
411
+ Imagine that you wrote a unit test, but you want to vividly specify what is a valid input for this
412
+
413
+ 104
414
+ 00:07:22,000 --> 00:07:23,000
415
+ test in case in.
416
+
417
+ 105
418
+ 00:07:24,000 --> 00:07:26,000
419
+ This message was invalid with this death.
420
+
421
+ 106
422
+ 00:07:27,000 --> 00:07:31,000
423
+ Don't worry, I will show you an example now and everything will become clear.
424
+
425
+ 107
426
+ 00:07:32,000 --> 00:07:38,000
427
+ Imagine that I wrote a test that should be run only on local development environment and another test
428
+
429
+ 108
430
+ 00:07:38,000 --> 00:07:41,000
431
+ that should be run on quality assurance environment.
432
+
433
+ 109
434
+ 00:07:42,000 --> 00:07:44,000
435
+ These environments use different configurations.
436
+
437
+ 110
438
+ 00:07:45,000 --> 00:07:48,000
439
+ While this is not a good practice, it is very common sense.
440
+
441
+ 111
442
+ 00:07:49,000 --> 00:07:55,000
443
+ And you want that one specific test would run only on local computers and another test would be run
444
+
445
+ 112
446
+ 00:07:55,000 --> 00:07:56,000
447
+ on a server.
448
+
449
+ 113
450
+ 00:07:56,000 --> 00:07:57,000
451
+ How to do that?
452
+
453
+ 114
454
+ 00:07:57,000 --> 00:08:01,000
455
+ We can assume some statement before running tests.
456
+
457
+ 115
458
+ 00:08:01,000 --> 00:08:05,000
459
+ For example, this test will be executed only on my laptop.
460
+
461
+ 116
462
+ 00:08:06,000 --> 00:08:12,000
463
+ I write assume true at the beginning and pass statements that should return true or false in history
464
+
465
+ 117
466
+ 00:08:12,000 --> 00:08:14,000
467
+ will be returned to you.
468
+
469
+ 118
470
+ 00:08:14,000 --> 00:08:18,000
471
+ It will proceed with the test execution and his statement will be false.
472
+
473
+ 119
474
+ 00:08:19,000 --> 00:08:23,000
475
+ You will just keep this test and will print the string message in the report.
476
+
477
+ 120
478
+ 00:08:24,000 --> 00:08:28,000
479
+ I said environment variable on my computer that is called is an Ripperton laptop.
480
+
481
+ 121
482
+ 00:08:29,000 --> 00:08:30,000
483
+ It has true value.
484
+
485
+ 122
486
+ 00:08:30,000 --> 00:08:36,000
487
+ In case I will change the statement a bit, I will get false and this test will be skipped.
488
+
489
+ 123
490
+ 00:08:36,000 --> 00:08:42,000
491
+ Let me run now all tests to show you how this look like and hand test reports.
492
+
493
+ 124
494
+ 00:08:42,000 --> 00:08:47,000
495
+ You can see how much tests were run and the number of tests in parentheses.
496
+
497
+ 125
498
+ 00:08:48,000 --> 00:08:51,000
499
+ Let's expand the report and check which test was kept.
500
+
501
+ 126
502
+ 00:08:52,000 --> 00:08:58,000
503
+ And here you can see the test on Batalha Workstation is escaped because assumption is failed.
504
+
505
+ 127
506
+ 00:08:59,000 --> 00:09:06,000
507
+ So what is the difference between assertion and assumption, you assert is used to test scenarios for
508
+
509
+ 128
510
+ 00:09:06,000 --> 00:09:12,000
511
+ our test methods, whereas ASSUME is used to validate favorable conditions for our tests.
512
+
513
+ 129
514
+ 00:09:13,000 --> 00:09:17,000
515
+ Here's how you can configure was a test should be executed or skipped.
516
+
517
+ 130
518
+ 00:09:18,000 --> 00:09:21,000
519
+ Now I want to show you another key feature of the unit.
520
+
521
+ 131
522
+ 00:09:21,000 --> 00:09:23,000
523
+ I am talking about parametrized test.
524
+
525
+ 132
526
+ 00:09:24,000 --> 00:09:29,000
527
+ Imagine that you have one test and you want to run it multiple times with different values.
528
+
529
+ 133
530
+ 00:09:29,000 --> 00:09:31,000
531
+ You don't have to write different tests.
532
+
533
+ 134
534
+ 00:09:31,000 --> 00:09:35,000
535
+ You can just specify that this test will have different inputs.
536
+
537
+ 135
538
+ 00:09:35,000 --> 00:09:36,000
539
+ How to do this?
540
+
541
+ 136
542
+ 00:09:36,000 --> 00:09:37,000
543
+ Let me show you.
544
+
545
+ 137
546
+ 00:09:38,000 --> 00:09:44,000
547
+ First of all, we have to write parametrized, test annotation instead of our regular test annotation.
548
+
549
+ 138
550
+ 00:09:44,000 --> 00:09:50,000
551
+ The second thing we have to do is to write value source annotation in parentheses.
552
+
553
+ 139
554
+ 00:09:50,000 --> 00:09:57,000
555
+ Next to this annotation, we can specify arrays of different types, namely moulins, bytes, chars
556
+
557
+ 140
558
+ 00:09:57,000 --> 00:10:02,000
559
+ classes, double slots in long shorts and strings.
560
+
561
+ 141
562
+ 00:10:02,000 --> 00:10:07,000
563
+ Even in case you would forget this, you just use auto suggestion to work.
564
+
565
+ 142
566
+ 00:10:07,000 --> 00:10:07,000
567
+ I do.
568
+
569
+ 143
570
+ 00:10:08,000 --> 00:10:11,000
571
+ You can press control and space simultaneously to see.
572
+
573
+ 144
574
+ 00:10:11,000 --> 00:10:19,000
575
+ Hence, in my particular example, I need INTs and next to end I specify array of in braces.
576
+
577
+ 145
578
+ 00:10:19,000 --> 00:10:24,000
579
+ The third thing we have to do is to declare method parameter in our test.
580
+
581
+ 146
582
+ 00:10:24,000 --> 00:10:29,000
583
+ This time should be compatible with the one we specified in the values source annotation.
584
+
585
+ 147
586
+ 00:10:30,000 --> 00:10:38,000
587
+ I declare parameter of type end and now this test will be executed four times y four because I have
588
+
589
+ 148
590
+ 00:10:38,000 --> 00:10:40,000
591
+ four inputs to be specific.
592
+
593
+ 149
594
+ 00:10:40,000 --> 00:10:47,000
595
+ In this case, test will be executed four times, but the fourth attempt will be skipped because I have
596
+
597
+ 150
598
+ 00:10:47,000 --> 00:10:51,000
599
+ assumption here that money amounts should be strictly more than zero.
600
+
601
+ 151
602
+ 00:10:51,000 --> 00:10:54,000
603
+ Let me run this test and show you to report.
604
+
605
+ 152
606
+ 00:10:55,000 --> 00:11:00,000
607
+ And here you must see that our parametrized test was executed four times with different arguments.
608
+
609
+ 153
610
+ 00:11:01,000 --> 00:11:07,000
611
+ And you also can see that force execution of test with minus Tanavoli was skipped because of assumption
612
+
613
+ 154
614
+ 00:11:07,000 --> 00:11:08,000
615
+ failed.
616
+
617
+ 155
618
+ 00:11:08,000 --> 00:11:09,000
619
+ Is that clear?
620
+
621
+ 156
622
+ 00:11:10,000 --> 00:11:14,000
623
+ To parameterize your test, you can use such annotations.
624
+
625
+ 157
626
+ 00:11:14,000 --> 00:11:16,000
627
+ S no source your source?
628
+
629
+ 158
630
+ 00:11:17,000 --> 00:11:18,000
631
+ No an empty source.
632
+
633
+ 159
634
+ 00:11:19,000 --> 00:11:22,000
635
+ You can use these annotations with parametrized tests.
636
+
637
+ 160
638
+ 00:11:22,000 --> 00:11:25,000
639
+ I believe that all these annotations are self-described.
640
+
641
+ 161
642
+ 00:11:26,000 --> 00:11:32,000
643
+ No source will just add no value to array of input values and your source will pass empty argument for
644
+
645
+ 162
646
+ 00:11:32,000 --> 00:11:41,000
647
+ parameters of the following types like Screenplay's said map, primitive arrays into HRB, etc..
648
+
649
+ 163
650
+ 00:11:41,000 --> 00:11:43,000
651
+ Object arrays and integer arrays.
652
+
653
+ 164
654
+ 00:11:43,000 --> 00:11:48,000
655
+ Whatever new and empty source is a combination of first two annotations.
656
+
657
+ 165
658
+ 00:11:49,000 --> 00:11:55,000
659
+ In case you would run this test, you would see that it will be executed two times with no an empty
660
+
661
+ 166
662
+ 00:11:55,000 --> 00:11:56,000
663
+ string argument.
664
+
665
+ 167
666
+ 00:11:56,000 --> 00:12:01,000
667
+ And as a annotation for test, parameterization is a method source annotation.
668
+
669
+ 168
670
+ 00:12:01,000 --> 00:12:04,000
671
+ You can mark any static method with this annotation.
672
+
673
+ 169
674
+ 00:12:04,000 --> 00:12:10,000
675
+ This is so-called factory method that generates stream of arguments that will be submitted to the parametrized
676
+
677
+ 170
678
+ 00:12:10,000 --> 00:12:11,000
679
+ method.
680
+
681
+ 171
682
+ 00:12:11,000 --> 00:12:13,000
683
+ Let me show you this on the example.
684
+
685
+ 172
686
+ 00:12:13,000 --> 00:12:19,000
687
+ I have parametrized test that is marked with method source annotation and name of the method that should
688
+
689
+ 173
690
+ 00:12:19,000 --> 00:12:23,000
691
+ be used to generate test inputs and use my static.
692
+
693
+ 174
694
+ 00:12:23,000 --> 00:12:29,000
695
+ Method that is used to generate inputs, it returns stream type, but actually it can return any type
696
+
697
+ 175
698
+ 00:12:29,000 --> 00:12:31,000
699
+ that can be converted to a string.
700
+
701
+ 176
702
+ 00:12:32,000 --> 00:12:37,000
703
+ For example, collection iterator, a terrible extreme double stream and long stream.
704
+
705
+ 177
706
+ 00:12:37,000 --> 00:12:44,000
707
+ And when I run test method source, it is executed three times because it generates three with three
708
+
709
+ 178
710
+ 00:12:44,000 --> 00:12:44,000
711
+ values.
712
+
713
+ 179
714
+ 00:12:44,000 --> 00:12:45,000
715
+ Does it make sense?
716
+
717
+ 180
718
+ 00:12:46,000 --> 00:12:52,000
719
+ There's also a possibility to specify multiple data inputs by using Azziz resource annotation.
720
+
721
+ 181
722
+ 00:12:52,000 --> 00:12:56,000
723
+ We use comma separated values to parse all arguments.
724
+
725
+ 182
726
+ 00:12:56,000 --> 00:12:57,000
727
+ It is pretty intuitive.
728
+
729
+ 183
730
+ 00:12:57,000 --> 00:12:59,000
731
+ If you would look at this example.
732
+
733
+ 184
734
+ 00:12:59,000 --> 00:13:02,000
735
+ To be honest, I don't use parametrized test.
736
+
737
+ 185
738
+ 00:13:03,000 --> 00:13:05,000
739
+ Why do you remember that?
740
+
741
+ 186
742
+ 00:13:05,000 --> 00:13:08,000
743
+ In previous lesson I explained you what equivalence class is?
744
+
745
+ 187
746
+ 00:13:09,000 --> 00:13:10,000
747
+ That is the answer.
748
+
749
+ 188
750
+ 00:13:10,000 --> 00:13:17,000
751
+ I don't need parametrized test because I write test for only one value for a specific equivalence class
752
+
753
+ 189
754
+ 00:13:17,000 --> 00:13:19,000
755
+ that is also works just fine.
756
+
757
+ 190
758
+ 00:13:19,000 --> 00:13:22,000
759
+ But you can use parametrized test if you wish.
760
+
761
+ 191
762
+ 00:13:22,000 --> 00:13:25,000
763
+ At least you should be aware about this feature.
764
+
765
+ 192
766
+ 00:13:25,000 --> 00:13:32,000
767
+ Now imagine that you found some defect and this test is failing and take into account that usually development
768
+
769
+ 193
770
+ 00:13:32,000 --> 00:13:33,000
771
+ is performed in teams.
772
+
773
+ 194
774
+ 00:13:33,000 --> 00:13:37,000
775
+ This test also failed on other computers to not book anyone else.
776
+
777
+ 195
778
+ 00:13:37,000 --> 00:13:41,000
779
+ You just disable some unit test until it will be fixed.
780
+
781
+ 196
782
+ 00:13:41,000 --> 00:13:44,000
783
+ Hope you can easily imagine this case now.
784
+
785
+ 197
786
+ 00:13:44,000 --> 00:13:48,000
787
+ How to disable test into a unit into unit four.
788
+
789
+ 198
790
+ 00:13:48,000 --> 00:13:51,000
791
+ We used to ignore annotation in unit five.
792
+
793
+ 199
794
+ 00:13:51,000 --> 00:13:53,000
795
+ We use disabled annotation.
796
+
797
+ 200
798
+ 00:13:53,000 --> 00:13:57,000
799
+ You can just keep this annotation if you wish, or you can add description.
800
+
801
+ 201
802
+ 00:13:57,000 --> 00:14:04,000
803
+ Why exactly this test is disabled and when you run all tests, this one just won't be executed.
804
+
805
+ 202
806
+ 00:14:05,000 --> 00:14:06,000
807
+ Great.
808
+
809
+ 203
810
+ 00:14:06,000 --> 00:14:08,000
811
+ We have one more quick topic to cover.
812
+
813
+ 204
814
+ 00:14:08,000 --> 00:14:10,000
815
+ That is test code coverage.
816
+
817
+ 205
818
+ 00:14:10,000 --> 00:14:11,000
819
+ What is this?
820
+
821
+ 206
822
+ 00:14:11,000 --> 00:14:17,000
823
+ This is a Madgwick some specific values that shows in percentage how much lines of your code was covered
824
+
825
+ 207
826
+ 00:14:17,000 --> 00:14:18,000
827
+ with tests.
828
+
829
+ 208
830
+ 00:14:18,000 --> 00:14:21,000
831
+ This is important for us because of your reasons.
832
+
833
+ 209
834
+ 00:14:22,000 --> 00:14:27,000
835
+ We want to be sure that all codes that we wrote is covered with tests in case we have codes that is
836
+
837
+ 210
838
+ 00:14:27,000 --> 00:14:29,000
839
+ not covered with tests.
840
+
841
+ 211
842
+ 00:14:29,000 --> 00:14:31,000
843
+ That means we don't need this code at all.
844
+
845
+ 212
846
+ 00:14:32,000 --> 00:14:38,000
847
+ Sometimes we want to provide the metrics for important purposes that our job was done with expected
848
+
849
+ 213
850
+ 00:14:38,000 --> 00:14:39,000
851
+ quality level.
852
+
853
+ 214
854
+ 00:14:39,000 --> 00:14:44,000
855
+ And sometimes you might be asked to keep the percentage of test code coverage on the specific level.
856
+
857
+ 215
858
+ 00:14:45,000 --> 00:14:51,000
859
+ How this code coverage works, that's code coverage shows how much lines and blocks were invoked from
860
+
861
+ 216
862
+ 00:14:51,000 --> 00:14:52,000
863
+ your tests.
864
+
865
+ 217
866
+ 00:14:52,000 --> 00:14:59,000
867
+ In other words, specific plug and measure how much lines of code were executed when your test is run.
868
+
869
+ 218
870
+ 00:15:00,000 --> 00:15:01,000
871
+ That's why that's got coverage.
872
+
873
+ 219
874
+ 00:15:01,000 --> 00:15:06,000
875
+ Not necessarily means that your test really verifies things and logic.
876
+
877
+ 220
878
+ 00:15:06,000 --> 00:15:13,000
879
+ You can just invoke some method from your test or simulate any other conditions to execute other parts
880
+
881
+ 221
882
+ 00:15:13,000 --> 00:15:14,000
883
+ of, if else, statement.
884
+
885
+ 222
886
+ 00:15:14,000 --> 00:15:15,000
887
+ And that's it.
888
+
889
+ 223
890
+ 00:15:16,000 --> 00:15:19,000
891
+ Such metric as test coverage will be increased.
892
+
893
+ 224
894
+ 00:15:19,000 --> 00:15:26,000
895
+ To help you understand how tasket coverage works, let me show you this on example from the code editor
896
+
897
+ 225
898
+ 00:15:26,000 --> 00:15:27,000
899
+ Error Mouse.
900
+
901
+ 226
902
+ 00:15:27,000 --> 00:15:30,000
903
+ Right click coverage as a test.
904
+
905
+ 227
906
+ 00:15:30,000 --> 00:15:37,000
907
+ In case you don't have such option, make sure that you have a grammar plugin installed and clips for
908
+
909
+ 228
910
+ 00:15:37,000 --> 00:15:42,000
911
+ Java developers is distributed with this plugin installed by default.
912
+
913
+ 229
914
+ 00:15:42,000 --> 00:15:45,000
915
+ Button Kizzire clips version doesn't have such plugin.
916
+
917
+ 230
918
+ 00:15:46,000 --> 00:15:47,000
919
+ You can install it manually.
920
+
921
+ 231
922
+ 00:15:48,000 --> 00:15:49,000
923
+ Just click help then.
924
+
925
+ 232
926
+ 00:15:49,000 --> 00:15:57,000
927
+ Select Eclipse Market Place after Eclipse Marketplace is loaded use search bar to find a clammer.
928
+
929
+ 233
930
+ 00:15:57,000 --> 00:16:01,000
931
+ A Clela is a plugin that can calculate Trescott coverage.
932
+
933
+ 234
934
+ 00:16:01,000 --> 00:16:06,000
935
+ Inside the clips it is shown that it is already installed for me.
936
+
937
+ 235
938
+ 00:16:06,000 --> 00:16:11,000
939
+ I click cancel and now I want to execute my test and check descant coverage.
940
+
941
+ 236
942
+ 00:16:12,000 --> 00:16:16,000
943
+ After test is executed, I can find Trescott coverage report.
944
+
945
+ 237
946
+ 00:16:17,000 --> 00:16:22,000
947
+ It says that this test covers only such specific parts of all lines in my project.
948
+
949
+ 238
950
+ 00:16:22,000 --> 00:16:25,000
951
+ Let me expand folders from this report.
952
+
953
+ 239
954
+ 00:16:25,000 --> 00:16:28,000
955
+ You can source all items here by coverage rate.
956
+
957
+ 240
958
+ 00:16:29,000 --> 00:16:35,000
959
+ As you can see, my unit test covered on one hundred percent, my money transaction service and account
960
+
961
+ 241
962
+ 00:16:35,000 --> 00:16:35,000
963
+ class.
964
+
965
+ 242
966
+ 00:16:36,000 --> 00:16:37,000
967
+ That is awesome.
968
+
969
+ 243
970
+ 00:16:37,000 --> 00:16:43,000
971
+ You can open each specific class now to see lines and green that are covered with your test.
972
+
973
+ 244
974
+ 00:16:43,000 --> 00:16:49,000
975
+ Let me open my transaction service and you can see that all lines and blocks are covered with tests.
976
+
977
+ 245
978
+ 00:16:50,000 --> 00:16:51,000
979
+ How to reset this?
980
+
981
+ 246
982
+ 00:16:52,000 --> 00:16:58,000
983
+ Just find this cross sign in coverage report to reset all reports and color selection in your source
984
+
985
+ 247
986
+ 00:16:58,000 --> 00:16:58,000
987
+ code.
988
+
989
+ 248
990
+ 00:16:59,000 --> 00:17:00,000
991
+ What are the other statuses?
992
+
993
+ 249
994
+ 00:17:00,000 --> 00:17:06,000
995
+ Could be you'll find your lines in red in case they were not covered by your test and you will find
996
+
997
+ 250
998
+ 00:17:06,000 --> 00:17:10,000
999
+ yellow lines in case not all branches of execution are covered with tests.
1000
+
1001
+ 251
1002
+ 00:17:11,000 --> 00:17:12,000
1003
+ Then we use these cases.
1004
+
1005
+ 252
1006
+ 00:17:12,000 --> 00:17:13,000
1007
+ I created separate class.
1008
+
1009
+ 253
1010
+ 00:17:14,000 --> 00:17:18,000
1011
+ It is called Trescott Coverage Damos and it is placed into unit folder.
1012
+
1013
+ 254
1014
+ 00:17:19,000 --> 00:17:22,000
1015
+ It is really simple class created only for the sake of the example.
1016
+
1017
+ 255
1018
+ 00:17:23,000 --> 00:17:30,000
1019
+ The matsutake swink argument it has, if else block first if statement contains expressions, that includes
1020
+
1021
+ 256
1022
+ 00:17:30,000 --> 00:17:31,000
1023
+ or operator.
1024
+
1025
+ 257
1026
+ 00:17:31,000 --> 00:17:38,000
1027
+ Let me show you the test now I have one single test and WOAK test code coverage method and personal
1028
+
1029
+ 258
1030
+ 00:17:38,000 --> 00:17:39,000
1031
+ values there.
1032
+
1033
+ 259
1034
+ 00:17:40,000 --> 00:17:45,000
1035
+ Now let me check this code coverage and run my tests when tests are executed.
1036
+
1037
+ 260
1038
+ 00:17:45,000 --> 00:17:47,000
1039
+ Let me open the source code of our class.
1040
+
1041
+ 261
1042
+ 00:17:48,000 --> 00:17:55,000
1043
+ You can see that each statement is yellow y because not all branches of execution are covered with tests.
1044
+
1045
+ 262
1046
+ 00:17:56,000 --> 00:18:02,000
1047
+ We have two possible options here in case my strong argument is now, I will print this test to council.
1048
+
1049
+ 263
1050
+ 00:18:03,000 --> 00:18:09,000
1051
+ And the second branch of execution is in case the string argument is not now, but it is empty string
1052
+
1053
+ 264
1054
+ 00:18:09,000 --> 00:18:09,000
1055
+ object.
1056
+
1057
+ 265
1058
+ 00:18:10,000 --> 00:18:13,000
1059
+ So that means I have to write one more test.
1060
+
1061
+ 266
1062
+ 00:18:13,000 --> 00:18:18,000
1063
+ Westwick argument won't be now is red line in in block.
1064
+
1065
+ 267
1066
+ 00:18:18,000 --> 00:18:21,000
1067
+ That is because it is not covered with test.
1068
+
1069
+ 268
1070
+ 00:18:21,000 --> 00:18:26,000
1071
+ So you can see that my unit is covered with tests on sixty two and a half percentages.
1072
+
1073
+ 269
1074
+ 00:18:27,000 --> 00:18:30,000
1075
+ But notice I even didn't test anything.
1076
+
1077
+ 270
1078
+ 00:18:30,000 --> 00:18:37,000
1079
+ There is no assertion at all in my unit test, but I already increased Ascott coverage metric set as
1080
+
1081
+ 271
1082
+ 00:18:37,000 --> 00:18:41,000
1083
+ the trigger that you should know about this cost coverage calculation to never use it.
1084
+
1085
+ 272
1086
+ 00:18:42,000 --> 00:18:43,000
1087
+ We learned a lot today.
1088
+
1089
+ 273
1090
+ 00:18:43,000 --> 00:18:46,000
1091
+ Let's recap what we have learned today.
1092
+
1093
+ 274
1094
+ 00:18:47,000 --> 00:18:48,000
1095
+ We learned new annotations.
1096
+
1097
+ 275
1098
+ 00:18:49,000 --> 00:18:55,000
1099
+ You also learned how to group assertions and how to build dependency between assertions and real examples.
1100
+
1101
+ 276
1102
+ 00:18:55,000 --> 00:19:00,000
1103
+ You saw how to create unique tests that can be failed because of time out.
1104
+
1105
+ 277
1106
+ 00:19:00,000 --> 00:19:03,000
1107
+ We learned how to use assumptions in the unit.
1108
+
1109
+ 278
1110
+ 00:19:03,000 --> 00:19:10,000
1111
+ I explained you different ways to parameterize your test methods to repeat test with different inputs.
1112
+
1113
+ 279
1114
+ 00:19:10,000 --> 00:19:14,000
1115
+ And at the end of the lesson we learned how to check Descant coverage.
1116
+
1117
+ 280
1118
+ 00:19:14,000 --> 00:19:16,000
1119
+ Hope you enjoyed the lesson.
1120
+
1121
+ 281
1122
+ 00:19:16,000 --> 00:19:18,000
1123
+ Thanks a lot for your attention.
1124
+
1125
+ 282
1126
+ 00:19:18,000 --> 00:19:20,000
1127
+ See you in the next lesson.
1128
+
34 - Unit Testing & JUnit 5/003 Source-code-of-test-1.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/MoneyTransactionServiceTest2.java
34 - Unit Testing & JUnit 5/003 Source-code-of-test-2.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/TestCodeCoverageDemoTest.java
34 - Unit Testing & JUnit 5/004 JUnit 5 API (Advanced p. 2) & Hamcrest Library_en.srt ADDED
@@ -0,0 +1,1124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:05,000 --> 00:00:06,000
3
+ Hello, Jim.
4
+
5
+ 2
6
+ 00:00:06,000 --> 00:00:12,000
7
+ In this lesson, we keep learning Janet API and advanced features, we'll start our lesson from learning
8
+
9
+ 3
10
+ 00:00:12,000 --> 00:00:16,000
11
+ what suit is and how to create our own tasseled.
12
+
13
+ 4
14
+ 00:00:16,000 --> 00:00:20,000
15
+ After that, I will explain to you what tagine is and how to take your tests.
16
+
17
+ 5
18
+ 00:00:21,000 --> 00:00:22,000
19
+ During the lesson.
20
+
21
+ 6
22
+ 00:00:22,000 --> 00:00:26,000
23
+ I'll show you a lot of examples that will help you to understand this topic better.
24
+
25
+ 7
26
+ 00:00:26,000 --> 00:00:30,000
27
+ You will learn how to configure order of tests execution.
28
+
29
+ 8
30
+ 00:00:31,000 --> 00:00:33,000
31
+ Besides that, I am going to show you a really cool feature.
32
+
33
+ 9
34
+ 00:00:34,000 --> 00:00:36,000
35
+ It is conditional test execution.
36
+
37
+ 10
38
+ 00:00:36,000 --> 00:00:42,000
39
+ You are going to learn how to set specific conditions to enable or disable your test programmatically.
40
+
41
+ 11
42
+ 00:00:43,000 --> 00:00:48,000
43
+ Also, I will explain you how to create repeat a test that will be executed specified number of times.
44
+
45
+ 12
46
+ 00:00:48,000 --> 00:00:54,000
47
+ I will explain you how temporary directory extension works and why we might need it.
48
+
49
+ 13
50
+ 00:00:54,000 --> 00:01:00,000
51
+ I believe you already know how to use the unit assertions, but today I will also show you how to use
52
+
53
+ 14
54
+ 00:01:00,000 --> 00:01:03,000
55
+ Honeycrisp Library to increase readability of your tests.
56
+
57
+ 15
58
+ 00:01:03,000 --> 00:01:08,000
59
+ And at the end of the lesson, we are going to use the most common and typical mistakes.
60
+
61
+ 16
62
+ 00:01:08,000 --> 00:01:12,000
63
+ Hopefully review and mistakes will help you to not repeat those.
64
+
65
+ 17
66
+ 00:01:12,000 --> 00:01:17,000
67
+ I believe that the best way to learn this topic is to learn API with examples.
68
+
69
+ 18
70
+ 00:01:17,000 --> 00:01:19,000
71
+ So let me open the clips.
72
+
73
+ 19
74
+ 00:01:19,000 --> 00:01:25,000
75
+ Imagines a case that you wrote specifics of unit tests that are related to specific feature.
76
+
77
+ 20
78
+ 00:01:25,000 --> 00:01:31,000
79
+ For example, all units are related to registration feature and while working on this feature, you
80
+
81
+ 21
82
+ 00:01:31,000 --> 00:01:34,000
83
+ don't want to run all possible unit tests.
84
+
85
+ 22
86
+ 00:01:34,000 --> 00:01:39,000
87
+ You want to run only those tests that are related to registration feature.
88
+
89
+ 23
90
+ 00:01:39,000 --> 00:01:44,000
91
+ There are so-called test kits to help you to run group of tests with one click.
92
+
93
+ 24
94
+ 00:01:44,000 --> 00:01:46,000
95
+ Let me show you how to create test.
96
+
97
+ 25
98
+ 00:01:47,000 --> 00:01:50,000
99
+ The first thing you have to do is to specific run class.
100
+
101
+ 26
102
+ 00:01:51,000 --> 00:01:52,000
103
+ What is Irana?
104
+
105
+ 27
106
+ 00:01:52,000 --> 00:01:56,000
107
+ This is a class that is responsible for running unit tests.
108
+
109
+ 28
110
+ 00:01:56,000 --> 00:02:01,000
111
+ There is a default unit run when we don't specify any specific granite class.
112
+
113
+ 29
114
+ 00:02:01,000 --> 00:02:07,000
115
+ In this particular case, we have to specify and also run a class that is called the unit platform.
116
+
117
+ 30
118
+ 00:02:08,000 --> 00:02:14,000
119
+ This class will check all configurations related with running group of tests, our tests.
120
+
121
+ 31
122
+ 00:02:15,000 --> 00:02:20,000
123
+ The next thing we have to do is to add one of the notations that will help us to run group of tests.
124
+
125
+ 32
126
+ 00:02:21,000 --> 00:02:24,000
127
+ It could be select packages, annotation from its name.
128
+
129
+ 33
130
+ 00:02:24,000 --> 00:02:26,000
131
+ I believe that is clear.
132
+
133
+ 34
134
+ 00:02:26,000 --> 00:02:29,000
135
+ What we have to pass to this annotation here.
136
+
137
+ 35
138
+ 00:02:29,000 --> 00:02:32,000
139
+ I specify a package with unit test that I want to run.
140
+
141
+ 36
142
+ 00:02:32,000 --> 00:02:34,000
143
+ Be careful.
144
+
145
+ 37
146
+ 00:02:34,000 --> 00:02:40,000
147
+ This notation by default runs on the test that there is a machine with test O ended up with test or
148
+
149
+ 38
150
+ 00:02:40,000 --> 00:02:41,000
151
+ test.
152
+
153
+ 39
154
+ 00:02:41,000 --> 00:02:47,000
155
+ That's why in case you have some custom name for unit class, it will be not included in the test.
156
+
157
+ 40
158
+ 00:02:48,000 --> 00:02:52,000
159
+ A little bit later, I will show you how to add any specific class by name.
160
+
161
+ 41
162
+ 00:02:52,000 --> 00:02:55,000
163
+ You can specify multiple packages if you wish.
164
+
165
+ 42
166
+ 00:02:55,000 --> 00:03:00,000
167
+ Just pass array of strings to annotation from the syntax standpoint.
168
+
169
+ 43
170
+ 00:03:00,000 --> 00:03:03,000
171
+ Just wrap your strings and curly braces like I did here.
172
+
173
+ 44
174
+ 00:03:04,000 --> 00:03:05,000
175
+ My default.
176
+
177
+ 45
178
+ 00:03:05,000 --> 00:03:10,000
179
+ This notation tells to run tests in this package and all of its packages.
180
+
181
+ 46
182
+ 00:03:10,000 --> 00:03:15,000
183
+ But what if I don't want to run all tests and I want to exclude test from specific package?
184
+
185
+ 47
186
+ 00:03:16,000 --> 00:03:22,000
187
+ For example, I can specify here that I want to run all tests that exist in my project, excluding tests
188
+
189
+ 48
190
+ 00:03:22,000 --> 00:03:24,000
191
+ from the unit package.
192
+
193
+ 49
194
+ 00:03:24,000 --> 00:03:31,000
195
+ To do this, I have to use exclude packages annotation in case you want to include specific package
196
+
197
+ 50
198
+ 00:03:31,000 --> 00:03:37,000
199
+ you can use include packages, annotation, hope that these annotations are self describing and you
200
+
201
+ 51
202
+ 00:03:37,000 --> 00:03:38,000
203
+ can understand these easily.
204
+
205
+ 52
206
+ 00:03:39,000 --> 00:03:45,000
207
+ Also, during the development of your tests, you can mark specific tasks with tasks a little bit later
208
+
209
+ 53
210
+ 00:03:45,000 --> 00:03:47,000
211
+ in this lesson, I'll show you how to do this.
212
+
213
+ 54
214
+ 00:03:48,000 --> 00:03:54,000
215
+ But imagine that there are some specifics in environmental configurations of each server and special
216
+
217
+ 55
218
+ 00:03:54,000 --> 00:03:59,000
219
+ set of test should be run on development, environment and special set of tests should be executed on
220
+
221
+ 56
222
+ 00:03:59,000 --> 00:04:00,000
223
+ production environment.
224
+
225
+ 57
226
+ 00:04:01,000 --> 00:04:07,000
227
+ While these cases are relatively rare, it is still good to know that such a level of configuration
228
+
229
+ 58
230
+ 00:04:07,000 --> 00:04:08,000
231
+ exists in the unit.
232
+
233
+ 59
234
+ 00:04:09,000 --> 00:04:14,000
235
+ In case you want to run a specific class, you can use select classes, annotation and pass gloss to
236
+
237
+ 60
238
+ 00:04:14,000 --> 00:04:14,000
239
+ it.
240
+
241
+ 61
242
+ 00:04:15,000 --> 00:04:21,000
243
+ Similar to previous example, we can pass array of classes in case we want to execute multiple classes
244
+
245
+ 62
246
+ 00:04:21,000 --> 00:04:22,000
247
+ in scope of this test.
248
+
249
+ 63
250
+ 00:04:23,000 --> 00:04:26,000
251
+ It looks like that's we're regarding creation of tests.
252
+
253
+ 64
254
+ 00:04:26,000 --> 00:04:28,000
255
+ Let's move on and see what else do we have.
256
+
257
+ 65
258
+ 00:04:29,000 --> 00:04:33,000
259
+ You already saw how to include test that attacked with a specific attack.
260
+
261
+ 66
262
+ 00:04:34,000 --> 00:04:36,000
263
+ Let's learn now how we can attack our tests.
264
+
265
+ 67
266
+ 00:04:37,000 --> 00:04:42,000
267
+ We can use that connotation with classes and masses, the specific rules for tech names.
268
+
269
+ 68
270
+ 00:04:42,000 --> 00:04:44,000
271
+ But all of them are pretty intuitive.
272
+
273
+ 69
274
+ 00:04:44,000 --> 00:04:51,000
275
+ And in case you don't use any extraordinary name that it started with ampersand or exclamation point,
276
+
277
+ 70
278
+ 00:04:51,000 --> 00:04:51,000
279
+ then are good.
280
+
281
+ 71
282
+ 00:04:52,000 --> 00:04:58,000
283
+ The next thing that I want to discuss with you today is a test in order by default test, an order is
284
+
285
+ 72
286
+ 00:04:58,000 --> 00:05:01,000
287
+ undermined and that is fine.
288
+
289
+ 73
290
+ 00:05:01,000 --> 00:05:04,000
291
+ I believe you remember first principles and namely.
292
+
293
+ 74
294
+ 00:05:04,000 --> 00:05:08,000
295
+ Is the latest principal, each test should be isolated from each other.
296
+
297
+ 75
298
+ 00:05:09,000 --> 00:05:11,000
299
+ That's why it is not a big deal for us.
300
+
301
+ 76
302
+ 00:05:11,000 --> 00:05:13,000
303
+ What is the order of test?
304
+
305
+ 77
306
+ 00:05:13,000 --> 00:05:19,000
307
+ Execution is, but it provides us with opportunity to specify order of tests, execution.
308
+
309
+ 78
310
+ 00:05:20,000 --> 00:05:25,000
311
+ In my opinion, this is extremely rare cases when you have to use this feature, but still you have
312
+
313
+ 79
314
+ 00:05:25,000 --> 00:05:28,000
315
+ to know about it to specify order of tests.
316
+
317
+ 80
318
+ 00:05:28,000 --> 00:05:29,000
319
+ We have to do a few things.
320
+
321
+ 81
322
+ 00:05:30,000 --> 00:05:37,000
323
+ First thing we have to do is to add test methods, order in addition to the class and specify order
324
+
325
+ 82
326
+ 00:05:37,000 --> 00:05:42,000
327
+ implementation that we want to use the different implementations that are available for us.
328
+
329
+ 83
330
+ 00:05:42,000 --> 00:05:50,000
331
+ They are just plain name to search execution by display, name, method, name to sort of test execution
332
+
333
+ 84
334
+ 00:05:50,000 --> 00:05:57,000
335
+ by test method names or the notation to search by order specified in annotation, random orders test
336
+
337
+ 85
338
+ 00:05:57,000 --> 00:06:01,000
339
+ methods to the randomly and supports configuration of a custom seat.
340
+
341
+ 86
342
+ 00:06:02,000 --> 00:06:05,000
343
+ In my opinion, using ornamentation is very convenient.
344
+
345
+ 87
346
+ 00:06:06,000 --> 00:06:07,000
347
+ So let me show you how it works.
348
+
349
+ 88
350
+ 00:06:08,000 --> 00:06:12,000
351
+ I specify all the annotation class in my test method order annotation.
352
+
353
+ 89
354
+ 00:06:13,000 --> 00:06:19,000
355
+ After this, the only thing that I have to do is to add order annotation to each test method and specify
356
+
357
+ 90
358
+ 00:06:19,000 --> 00:06:21,000
359
+ in the order of each.
360
+
361
+ 91
362
+ 00:06:21,000 --> 00:06:24,000
363
+ So the test was order one will be executed.
364
+
365
+ 92
366
+ 00:06:24,000 --> 00:06:29,000
367
+ First test was ordered to will be executed next and so on.
368
+
369
+ 93
370
+ 00:06:29,000 --> 00:06:33,000
371
+ That is how simply we can configure order of execution for our test.
372
+
373
+ 94
374
+ 00:06:33,000 --> 00:06:39,000
375
+ But remember, usually each test should not rely on the test or the execution.
376
+
377
+ 95
378
+ 00:06:40,000 --> 00:06:45,000
379
+ The next thing I wanted to discuss with you is a conditional test execution gene.
380
+
381
+ 96
382
+ 00:06:45,000 --> 00:06:50,000
383
+ It allows us to disable or enable test based on the specific conditions.
384
+
385
+ 97
386
+ 00:06:50,000 --> 00:06:55,000
387
+ We are going to learn annotations that will help us to configure specific conditions.
388
+
389
+ 98
390
+ 00:06:55,000 --> 00:06:59,000
391
+ Basically, we can group all these annotations in the following groups.
392
+
393
+ 99
394
+ 00:06:59,000 --> 00:07:06,000
395
+ Operating system conditions, Java runtime environment conditions, system, property conditions, environment,
396
+
397
+ 100
398
+ 00:07:06,000 --> 00:07:09,000
399
+ variable conditions, custom conditions.
400
+
401
+ 101
402
+ 00:07:10,000 --> 00:07:11,000
403
+ Let's review all examples.
404
+
405
+ 102
406
+ 00:07:11,000 --> 00:07:14,000
407
+ One by one operating system.
408
+
409
+ 103
410
+ 00:07:14,000 --> 00:07:20,000
411
+ Conditions allows you to enable or disable test based on the operating system of environment where code
412
+
413
+ 104
414
+ 00:07:20,000 --> 00:07:21,000
415
+ is executed.
416
+
417
+ 105
418
+ 00:07:21,000 --> 00:07:27,000
419
+ Here you can see examples with enabling test on the operating system, on array of operating systems
420
+
421
+ 106
422
+ 00:07:27,000 --> 00:07:31,000
423
+ and similar example with disabling test based on operating system.
424
+
425
+ 107
426
+ 00:07:32,000 --> 00:07:37,000
427
+ Pay attention to their predefined constants for major operating systems in this class.
428
+
429
+ 108
430
+ 00:07:38,000 --> 00:07:43,000
431
+ I will share the link to the source code of this test so that you could check all the statements that
432
+
433
+ 109
434
+ 00:07:43,000 --> 00:07:48,000
435
+ they use to use these classes and annotations just in case it gives us a suggestion.
436
+
437
+ 110
438
+ 00:07:48,000 --> 00:07:50,000
439
+ Tool should help you with this.
440
+
441
+ 111
442
+ 00:07:51,000 --> 00:07:57,000
443
+ The next group of conditions will help you to enable or disable specific unit tests based on the particular
444
+
445
+ 112
446
+ 00:07:57,000 --> 00:07:58,000
447
+ version of Jerry.
448
+
449
+ 113
450
+ 00:07:59,000 --> 00:08:05,000
451
+ The specific annotations for NAINGGOLAN test for the specific Jerry enabling test for the arrays or
452
+
453
+ 114
454
+ 00:08:05,000 --> 00:08:11,000
455
+ reversions enable for jury rank enabling for range by specifying easy, just minimum or just maximum
456
+
457
+ 115
458
+ 00:08:11,000 --> 00:08:13,000
459
+ Jerry version.
460
+
461
+ 116
462
+ 00:08:13,000 --> 00:08:20,000
463
+ You can do the similar things for the same tests and here you can find examples how this is clear.
464
+
465
+ 117
466
+ 00:08:20,000 --> 00:08:26,000
467
+ Now let me show you annotations that will help you make conditions based on the system properties you
468
+
469
+ 118
470
+ 00:08:26,000 --> 00:08:28,000
471
+ can use, enabled or disabled.
472
+
473
+ 119
474
+ 00:08:28,000 --> 00:08:35,000
475
+ If property annotations to check if specific properties are equal to the value we pass here, the value
476
+
477
+ 120
478
+ 00:08:35,000 --> 00:08:36,000
479
+ is applied.
480
+
481
+ 121
482
+ 00:08:36,000 --> 00:08:36,000
483
+ We are much.
484
+
485
+ 122
486
+ 00:08:36,000 --> 00:08:39,000
487
+ This attribute will be interpreted as a regular expression.
488
+
489
+ 123
490
+ 00:08:40,000 --> 00:08:42,000
491
+ Actually, there is nothing more to add here.
492
+
493
+ 124
494
+ 00:08:43,000 --> 00:08:47,000
495
+ Also, we can enable or disable test based on the environment variables.
496
+
497
+ 125
498
+ 00:08:47,000 --> 00:08:52,000
499
+ Here you can see examples of these two annotations similar to previous example.
500
+
501
+ 126
502
+ 00:08:53,000 --> 00:08:59,000
503
+ Value in matches attribute will be treated as a regular expression and the most interesting, in my
504
+
505
+ 127
506
+ 00:08:59,000 --> 00:09:01,000
507
+ opinion, it is a custom condition.
508
+
509
+ 128
510
+ 00:09:02,000 --> 00:09:03,000
511
+ Let me explain how it works.
512
+
513
+ 129
514
+ 00:09:04,000 --> 00:09:10,000
515
+ We can use is a enable or disable if annotations and pastorate name or the method that we are going
516
+
517
+ 130
518
+ 00:09:10,000 --> 00:09:12,000
519
+ to use to define the condition.
520
+
521
+ 131
522
+ 00:09:13,000 --> 00:09:19,000
523
+ The method should return is a true or false, and based on this test will be is enabled or disabled.
524
+
525
+ 132
526
+ 00:09:20,000 --> 00:09:25,000
527
+ This option gives you a lot of flexibility and definition of your own condition.
528
+
529
+ 133
530
+ 00:09:25,000 --> 00:09:27,000
531
+ Does it make sense now?
532
+
533
+ 134
534
+ 00:09:27,000 --> 00:09:32,000
535
+ You know all possible ways how to configure conditions to enable or disable your test.
536
+
537
+ 135
538
+ 00:09:32,000 --> 00:09:34,000
539
+ Let's move on to the next topic.
540
+
541
+ 136
542
+ 00:09:35,000 --> 00:09:41,000
543
+ Do it allows us to create repeat a test that will be repeated, specified number of times to create
544
+
545
+ 137
546
+ 00:09:41,000 --> 00:09:41,000
547
+ such test.
548
+
549
+ 138
550
+ 00:09:41,000 --> 00:09:48,000
551
+ Just use repeated test annotation, unspecified number of times to repeat it inside annotation.
552
+
553
+ 139
554
+ 00:09:48,000 --> 00:09:51,000
555
+ Besides, no, we also can specify the name of the test.
556
+
557
+ 140
558
+ 00:09:52,000 --> 00:09:53,000
559
+ Well, define a name.
560
+
561
+ 141
562
+ 00:09:53,000 --> 00:09:58,000
563
+ We can use placeholders to display current repetition and total repetitions.
564
+
565
+ 142
566
+ 00:09:58,000 --> 00:09:59,000
567
+ That's it.
568
+
569
+ 143
570
+ 00:10:00,000 --> 00:10:04,000
571
+ This notation is useful when you want to make sure that even after multi.
572
+
573
+ 144
574
+ 00:10:04,000 --> 00:10:11,000
575
+ Execution, tax returns, the same result, the next example I want to show you is about temporary director
576
+
577
+ 145
578
+ 00:10:11,000 --> 00:10:18,000
579
+ in Unit four, there was so-called temporary folder rule that helped us to perform operations with file
580
+
581
+ 146
582
+ 00:10:18,000 --> 00:10:20,000
583
+ only in scope of our union test.
584
+
585
+ 147
586
+ 00:10:20,000 --> 00:10:25,000
587
+ In grade five, we have similar feature, but implemented in more intuitive way.
588
+
589
+ 148
590
+ 00:10:25,000 --> 00:10:29,000
591
+ Imagine that your application stores some data to your file system.
592
+
593
+ 149
594
+ 00:10:30,000 --> 00:10:36,000
595
+ Imagine that you want to store receipt of all purchases in the online store and you want to test the
596
+
597
+ 150
598
+ 00:10:36,000 --> 00:10:40,000
599
+ content of this file instead of fighting the workarounds.
600
+
601
+ 151
602
+ 00:10:40,000 --> 00:10:44,000
603
+ How to create files first and after all, test passed.
604
+
605
+ 152
606
+ 00:10:44,000 --> 00:10:50,000
607
+ Remove these files and also be bothered about other questions like how to separate test and non test
608
+
609
+ 153
610
+ 00:10:50,000 --> 00:10:54,000
611
+ files and so on to avoid answering these questions.
612
+
613
+ 154
614
+ 00:10:54,000 --> 00:10:56,000
615
+ There is a temporary folder extension.
616
+
617
+ 155
618
+ 00:10:56,000 --> 00:10:58,000
619
+ Let me show you how you can use it.
620
+
621
+ 156
622
+ 00:10:59,000 --> 00:11:07,000
623
+ Basically, in any test method we can pass such argument as pass was annotation stampeder after that.
624
+
625
+ 157
626
+ 00:11:07,000 --> 00:11:13,000
627
+ Inside the test we can resolve the pass and do this, pass everything we need.
628
+
629
+ 158
630
+ 00:11:13,000 --> 00:11:20,000
631
+ For example, in this particular case I wrote some text to a file and after that verified the text and
632
+
633
+ 159
634
+ 00:11:20,000 --> 00:11:26,000
635
+ file is the same as I expect after test execution's, this file will be removed.
636
+
637
+ 160
638
+ 00:11:26,000 --> 00:11:29,000
639
+ So there is no impact on your local file system.
640
+
641
+ 161
642
+ 00:11:30,000 --> 00:11:33,000
643
+ That's how easily you can use temporary directory extension.
644
+
645
+ 162
646
+ 00:11:33,000 --> 00:11:34,000
647
+ Is it clear?
648
+
649
+ 163
650
+ 00:11:35,000 --> 00:11:35,000
651
+ Awesome.
652
+
653
+ 164
654
+ 00:11:36,000 --> 00:11:39,000
655
+ Also today we are going to have one more important topic.
656
+
657
+ 165
658
+ 00:11:40,000 --> 00:11:46,000
659
+ I believe you already noticed that a lot of things in our Test MGE library is developed for the one
660
+
661
+ 166
662
+ 00:11:46,000 --> 00:11:50,000
663
+ main increase readability of our test.
664
+
665
+ 167
666
+ 00:11:50,000 --> 00:11:57,000
667
+ I mean, all these annotations like display neme extra long, massive names, naming mascots with underscore
668
+
669
+ 168
670
+ 00:11:57,000 --> 00:11:58,000
671
+ and lots more.
672
+
673
+ 169
674
+ 00:11:59,000 --> 00:12:04,000
675
+ And there is also a popular library the Java developers use often it is called Holmquist.
676
+
677
+ 170
678
+ 00:12:05,000 --> 00:12:11,000
679
+ Even if you want to use it on a daily basis, you should be at least aware about it because it is very
680
+
681
+ 171
682
+ 00:12:11,000 --> 00:12:11,000
683
+ popular.
684
+
685
+ 172
686
+ 00:12:12,000 --> 00:12:19,000
687
+ So Ensures Holmquist is a library that allows us to achieve high reliability of our code by using custom
688
+
689
+ 173
690
+ 00:12:19,000 --> 00:12:22,000
691
+ assertion methods and matchers as well known examples.
692
+
693
+ 174
694
+ 00:12:22,000 --> 00:12:28,000
695
+ You understand what I am talking about and to start working with Holmquist, the first thing we have
696
+
697
+ 175
698
+ 00:12:28,000 --> 00:12:31,000
699
+ to do is to add Humphris Library to our claspers.
700
+
701
+ 176
702
+ 00:12:32,000 --> 00:12:33,000
703
+ How to do that?
704
+
705
+ 177
706
+ 00:12:33,000 --> 00:12:38,000
707
+ I already show the imperiousness and how to add external jar's to our project.
708
+
709
+ 178
710
+ 00:12:38,000 --> 00:12:41,000
711
+ But in this lesson we will do everything from the beginning.
712
+
713
+ 179
714
+ 00:12:41,000 --> 00:12:46,000
715
+ So the first question, where to get Humphris Library in the Internet?
716
+
717
+ 180
718
+ 00:12:47,000 --> 00:12:49,000
719
+ There really a lot of open repositories.
720
+
721
+ 181
722
+ 00:12:49,000 --> 00:12:52,000
723
+ One of the biggest repository is Mavin repository.
724
+
725
+ 182
726
+ 00:12:53,000 --> 00:12:58,000
727
+ We can type our Google search like this Holmquist Mavin Rappa.
728
+
729
+ 183
730
+ 00:12:58,000 --> 00:13:01,000
731
+ Now let's open the first link from the list.
732
+
733
+ 184
734
+ 00:13:01,000 --> 00:13:07,000
735
+ These are all libraries from Humphris, but today we need only one Holmquist.
736
+
737
+ 185
738
+ 00:13:07,000 --> 00:13:09,000
739
+ Oh, here it is right on the top.
740
+
741
+ 186
742
+ 00:13:10,000 --> 00:13:15,000
743
+ The library contains all modules that are needed to work efficiently with Congress.
744
+
745
+ 187
746
+ 00:13:15,000 --> 00:13:19,000
747
+ On this page, we can choose a version of our Honkers Library.
748
+
749
+ 188
750
+ 00:13:19,000 --> 00:13:22,000
751
+ I select the latest one on this page.
752
+
753
+ 189
754
+ 00:13:22,000 --> 00:13:28,000
755
+ We can find instructions how to setup dependency on this library in projects was automated built tools.
756
+
757
+ 190
758
+ 00:13:29,000 --> 00:13:31,000
759
+ But we have simple Java project.
760
+
761
+ 191
762
+ 00:13:31,000 --> 00:13:36,000
763
+ Don't worry, we'll learn, automate, build tools later, but not in this lesson.
764
+
765
+ 192
766
+ 00:13:36,000 --> 00:13:41,000
767
+ Right now we need to find how to download archive with Humphris classes.
768
+
769
+ 193
770
+ 00:13:41,000 --> 00:13:48,000
771
+ And here I can download your file of Humphris Library Download File and get back to Eclipse.
772
+
773
+ 194
774
+ 00:13:48,000 --> 00:13:52,000
775
+ Hearing the clips we have to adhere to Claspers Mouse right.
776
+
777
+ 195
778
+ 00:13:52,000 --> 00:13:58,000
779
+ Click on our project, build POS, configure, build, pass here.
780
+
781
+ 196
782
+ 00:13:58,000 --> 00:14:00,000
783
+ Make sure you can navigate at the library.
784
+
785
+ 197
786
+ 00:14:00,000 --> 00:14:02,000
787
+ Step press on claspers.
788
+
789
+ 198
790
+ 00:14:03,000 --> 00:14:10,000
791
+ Now click on Add External Jar's and here you can find Humphris libraries that we have just downloaded
792
+
793
+ 199
794
+ 00:14:10,000 --> 00:14:13,000
795
+ and already have this library added to my claspers.
796
+
797
+ 200
798
+ 00:14:13,000 --> 00:14:15,000
799
+ So I will just close this window.
800
+
801
+ 201
802
+ 00:14:15,000 --> 00:14:21,000
803
+ When you added Humphris Library to a class pass, we can proceed with our examples, especially for
804
+
805
+ 202
806
+ 00:14:21,000 --> 00:14:22,000
807
+ this lesson.
808
+
809
+ 203
810
+ 00:14:22,000 --> 00:14:25,000
811
+ I created a separate file with compressed examples.
812
+
813
+ 204
814
+ 00:14:25,000 --> 00:14:28,000
815
+ I will leave Lean to the source code attached to the lesson.
816
+
817
+ 205
818
+ 00:14:29,000 --> 00:14:31,000
819
+ Let's write our first test with Congress.
820
+
821
+ 206
822
+ 00:14:31,000 --> 00:14:33,000
823
+ We have simple test here.
824
+
825
+ 207
826
+ 00:14:33,000 --> 00:14:37,000
827
+ Imagine we have two strings no matter how we received that.
828
+
829
+ 208
830
+ 00:14:37,000 --> 00:14:43,000
831
+ In this example, I want to put all your focus on the syntax of Honkers instead of regular assertions
832
+
833
+ 209
834
+ 00:14:43,000 --> 00:14:45,000
835
+ that you already used to into Unit five.
836
+
837
+ 210
838
+ 00:14:46,000 --> 00:14:49,000
839
+ Your special message from Moccia, a search class.
840
+
841
+ 211
842
+ 00:14:49,000 --> 00:14:55,000
843
+ This is called Assert that this is overloaded MassArt and one version of it takes three as the first
844
+
845
+ 212
846
+ 00:14:55,000 --> 00:14:56,000
847
+ argument.
848
+
849
+ 213
850
+ 00:14:56,000 --> 00:15:01,000
851
+ This string is used as an error message to be displayed in case test was failed.
852
+
853
+ 214
854
+ 00:15:01,000 --> 00:15:03,000
855
+ Personally, I more often use an.
856
+
857
+ 215
858
+ 00:15:03,000 --> 00:15:09,000
859
+ Another version of this massive that takes actual value as a first argument and the march as a second
860
+
861
+ 216
862
+ 00:15:09,000 --> 00:15:16,000
863
+ argument, Humphris Marcia is a special type and can help you to identify the march according to the
864
+
865
+ 217
866
+ 00:15:16,000 --> 00:15:18,000
867
+ requirements of the test.
868
+
869
+ 218
870
+ 00:15:18,000 --> 00:15:21,000
871
+ Usually we use static methods that can return.
872
+
873
+ 219
874
+ 00:15:21,000 --> 00:15:27,000
875
+ Matching object in this particular case are used equal to Masset from March 1st class.
876
+
877
+ 220
878
+ 00:15:28,000 --> 00:15:33,000
879
+ This static method returns March as it will help us to check equality with the first argument.
880
+
881
+ 221
882
+ 00:15:33,000 --> 00:15:40,000
883
+ And if you can notice that we received Stylize sentence, that is easy to read and to understand.
884
+
885
+ 222
886
+ 00:15:40,000 --> 00:15:42,000
887
+ Let's look at another example.
888
+
889
+ 223
890
+ 00:15:42,000 --> 00:15:47,000
891
+ Imagine that you have at least with values, and during the test you modified the state of the list.
892
+
893
+ 224
894
+ 00:15:48,000 --> 00:15:49,000
895
+ Just imagine that.
896
+
897
+ 225
898
+ 00:15:49,000 --> 00:15:56,000
899
+ And in a certain part of your test, we have to verify that list contains one of the expected values.
900
+
901
+ 226
902
+ 00:15:56,000 --> 00:16:06,000
903
+ Here is a line written with Humphris assert that Liste has item any of equal to a equal to be equal
904
+
905
+ 227
906
+ 00:16:06,000 --> 00:16:11,000
907
+ to see you like it is almost like a complete sentence.
908
+
909
+ 228
910
+ 00:16:11,000 --> 00:16:16,000
911
+ And you can see that you can use marchers as an input argument to another marcher.
912
+
913
+ 229
914
+ 00:16:17,000 --> 00:16:19,000
915
+ And right below we can see that same assertion.
916
+
917
+ 230
918
+ 00:16:19,000 --> 00:16:22,000
919
+ But reason with do can't tell me what do you think?
920
+
921
+ 231
922
+ 00:16:23,000 --> 00:16:25,000
923
+ What is more readable in your opinion?
924
+
925
+ 232
926
+ 00:16:26,000 --> 00:16:32,000
927
+ Some of my students tell me that they still prefer giant assertions of a holmquist and that is completely
928
+
929
+ 233
930
+ 00:16:32,000 --> 00:16:33,000
931
+ fine.
932
+
933
+ 234
934
+ 00:16:33,000 --> 00:16:36,000
935
+ It is only a matter of coding style and nothing more.
936
+
937
+ 235
938
+ 00:16:36,000 --> 00:16:42,000
939
+ I just want you to know about this library since it is popular, essentially.
940
+
941
+ 236
942
+ 00:16:42,000 --> 00:16:43,000
943
+ That's it.
944
+
945
+ 237
946
+ 00:16:43,000 --> 00:16:49,000
947
+ So the only thing that would be different from test to test is a march that you will choose to perform
948
+
949
+ 238
950
+ 00:16:49,000 --> 00:16:55,000
951
+ the validation that different group of marchers I gathered all of them on one slide.
952
+
953
+ 239
954
+ 00:16:55,000 --> 00:16:56,000
955
+ Let me show it to you.
956
+
957
+ 240
958
+ 00:16:57,000 --> 00:17:05,000
959
+ There are such groups of marchers, core logical object, beanz collections, no text.
960
+
961
+ 241
962
+ 00:17:06,000 --> 00:17:09,000
963
+ And on this slide, you can find a description for each of this march.
964
+
965
+ 242
966
+ 00:17:10,000 --> 00:17:15,000
967
+ I believe that by name of each march you can understand what does do.
968
+
969
+ 243
970
+ 00:17:15,000 --> 00:17:19,000
971
+ That's why I believe there is no need to go over each of these.
972
+
973
+ 244
974
+ 00:17:20,000 --> 00:17:24,000
975
+ In the case that after reading of description for each march, you still have questions.
976
+
977
+ 245
978
+ 00:17:24,000 --> 00:17:28,000
979
+ Do not hesitate to ask these questions in Q&A section.
980
+
981
+ 246
982
+ 00:17:29,000 --> 00:17:35,000
983
+ And the last, but not least for today, I would love to use your typical mistakes that usually junior
984
+
985
+ 247
986
+ 00:17:35,000 --> 00:17:36,000
987
+ developers do.
988
+
989
+ 248
990
+ 00:17:36,000 --> 00:17:37,000
991
+ Based on my experience.
992
+
993
+ 249
994
+ 00:17:38,000 --> 00:17:41,000
995
+ The first typical mistake is testing of Java API.
996
+
997
+ 250
998
+ 00:17:42,000 --> 00:17:48,000
999
+ This mistake can have multiple and various forms, but the idea, as it stands behind its example,
1000
+
1001
+ 251
1002
+ 00:17:48,000 --> 00:17:48,000
1003
+ is simple.
1004
+
1005
+ 252
1006
+ 00:17:49,000 --> 00:17:51,000
1007
+ You don't have to test how Java works.
1008
+
1009
+ 253
1010
+ 00:17:52,000 --> 00:17:58,000
1011
+ The second common mistake is to write a test that will never fail on the slide.
1012
+
1013
+ 254
1014
+ 00:17:58,000 --> 00:18:04,000
1015
+ You can see very simple example to get the point in real life, the source code can be a bit more complicated,
1016
+
1017
+ 255
1018
+ 00:18:04,000 --> 00:18:09,000
1019
+ but at the end of the day, specific scenario will always return.
1020
+
1021
+ 256
1022
+ 00:18:09,000 --> 00:18:16,000
1023
+ True, if you remember in previous lesson I gave you one advice spend two more seconds to make sure
1024
+
1025
+ 257
1026
+ 00:18:16,000 --> 00:18:18,000
1027
+ that you at least once in your life.
1028
+
1029
+ 258
1030
+ 00:18:18,000 --> 00:18:24,000
1031
+ So each specific test in red status that would help you to avoid this mistake.
1032
+
1033
+ 259
1034
+ 00:18:25,000 --> 00:18:28,000
1035
+ Huge test, that is our next mistake.
1036
+
1037
+ 260
1038
+ 00:18:28,000 --> 00:18:31,000
1039
+ Don't try to test everything in one test.
1040
+
1041
+ 261
1042
+ 00:18:31,000 --> 00:18:36,000
1043
+ Remember one assert per test or single concept for a test.
1044
+
1045
+ 262
1046
+ 00:18:36,000 --> 00:18:42,000
1047
+ And also remember, do not hardcourt any values in court and avoid of using magic numbers.
1048
+
1049
+ 263
1050
+ 00:18:43,000 --> 00:18:49,000
1051
+ We kind of discuss this topic and this advice already, but I want to make sure that you remember this.
1052
+
1053
+ 264
1054
+ 00:18:49,000 --> 00:18:55,000
1055
+ It is better to use constants that are defined in your test class and that have clear name rather than
1056
+
1057
+ 265
1058
+ 00:18:55,000 --> 00:18:56,000
1059
+ guessing.
1060
+
1061
+ 266
1062
+ 00:18:56,000 --> 00:18:57,000
1063
+ What does this mean?
1064
+
1065
+ 267
1066
+ 00:18:58,000 --> 00:19:01,000
1067
+ That was all made mistakes that I wanted to put your attention to.
1068
+
1069
+ 268
1070
+ 00:19:02,000 --> 00:19:04,000
1071
+ Now let's recap what we have learned today.
1072
+
1073
+ 269
1074
+ 00:19:05,000 --> 00:19:10,000
1075
+ We started our lesson was learned what test is and how to define the customer test.
1076
+
1077
+ 270
1078
+ 00:19:10,000 --> 00:19:14,000
1079
+ But after that, we learned a little bit more about tagine.
1080
+
1081
+ 271
1082
+ 00:19:14,000 --> 00:19:21,000
1083
+ In this lesson, I explained you how to configure order of test execution to make sure that tests are
1084
+
1085
+ 272
1086
+ 00:19:21,000 --> 00:19:27,000
1087
+ running in predefined sequence uson examples how to create different kinds of conditional statements
1088
+
1089
+ 273
1090
+ 00:19:27,000 --> 00:19:31,000
1091
+ that will allow you to enable or disable test upon specific condition.
1092
+
1093
+ 274
1094
+ 00:19:32,000 --> 00:19:37,000
1095
+ Besides that, I also showed you a small example that explains how to create repeated tests.
1096
+
1097
+ 275
1098
+ 00:19:37,000 --> 00:19:41,000
1099
+ Now you know how to use temporary Fulda Extension.
1100
+
1101
+ 276
1102
+ 00:19:41,000 --> 00:19:43,000
1103
+ Well, testing input and output streams.
1104
+
1105
+ 277
1106
+ 00:19:44,000 --> 00:19:51,000
1107
+ Also, I showed you how to use Hahm Christiania unit test and at the end of the lesson we learned typical
1108
+
1109
+ 278
1110
+ 00:19:51,000 --> 00:19:52,000
1111
+ and most common mistakes.
1112
+
1113
+ 279
1114
+ 00:19:53,000 --> 00:19:54,000
1115
+ That's it for today.
1116
+
1117
+ 280
1118
+ 00:19:54,000 --> 00:19:56,000
1119
+ Thanks a lot for your attention.
1120
+
1121
+ 281
1122
+ 00:19:56,000 --> 00:19:59,000
1123
+ Have a great day and see you in the next lesson.
1124
+
34 - Unit Testing & JUnit 5/004 Source-code-of-Advanced-JUnit-Examples.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/JUnitApiAdvancedExamples.java
34 - Unit Testing & JUnit 5/004 Source-code-of-Hamcrest-Library-Examples.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/tree/master/test/com/itbulls/learnit/javacore/hamcrest
34 - Unit Testing & JUnit 5/004 Source-code-of-Test-Suites.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/TestSuiteExample.java
34 - Unit Testing & JUnit 5/external-links.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ 002 JUnit-Documentation
3
+ https://junit.org/junit5/docs/current/api/
4
+
5
+ 002 Source-code-of-MoneyTransactionService
6
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/src/com/itbulls/learnit/javacore/junit5/MoneyTransactionService.java
7
+
8
+ 002 Source-code-of-MoneyTransactionServiceTest
9
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/MoneyTransactionServiceTest.java
10
+
11
+ 003 Source-code-of-test-1
12
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/MoneyTransactionServiceTest2.java
13
+
14
+ 003 Source-code-of-test-2
15
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/TestCodeCoverageDemoTest.java
16
+
17
+ 004 Source-code-of-Test-Suites
18
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/TestSuiteExample.java
19
+
20
+ 004 Source-code-of-Advanced-JUnit-Examples
21
+ https://github.com/AndriiPiatakha/learnit_java_core/blob/master/test/com/itbulls/learnit/javacore/junit5/JUnitApiAdvancedExamples.java
22
+
23
+ 004 Source-code-of-Hamcrest-Library-Examples
24
+ https://github.com/AndriiPiatakha/learnit_java_core/tree/master/test/com/itbulls/learnit/javacore/hamcrest
35 - Integration testing & Mockito/001 Integration Testing in Java_en.srt ADDED
@@ -0,0 +1,700 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:06,000 --> 00:00:06,000
3
+ Hello, Jim.
4
+
5
+ 2
6
+ 00:00:07,000 --> 00:00:11,000
7
+ Today was that important section in this course we start learning how to perform integration testing
8
+
9
+ 3
10
+ 00:00:11,000 --> 00:00:12,000
11
+ of our app.
12
+
13
+ 4
14
+ 00:00:12,000 --> 00:00:16,000
15
+ We'll start from understanding what integration testing is.
16
+
17
+ 5
18
+ 00:00:16,000 --> 00:00:20,000
19
+ To help you understand it better, we'll compare integration and unit testing.
20
+
21
+ 6
22
+ 00:00:20,000 --> 00:00:26,000
23
+ I will explain what test numbers are and how they help us in testing will understand the advantages
24
+
25
+ 7
26
+ 00:00:26,000 --> 00:00:29,000
27
+ of using test doubles in testing process.
28
+
29
+ 8
30
+ 00:00:29,000 --> 00:00:34,000
31
+ After that, I'll share with you information about different types of integration testing.
32
+
33
+ 9
34
+ 00:00:34,000 --> 00:00:39,000
35
+ And at the end of the lesson, we'll learn what frameworks are used for integration testing in Java.
36
+
37
+ 10
38
+ 00:00:40,000 --> 00:00:42,000
39
+ Let's start at the beginning.
40
+
41
+ 11
42
+ 00:00:42,000 --> 00:00:45,000
43
+ We have to understand what is integration tests.
44
+
45
+ 12
46
+ 00:00:45,000 --> 00:00:52,000
47
+ In simple words, integration testing is a process where individual units are tested together to check
48
+
49
+ 13
50
+ 00:00:52,000 --> 00:00:55,000
51
+ whether all the units interact with each other as expected.
52
+
53
+ 14
54
+ 00:00:56,000 --> 00:01:03,000
55
+ So in the case of testing, we test only one specific unit in isolation, in integration testing.
56
+
57
+ 15
58
+ 00:01:03,000 --> 00:01:07,000
59
+ We want to make sure that different units work together as expected.
60
+
61
+ 16
62
+ 00:01:08,000 --> 00:01:13,000
63
+ For example, you want to be sure that when you use mail server to send an email, the message of template
64
+
65
+ 17
66
+ 00:01:13,000 --> 00:01:16,000
67
+ engine that prepares content of our email are invoked.
68
+
69
+ 18
70
+ 00:01:17,000 --> 00:01:23,000
71
+ Or for example, we want to be sure that in case there was an error in template engine, we didn't invoke
72
+
73
+ 19
74
+ 00:01:23,000 --> 00:01:27,000
75
+ stand method of our mail server to send invalid message and so on.
76
+
77
+ 20
78
+ 00:01:28,000 --> 00:01:31,000
79
+ Does it make sense during integration testing?
80
+
81
+ 21
82
+ 00:01:31,000 --> 00:01:38,000
83
+ All our focus is put into verification of behavior that is happening not inside the one single object,
84
+
85
+ 22
86
+ 00:01:38,000 --> 00:01:40,000
87
+ but between different objects.
88
+
89
+ 23
90
+ 00:01:41,000 --> 00:01:47,000
91
+ The focus of the integration test and level is to expose the at the time of interaction between integrated
92
+
93
+ 24
94
+ 00:01:47,000 --> 00:01:54,000
95
+ components or units to make sure that we are all here on the same page and that we are clearly understands
96
+
97
+ 25
98
+ 00:01:54,000 --> 00:01:57,000
99
+ the difference between unit testing and integration testing.
100
+
101
+ 26
102
+ 00:01:57,000 --> 00:01:59,000
103
+ Let's look at the next table here.
104
+
105
+ 27
106
+ 00:01:59,000 --> 00:02:04,000
107
+ You can see the table where we separated attributes of unit and integration testing.
108
+
109
+ 28
110
+ 00:02:05,000 --> 00:02:12,000
111
+ Let's go over each row one by one, and I will give my comments as we go in unit testing, test verifies
112
+
113
+ 29
114
+ 00:02:12,000 --> 00:02:20,000
115
+ on the implementation of the code of one single unit, whereas in integration testing test puts main
116
+
117
+ 30
118
+ 00:02:20,000 --> 00:02:24,000
119
+ attention on the interconnection behavior when they're used together.
120
+
121
+ 31
122
+ 00:02:25,000 --> 00:02:31,000
123
+ The next thing we have to know is that a unit test uses only unit test frameworks like G Unit or testing
124
+
125
+ 32
126
+ 00:02:31,000 --> 00:02:32,000
127
+ G and the Morgan framework.
128
+
129
+ 33
130
+ 00:02:33,000 --> 00:02:39,000
131
+ Today we'll talk about what more and more can a framework is ensure during the unit testing.
132
+
133
+ 34
134
+ 00:02:39,000 --> 00:02:44,000
135
+ Sometimes you need to use test doubles to replace real collaboration's of your unit with other units
136
+
137
+ 35
138
+ 00:02:45,000 --> 00:02:48,000
139
+ or even simply to satisfy the requirements of COMPILER.
140
+
141
+ 36
142
+ 00:02:48,000 --> 00:02:52,000
143
+ Don't worry, we'll also talk about test Dubbo's a little bit later today.
144
+
145
+ 37
146
+ 00:02:53,000 --> 00:02:58,000
147
+ But when we talk about integration tests, we still can use Moken frameworks and test doubles for the
148
+
149
+ 38
150
+ 00:02:58,000 --> 00:03:00,000
151
+ waste areas of the system.
152
+
153
+ 39
154
+ 00:03:00,000 --> 00:03:06,000
155
+ For example, as I already mentioned, we need to test interaction and behavior between elements like
156
+
157
+ 40
158
+ 00:03:06,000 --> 00:03:12,000
159
+ an example when mail server and Wolk's masses of template engine also an integration test.
160
+
161
+ 41
162
+ 00:03:12,000 --> 00:03:18,000
163
+ And we can use real containers and real databases and use real components for integration testing.
164
+
165
+ 42
166
+ 00:03:18,000 --> 00:03:24,000
167
+ For example, when one might project we had separate environment where automated acceptant testing was
168
+
169
+ 43
170
+ 00:03:24,000 --> 00:03:32,000
171
+ executed, we had sort of integration test the test, our API, but still used marked fake components.
172
+
173
+ 44
174
+ 00:03:32,000 --> 00:03:39,000
175
+ After running tests on eight environment, we executed our tests on so-called sealed environment system
176
+
177
+ 45
178
+ 00:03:39,000 --> 00:03:46,000
179
+ integration testing test on that environment used real competence like real database, real payment
180
+
181
+ 46
182
+ 00:03:46,000 --> 00:03:49,000
183
+ services, but just with the test data.
184
+
185
+ 47
186
+ 00:03:49,000 --> 00:03:55,000
187
+ So as you can see, level of using fake objects and test doubles during the integration testing can
188
+
189
+ 48
190
+ 00:03:55,000 --> 00:04:01,000
191
+ be different and will depend on your application and level of complexity of your system in general.
192
+
193
+ 49
194
+ 00:04:01,000 --> 00:04:07,000
195
+ The next thing that is different in unit testing and integration testing is that failure in unit test
196
+
197
+ 50
198
+ 00:04:07,000 --> 00:04:09,000
199
+ is always issue with the source code.
200
+
201
+ 51
202
+ 00:04:09,000 --> 00:04:11,000
203
+ But failure and integration testing.
204
+
205
+ 52
206
+ 00:04:11,000 --> 00:04:17,000
207
+ Besides, the issue with the source code also can mean changes in the environment and in other components.
208
+
209
+ 53
210
+ 00:04:18,000 --> 00:04:21,000
211
+ Unit testing is a first layer of test in our testing pyramid.
212
+
213
+ 54
214
+ 00:04:22,000 --> 00:04:26,000
215
+ If you don't miss any lessons before, I believe you remember what testing parameter is.
216
+
217
+ 55
218
+ 00:04:27,000 --> 00:04:32,000
219
+ And this is important to understand that before starting the implementation of integration tests, we
220
+
221
+ 56
222
+ 00:04:32,000 --> 00:04:38,000
223
+ have to be sure that all the years work properly in isolation and once all the components and modules
224
+
225
+ 57
226
+ 00:04:38,000 --> 00:04:44,000
227
+ are working independently, then we need to check the data flow between the dependent modules that is
228
+
229
+ 58
230
+ 00:04:44,000 --> 00:04:45,000
231
+ known as integration testing.
232
+
233
+ 59
234
+ 00:04:46,000 --> 00:04:52,000
235
+ So I believe that is clear that integration testing is a second level of the software testing process
236
+
237
+ 60
238
+ 00:04:52,000 --> 00:04:54,000
239
+ that comes after unit testing.
240
+
241
+ 61
242
+ 00:04:54,000 --> 00:05:00,000
243
+ Now, I would like to talk about test Dubbo's during the unit test and integration test, and sometimes
244
+
245
+ 62
246
+ 00:05:00,000 --> 00:05:02,000
247
+ we depend on the parts of our system.
248
+
249
+ 63
250
+ 00:05:03,000 --> 00:05:09,000
251
+ We don't need at the moment or they are not ready to be tested now where it is impossible to reproduce
252
+
253
+ 64
254
+ 00:05:09,000 --> 00:05:13,000
255
+ the state of some parts of the system on this particular environment and to write.
256
+
257
+ 65
258
+ 00:05:14,000 --> 00:05:20,000
259
+ We have to use counter parts of those elements that would behave like release ready elements.
260
+
261
+ 66
262
+ 00:05:20,000 --> 00:05:26,000
263
+ For example, you don't have available third party API that performs fraud verification of your user
264
+
265
+ 67
266
+ 00:05:26,000 --> 00:05:32,000
267
+ during the purchase, but you have official documentation and you know how to imitate this API.
268
+
269
+ 68
270
+ 00:05:32,000 --> 00:05:36,000
271
+ And now you can build something what behaves like real API.
272
+
273
+ 69
274
+ 00:05:37,000 --> 00:05:39,000
275
+ But actually this isn't an actual API.
276
+
277
+ 70
278
+ 00:05:40,000 --> 00:05:43,000
279
+ Such kind of units are called test double's.
280
+
281
+ 71
282
+ 00:05:43,000 --> 00:05:48,000
283
+ Besides that, that's double simplified testing process and provider's responsibility to reduce the
284
+
285
+ 72
286
+ 00:05:48,000 --> 00:05:51,000
287
+ complexity and facilitate testing.
288
+
289
+ 73
290
+ 00:05:51,000 --> 00:05:57,000
291
+ That's doable is a generic term that is used to describe objects or procedures that will help us during
292
+
293
+ 74
294
+ 00:05:57,000 --> 00:05:59,000
295
+ the testing was the case I described.
296
+
297
+ 75
298
+ 00:06:00,000 --> 00:06:06,000
299
+ Test novel has to implement the same interface as real life object and meets the same requirements,
300
+
301
+ 76
302
+ 00:06:06,000 --> 00:06:08,000
303
+ the different types of test.
304
+
305
+ 77
306
+ 00:06:08,000 --> 00:06:10,000
307
+ Dubbo's let's look at them.
308
+
309
+ 78
310
+ 00:06:10,000 --> 00:06:13,000
311
+ The first in our list is a dummy object.
312
+
313
+ 79
314
+ 00:06:13,000 --> 00:06:15,000
315
+ What is a dummy object?
316
+
317
+ 80
318
+ 00:06:15,000 --> 00:06:20,000
319
+ This is fake argument that is not really used and has no effect on the test.
320
+
321
+ 81
322
+ 00:06:20,000 --> 00:06:26,000
323
+ Imagine that you have multiple parameters in the method and you just need to pass at least something
324
+
325
+ 82
326
+ 00:06:26,000 --> 00:06:31,000
327
+ as an argument to execute this method, even in case you don't care about this argument at all.
328
+
329
+ 83
330
+ 00:06:31,000 --> 00:06:34,000
331
+ The next type of test is a test.
332
+
333
+ 84
334
+ 00:06:34,000 --> 00:06:34,000
335
+ Stop.
336
+
337
+ 85
338
+ 00:06:35,000 --> 00:06:38,000
339
+ Stop is an object with hardcoded values to be returned.
340
+
341
+ 86
342
+ 00:06:38,000 --> 00:06:42,000
343
+ It has no logic in sight and it is state oriented.
344
+
345
+ 87
346
+ 00:06:43,000 --> 00:06:48,000
347
+ Steps are used to provide our test with input to imitate different life cases.
348
+
349
+ 88
350
+ 00:06:48,000 --> 00:06:55,000
351
+ A fake object has implementation with shortcuts, so it is just a simplified version of the production
352
+
353
+ 89
354
+ 00:06:55,000 --> 00:06:55,000
355
+ code.
356
+
357
+ 90
358
+ 00:06:56,000 --> 00:07:02,000
359
+ It is usually used in integration testing, for example, to access and in-memory version of the production
360
+
361
+ 91
362
+ 00:07:02,000 --> 00:07:03,000
363
+ database.
364
+
365
+ 92
366
+ 00:07:04,000 --> 00:07:11,000
367
+ Mock a mock test double is a behavior oriented object used to assert InterAction's, it allows to use
368
+
369
+ 93
370
+ 00:07:11,000 --> 00:07:13,000
371
+ methods to verify interactions.
372
+
373
+ 94
374
+ 00:07:13,000 --> 00:07:19,000
375
+ For example, I can tell that some specific Masset was invoked with a specific list of parameters.
376
+
377
+ 95
378
+ 00:07:19,000 --> 00:07:23,000
379
+ Also, I can calculate a number of times method was invoked.
380
+
381
+ 96
382
+ 00:07:23,000 --> 00:07:29,000
383
+ We can also set expectations about Molk behavior before this code is executed.
384
+
385
+ 97
386
+ 00:07:29,000 --> 00:07:31,000
387
+ And finally, spy.
388
+
389
+ 98
390
+ 00:07:31,000 --> 00:07:33,000
391
+ A spy is similar to a mock.
392
+
393
+ 99
394
+ 00:07:33,000 --> 00:07:40,000
395
+ It is also behavior oriented object used to assert interactions, but it is different from the mock
396
+
397
+ 100
398
+ 00:07:40,000 --> 00:07:43,000
399
+ as delegates and monitor calls to real objects.
400
+
401
+ 101
402
+ 00:07:43,000 --> 00:07:50,000
403
+ So you use real object with real methods and all interactions with spy are substituted with close to
404
+
405
+ 102
406
+ 00:07:50,000 --> 00:07:53,000
407
+ real object unless some method was stopped.
408
+
409
+ 103
410
+ 00:07:54,000 --> 00:07:58,000
411
+ So I want you to understand that Mock's are something totally different.
412
+
413
+ 104
414
+ 00:07:58,000 --> 00:08:06,000
415
+ Until now, all our tests made assertions on a state marks a test double's that make assertions on behavior.
416
+
417
+ 105
418
+ 00:08:06,000 --> 00:08:10,000
419
+ To understand the analogy, imagine that Moncks say something like this.
420
+
421
+ 106
422
+ 00:08:11,000 --> 00:08:18,000
423
+ I expect that Masset one will be invoked with this string argument and if it is not there, I will throw
424
+
425
+ 107
426
+ 00:08:18,000 --> 00:08:19,000
427
+ an error.
428
+
429
+ 108
430
+ 00:08:19,000 --> 00:08:25,000
431
+ So Molk verifies behavior that the main goal of creating these kind of testable.
432
+
433
+ 109
434
+ 00:08:26,000 --> 00:08:32,000
435
+ Let's now sum it up to understand why we have to use test Dubbo's during the testing and what advantages
436
+
437
+ 110
438
+ 00:08:32,000 --> 00:08:34,000
439
+ we get from using that.
440
+
441
+ 111
442
+ 00:08:34,000 --> 00:08:38,000
443
+ With the help of test double's, we isolate code that is under test.
444
+
445
+ 112
446
+ 00:08:38,000 --> 00:08:45,000
447
+ We can be sure that we control all integration's and isolate specific parts of our system from each
448
+
449
+ 113
450
+ 00:08:45,000 --> 00:08:49,000
451
+ other, substituting the real integrations with Test Dumbo's.
452
+
453
+ 114
454
+ 00:08:49,000 --> 00:08:56,000
455
+ We can speed up test execution because integration test that uses real components for all kinds of integrations
456
+
457
+ 115
458
+ 00:08:56,000 --> 00:08:58,000
459
+ can take hours to complete.
460
+
461
+ 116
462
+ 00:08:59,000 --> 00:09:05,000
463
+ That's why very often a lot of parts in our integration test is substituted with test double's using
464
+
465
+ 117
466
+ 00:09:05,000 --> 00:09:06,000
467
+ test Dubbo's.
468
+
469
+ 118
470
+ 00:09:06,000 --> 00:09:12,000
471
+ We can stop specific behavior of our components and make execution of our test deterministic.
472
+
473
+ 119
474
+ 00:09:13,000 --> 00:09:18,000
475
+ At the end of the day, we want to have control over execution of our test from the start to the end
476
+
477
+ 120
478
+ 00:09:19,000 --> 00:09:25,000
479
+ test that helps us to reproduce special conditions and produce different states of our system to test
480
+
481
+ 121
482
+ 00:09:25,000 --> 00:09:27,000
483
+ different use cases.
484
+
485
+ 122
486
+ 00:09:27,000 --> 00:09:28,000
487
+ Does it make sense?
488
+
489
+ 123
490
+ 00:09:29,000 --> 00:09:33,000
491
+ Before we move further, I want to explain the different types of integration testing.
492
+
493
+ 124
494
+ 00:09:34,000 --> 00:09:41,000
495
+ Integration testing may be classified into two major groups ZAYA incremental integration testing and
496
+
497
+ 125
498
+ 00:09:41,000 --> 00:09:43,000
499
+ non incremental integration testing.
500
+
501
+ 126
502
+ 00:09:44,000 --> 00:09:51,000
503
+ In the incremental approach, modules are added in the ascending order one by one or according to need.
504
+
505
+ 127
506
+ 00:09:51,000 --> 00:09:57,000
507
+ The selected modules must be logically related generally to unmuzzled.
508
+
509
+ 128
510
+ 00:09:57,000 --> 00:10:01,000
511
+ Two modules are added and tested to determine the correctness of functions.
512
+
513
+ 129
514
+ 00:10:02,000 --> 00:10:08,000
515
+ The process continues until the successful testing of all the modules they are top down and bottom up
516
+
517
+ 130
518
+ 00:10:08,000 --> 00:10:14,000
519
+ approach is the top down testing strategy deals with the process in which high level modules are tested
520
+
521
+ 131
522
+ 00:10:14,000 --> 00:10:21,000
523
+ with low level modules until the successful completion of testing of all the modules, major design
524
+
525
+ 132
526
+ 00:10:21,000 --> 00:10:27,000
527
+ flaws can be detected and fixed early because critical modules tested first in this type of testing
528
+
529
+ 133
530
+ 00:10:27,000 --> 00:10:33,000
531
+ will add the modules incrementally or one by one and check the data flow in the same order.
532
+
533
+ 134
534
+ 00:10:34,000 --> 00:10:39,000
535
+ The bottom up testing strategy deals with the processes in which low level modules are tested with high
536
+
537
+ 135
538
+ 00:10:39,000 --> 00:10:44,000
539
+ level modules and use the successful completion of testing of all the modules.
540
+
541
+ 136
542
+ 00:10:44,000 --> 00:10:49,000
543
+ Top level critical modules are tested at last, so it may cause a defect.
544
+
545
+ 137
546
+ 00:10:49,000 --> 00:10:54,000
547
+ Or we can say that we will be adding the modules from bottom to the top and checking the data flow in
548
+
549
+ 138
550
+ 00:10:54,000 --> 00:10:55,000
551
+ the same order.
552
+
553
+ 139
554
+ 00:10:56,000 --> 00:10:59,000
555
+ Let me explain more about non incremental integration testing.
556
+
557
+ 140
558
+ 00:11:00,000 --> 00:11:06,000
559
+ We will go for this method when the data flow is very complex and when it is difficult to find who is
560
+
561
+ 141
562
+ 00:11:06,000 --> 00:11:13,000
563
+ a parent and who is a child and in such case will create the data in any module and we will test interactions
564
+
565
+ 142
566
+ 00:11:13,000 --> 00:11:15,000
567
+ with different modules without any specific logic.
568
+
569
+ 143
570
+ 00:11:16,000 --> 00:11:19,000
571
+ That is why this method is also known as big bank Macit.
572
+
573
+ 144
574
+ 00:11:20,000 --> 00:11:25,000
575
+ Now, when you know the theory of integration testing, let's learn what frameworks are used for integration
576
+
577
+ 145
578
+ 00:11:25,000 --> 00:11:26,000
579
+ testing.
580
+
581
+ 146
582
+ 00:11:26,000 --> 00:11:31,000
583
+ Probably the first framework that is used for integration testing is a unit.
584
+
585
+ 147
586
+ 00:11:31,000 --> 00:11:37,000
587
+ Even despite developers use the unit primarily for unit testing, we still can use this library for
588
+
589
+ 148
590
+ 00:11:37,000 --> 00:11:38,000
591
+ integration testing.
592
+
593
+ 149
594
+ 00:11:39,000 --> 00:11:43,000
595
+ Also, probably one of the most popular libraries that we use during integration testing.
596
+
597
+ 150
598
+ 00:11:43,000 --> 00:11:45,000
599
+ Is Makita an easy mark?
600
+
601
+ 151
602
+ 00:11:45,000 --> 00:11:52,000
603
+ These libraries help us to create mock and spy objects YABE unit libraries that helps us to create test
604
+
605
+ 152
606
+ 00:11:52,000 --> 00:11:54,000
607
+ for integration with database.
608
+
609
+ 153
610
+ 00:11:54,000 --> 00:12:00,000
611
+ Mauck FCP Server Library provides us with different FCP Implementations FAQ and step.
612
+
613
+ 154
614
+ 00:12:00,000 --> 00:12:03,000
615
+ It is just a few libraries in fact.
616
+
617
+ 155
618
+ 00:12:03,000 --> 00:12:09,000
619
+ There are much more of them that will be used for defense specific cases, but the principle of working
620
+
621
+ 156
622
+ 00:12:09,000 --> 00:12:14,000
623
+ with these libraries as a state, that means in case you would learn at least few libraries for integration
624
+
625
+ 157
626
+ 00:12:14,000 --> 00:12:20,000
627
+ testing, it will be like piece of cake to learn other libraries by just reading documentation.
628
+
629
+ 158
630
+ 00:12:20,000 --> 00:12:25,000
631
+ In this course, we are going to learn the most popular libraries for integration testing that you will
632
+
633
+ 159
634
+ 00:12:25,000 --> 00:12:32,000
635
+ use most often, especially for all my students are prepared examples for each topic and I walk you
636
+
637
+ 160
638
+ 00:12:32,000 --> 00:12:33,000
639
+ through all examples as we go.
640
+
641
+ 161
642
+ 00:12:34,000 --> 00:12:40,000
643
+ I believe that we learned a lot for today and you already can understand and imagine what integration
644
+
645
+ 162
646
+ 00:12:40,000 --> 00:12:40,000
647
+ testing is.
648
+
649
+ 163
650
+ 00:12:41,000 --> 00:12:46,000
651
+ The only thing that we still need to do is to learn how to use frameworks that are listed in the lesson.
652
+
653
+ 164
654
+ 00:12:47,000 --> 00:12:49,000
655
+ But we will do this in the next lessons.
656
+
657
+ 165
658
+ 00:12:49,000 --> 00:12:52,000
659
+ Right now, let's recap what we have learned today.
660
+
661
+ 166
662
+ 00:12:53,000 --> 00:12:56,000
663
+ In this lesson, we learned what integration testing is.
664
+
665
+ 167
666
+ 00:12:56,000 --> 00:13:01,000
667
+ We made a comparison of unit and integration testing to understand the difference better.
668
+
669
+ 168
670
+ 00:13:02,000 --> 00:13:07,000
671
+ After that, we learn the concept of test doubles and what types of test double's exist.
672
+
673
+ 169
674
+ 00:13:07,000 --> 00:13:13,000
675
+ We also learned why and when we need to use test numbers and we learn the advantages of working with
676
+
677
+ 170
678
+ 00:13:13,000 --> 00:13:13,000
679
+ them.
680
+
681
+ 171
682
+ 00:13:14,000 --> 00:13:20,000
683
+ I explain the different types of integration testing and we discussed different approaches during integration
684
+
685
+ 172
686
+ 00:13:20,000 --> 00:13:26,000
687
+ testing and at the end of the lesson we reviewed frameworks for Java that will help us to write integration
688
+
689
+ 173
690
+ 00:13:26,000 --> 00:13:27,000
691
+ tests.
692
+
693
+ 174
694
+ 00:13:27,000 --> 00:13:29,000
695
+ That said, hope you like the lesson.
696
+
697
+ 175
698
+ 00:13:30,000 --> 00:13:33,000
699
+ Thanks a lot for your attention and see you in the next lesson.
700
+
35 - Integration testing & Mockito/002 Byte-Buddy-agent-library.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy-agent/1.10.19
35 - Integration testing & Mockito/002 Byte-Buddy-library.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy/1.10.19
35 - Integration testing & Mockito/002 Mockito Part 1_en.srt ADDED
@@ -0,0 +1,1196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1
2
+ 00:00:05,000 --> 00:00:06,000
3
+ Hello, Jim.
4
+
5
+ 2
6
+ 00:00:06,000 --> 00:00:11,000
7
+ Glad to see you and this lesson and today we're going to start dive deeper into the details and learn
8
+
9
+ 3
10
+ 00:00:11,000 --> 00:00:13,000
11
+ framework for integration testing.
12
+
13
+ 4
14
+ 00:00:13,000 --> 00:00:18,000
15
+ Today, we learn McKetta will start from understanding what McKetta library is.
16
+
17
+ 5
18
+ 00:00:19,000 --> 00:00:24,000
19
+ After that, we are going to have a lot of real life examples that will help you to understand how to
20
+
21
+ 6
22
+ 00:00:24,000 --> 00:00:30,000
23
+ work with Makita API, but to make sure that you can write and run Makita tests will set up your environment
24
+
25
+ 7
26
+ 00:00:30,000 --> 00:00:34,000
27
+ first and will add Java libraries to class parts of your project.
28
+
29
+ 8
30
+ 00:00:34,000 --> 00:00:40,000
31
+ I will show you how to use Marketo extension for your unit to be able to work with Makita in your unit.
32
+
33
+ 9
34
+ 00:00:40,000 --> 00:00:46,000
35
+ Tests will create more books and in real life, examples will verify behavior on our marks.
36
+
37
+ 10
38
+ 00:00:46,000 --> 00:00:50,000
39
+ You will learn how much injection works in this lesson.
40
+
41
+ 11
42
+ 00:00:50,000 --> 00:00:56,000
43
+ I will show you how you can use argument marchers and what the specifics of using them in Makita tests
44
+
45
+ 12
46
+ 00:00:56,000 --> 00:00:57,000
47
+ for specific cases.
48
+
49
+ 13
50
+ 00:00:57,000 --> 00:01:03,000
51
+ I will show you how to stop exception when it will be needed and at the end of the lesson will learn
52
+
53
+ 14
54
+ 00:01:03,000 --> 00:01:04,000
55
+ how to work with argument.
56
+
57
+ 15
58
+ 00:01:04,000 --> 00:01:06,000
59
+ CAPTA, let's start.
60
+
61
+ 16
62
+ 00:01:07,000 --> 00:01:11,000
63
+ Makita is a library that is used during unioned and integration testing in Java applications.
64
+
65
+ 17
66
+ 00:01:12,000 --> 00:01:15,000
67
+ Makita is used to create Mock's based on the interfaces.
68
+
69
+ 18
70
+ 00:01:15,000 --> 00:01:22,000
71
+ With the help of this library, we can stop some great spice and does behavior during integration of
72
+
73
+ 19
74
+ 00:01:22,000 --> 00:01:23,000
75
+ different components.
76
+
77
+ 20
78
+ 00:01:23,000 --> 00:01:28,000
79
+ Makita has a really nice API that helps us to write nice and readable tasks.
80
+
81
+ 21
82
+ 00:01:29,000 --> 00:01:32,000
83
+ And today on real examples, I'm going to show you how to work with McKetta.
84
+
85
+ 22
86
+ 00:01:33,000 --> 00:01:36,000
87
+ Let's jump to Eclipse and not Makita on examples.
88
+
89
+ 23
90
+ 00:01:36,000 --> 00:01:42,000
91
+ I prepared real life example to help you understand the API before the Makita API.
92
+
93
+ 24
94
+ 00:01:43,000 --> 00:01:46,000
95
+ I will give you a context of our classes that we are going to test.
96
+
97
+ 25
98
+ 00:01:47,000 --> 00:01:49,000
99
+ Imagine that we have messenger class.
100
+
101
+ 26
102
+ 00:01:49,000 --> 00:01:53,000
103
+ This class aggregates template engine and mail server.
104
+
105
+ 27
106
+ 00:01:53,000 --> 00:01:59,000
107
+ Template engine is a type that can prepare content for your email message based on the template, and
108
+
109
+ 28
110
+ 00:01:59,000 --> 00:02:05,000
111
+ the client will take information from client object and pasted in the template and return ready to send
112
+
113
+ 29
114
+ 00:02:05,000 --> 00:02:06,000
115
+ message.
116
+
117
+ 30
118
+ 00:02:06,000 --> 00:02:12,000
119
+ You know this kind of emails that contains personalized information like your first and last name,
120
+
121
+ 31
122
+ 00:02:12,000 --> 00:02:13,000
123
+ for example.
124
+
125
+ 32
126
+ 00:02:13,000 --> 00:02:18,000
127
+ I didn't implement all logic here because for the sake of our market examples, that wouldn't mean a
128
+
129
+ 33
130
+ 00:02:18,000 --> 00:02:19,000
131
+ lot.
132
+
133
+ 34
134
+ 00:02:19,000 --> 00:02:25,000
135
+ So I'm one of you understand at least high level logic client is a regular object that can be created
136
+
137
+ 35
138
+ 00:02:25,000 --> 00:02:29,000
139
+ only with email and can return its email when needed.
140
+
141
+ 36
142
+ 00:02:29,000 --> 00:02:32,000
143
+ The next field in messenger type is email server.
144
+
145
+ 37
146
+ 00:02:32,000 --> 00:02:35,000
147
+ Object of this type has only one goal.
148
+
149
+ 38
150
+ 00:02:35,000 --> 00:02:41,000
151
+ Be able to send the message from specific person to the specific addressee with a personalized message
152
+
153
+ 39
154
+ 00:02:41,000 --> 00:02:49,000
155
+ content sent massive takes object of type email to send the message email object in our particular case
156
+
157
+ 40
158
+ 00:02:49,000 --> 00:02:51,000
159
+ has a message, content and address.
160
+
161
+ 41
162
+ 00:02:52,000 --> 00:02:56,000
163
+ We have getters and setters here for mail server and template engine.
164
+
165
+ 42
166
+ 00:02:56,000 --> 00:02:59,000
167
+ And here is our key message and messenger service.
168
+
169
+ 43
170
+ 00:02:59,000 --> 00:03:00,000
171
+ It is called Send Message.
172
+
173
+ 44
174
+ 00:03:01,000 --> 00:03:04,000
175
+ This method takes client object and template object.
176
+
177
+ 45
178
+ 00:03:04,000 --> 00:03:06,000
179
+ At the beginning we create message content.
180
+
181
+ 46
182
+ 00:03:06,000 --> 00:03:13,000
183
+ After that we create email object and set content and Andrassy to email and after that we call send
184
+
185
+ 47
186
+ 00:03:13,000 --> 00:03:14,000
187
+ with email object.
188
+
189
+ 48
190
+ 00:03:15,000 --> 00:03:17,000
191
+ Hope you understand the context.
192
+
193
+ 49
194
+ 00:03:17,000 --> 00:03:19,000
195
+ And now let me ask you a few questions.
196
+
197
+ 50
198
+ 00:03:19,000 --> 00:03:25,000
199
+ How would you test that when you call, send the message Masset on messenger then send message of mail
200
+
201
+ 51
202
+ 00:03:25,000 --> 00:03:30,000
203
+ server is invoked to be sure that integration between messenger and mail server works.
204
+
205
+ 52
206
+ 00:03:31,000 --> 00:03:36,000
207
+ How would you test that mail server is invoked with the email object that contains email that we get
208
+
209
+ 53
210
+ 00:03:36,000 --> 00:03:38,000
211
+ from the client object.
212
+
213
+ 54
214
+ 00:03:38,000 --> 00:03:44,000
215
+ And to be sure that this is not just a random email object, would you like to check when you call,
216
+
217
+ 55
218
+ 00:03:44,000 --> 00:03:48,000
219
+ send messages and prepare a message of template engine objects is invoked.
220
+
221
+ 56
222
+ 00:03:48,000 --> 00:03:52,000
223
+ Can you take a minute and think of different cases that you would like to test?
224
+
225
+ 57
226
+ 00:03:52,000 --> 00:03:58,000
227
+ We have to test interconnection behavior and how components behave in different cases based on different
228
+
229
+ 58
230
+ 00:03:58,000 --> 00:04:00,000
231
+ output of connected objects.
232
+
233
+ 59
234
+ 00:04:01,000 --> 00:04:07,000
235
+ Now, when we have the context about our system, let's write this with the help of the library and
236
+
237
+ 60
238
+ 00:04:07,000 --> 00:04:11,000
239
+ the first thing we have to do is to add external library to our project.
240
+
241
+ 61
242
+ 00:04:12,000 --> 00:04:17,000
243
+ If you so lesson about Holmquist, I already showed how to download the library from my own repository
244
+
245
+ 62
246
+ 00:04:17,000 --> 00:04:20,000
247
+ and edit as external library to the project.
248
+
249
+ 63
250
+ 00:04:20,000 --> 00:04:21,000
251
+ No, you have to do the same.
252
+
253
+ 64
254
+ 00:04:21,000 --> 00:04:26,000
255
+ But just download other libraries, find Marketo core and download library.
256
+
257
+ 65
258
+ 00:04:27,000 --> 00:04:32,000
259
+ You can download from Mavin Repository, have a live link to this library and the lesson attachments.
260
+
261
+ 66
262
+ 00:04:32,000 --> 00:04:38,000
263
+ So don't worry, you just have to download jar of the latest version and add it has external library
264
+
265
+ 67
266
+ 00:04:38,000 --> 00:04:38,000
267
+ to our project.
268
+
269
+ 68
270
+ 00:04:39,000 --> 00:04:42,000
271
+ Pay attention that this library has dependencies.
272
+
273
+ 69
274
+ 00:04:42,000 --> 00:04:45,000
275
+ Click on the compatible version and make sure you download it.
276
+
277
+ 70
278
+ 00:04:45,000 --> 00:04:48,000
279
+ Also these libraries and added them to a class.
280
+
281
+ 71
282
+ 00:04:49,000 --> 00:04:54,000
283
+ In this particular lesson, we are not using the building tools that will significantly help us with
284
+
285
+ 72
286
+ 00:04:54,000 --> 00:04:59,000
287
+ managing dependencies, but we will learn this bill to use a little bit later in our course.
288
+
289
+ 73
290
+ 00:04:59,000 --> 00:05:03,000
291
+ Also, besides this libraries, please download my Kitajima.
292
+
293
+ 74
294
+ 00:05:03,000 --> 00:05:08,000
295
+ Jupiter Library, all links, you will find interesting attachments, so don't worry about that.
296
+
297
+ 75
298
+ 00:05:09,000 --> 00:05:15,000
299
+ I have added all these jurors to the glass parts of my project, and now we can proceed with the examples.
300
+
301
+ 76
302
+ 00:05:16,000 --> 00:05:21,000
303
+ Here's our test, you know, where you can see a lot of different annotations, but don't worry, we'll
304
+
305
+ 77
306
+ 00:05:21,000 --> 00:05:23,000
307
+ learn all of them gradually as we go.
308
+
309
+ 78
310
+ 00:05:24,000 --> 00:05:25,000
311
+ Let's create our first test.
312
+
313
+ 79
314
+ 00:05:26,000 --> 00:05:27,000
315
+ We want to test it.
316
+
317
+ 80
318
+ 00:05:27,000 --> 00:05:33,000
319
+ Mansehra will actually send email when I will call, send a message message on my messenger object.
320
+
321
+ 81
322
+ 00:05:33,000 --> 00:05:34,000
323
+ Let's write this test.
324
+
325
+ 82
326
+ 00:05:35,000 --> 00:05:41,000
327
+ For the first test, I have to create concerns for some text message and some random email in my condition.
328
+
329
+ 83
330
+ 00:05:41,000 --> 00:05:45,000
331
+ Part of the test I create client object was a random email.
332
+
333
+ 84
334
+ 00:05:45,000 --> 00:05:49,000
335
+ Also, I create some template object to use it during the testing.
336
+
337
+ 85
338
+ 00:05:50,000 --> 00:05:54,000
339
+ After that, I want to create a stop for this specific test.
340
+
341
+ 86
342
+ 00:05:54,000 --> 00:06:00,000
343
+ I want to imitate the next scenario when prepare message will be called on template engine object with
344
+
345
+ 87
346
+ 00:06:00,000 --> 00:06:02,000
347
+ a specific template and with my client.
348
+
349
+ 88
350
+ 00:06:02,000 --> 00:06:05,000
351
+ Then I will return some random message.
352
+
353
+ 89
354
+ 00:06:05,000 --> 00:06:12,000
355
+ Important thing here is to understand that after this line, no matter how much time someone will prepare
356
+
357
+ 90
358
+ 00:06:12,000 --> 00:06:17,000
359
+ a message with these objects, I will get these random message for all other arguments.
360
+
361
+ 91
362
+ 00:06:17,000 --> 00:06:19,000
363
+ Template engine will return now.
364
+
365
+ 92
366
+ 00:06:19,000 --> 00:06:26,000
367
+ In other words, the default value for type that is returned from this method for all reference types.
368
+
369
+ 93
370
+ 00:06:26,000 --> 00:06:28,000
371
+ This value is now here.
372
+
373
+ 94
374
+ 00:06:28,000 --> 00:06:29,000
375
+ I left a command line.
376
+
377
+ 95
378
+ 00:06:29,000 --> 00:06:35,000
379
+ When you get the source code, you can uncommon this line to make sure what is returned after this method
380
+
381
+ 96
382
+ 00:06:35,000 --> 00:06:37,000
383
+ and location with new parameters.
384
+
385
+ 97
386
+ 00:06:38,000 --> 00:06:40,000
387
+ But let's stop on this line before moving further.
388
+
389
+ 98
390
+ 00:06:41,000 --> 00:06:44,000
391
+ Let me explain to you what is happening here.
392
+
393
+ 99
394
+ 00:06:44,000 --> 00:06:49,000
395
+ When is a static method from Makita class to stop massas on UniMac?
396
+
397
+ 100
398
+ 00:06:49,000 --> 00:06:54,000
399
+ Pay attention that on the top of my file I need a static input of everything.
400
+
401
+ 101
402
+ 00:06:54,000 --> 00:06:55,000
403
+ What is inside my class?
404
+
405
+ 102
406
+ 00:06:56,000 --> 00:07:00,000
407
+ That's why I can call one method without specifying much the class name.
408
+
409
+ 103
410
+ 00:07:00,000 --> 00:07:04,000
411
+ The next thing I have here is a method and location on mock object.
412
+
413
+ 104
414
+ 00:07:04,000 --> 00:07:08,000
415
+ Based on this, we need to have AMOC from the previous class.
416
+
417
+ 105
418
+ 00:07:08,000 --> 00:07:13,000
419
+ And you already know that Mock allows us to test behavior during the interaction with other components.
420
+
421
+ 106
422
+ 00:07:13,000 --> 00:07:20,000
423
+ For example, we will do this in the next lines, but at this very moment we need to stop specific behavior.
424
+
425
+ 107
426
+ 00:07:21,000 --> 00:07:25,000
427
+ Why I need to start behavior and why I just can't use real object.
428
+
429
+ 108
430
+ 00:07:25,000 --> 00:07:29,000
431
+ Well, there are different reasons why we might want to do like this.
432
+
433
+ 109
434
+ 00:07:29,000 --> 00:07:31,000
435
+ The first reason is the simplest one.
436
+
437
+ 110
438
+ 00:07:32,000 --> 00:07:37,000
439
+ By the moment you write this test, you don't have any implementation of template engine at all.
440
+
441
+ 111
442
+ 00:07:38,000 --> 00:07:42,000
443
+ The only thing what you have is interface of type, template engine.
444
+
445
+ 112
446
+ 00:07:43,000 --> 00:07:48,000
447
+ And implementation of this interface is in progress by as a developer from your team, for example,
448
+
449
+ 113
450
+ 00:07:48,000 --> 00:07:53,000
451
+ the second reason to stop MassArt on the mark is that you are going to perform a lot of different tasks
452
+
453
+ 114
454
+ 00:07:54,000 --> 00:07:59,000
455
+ and you want to reproduce different cases to understand how program behaves based on the different state
456
+
457
+ 115
458
+ 00:07:59,000 --> 00:08:02,000
459
+ of other components that it interacting with.
460
+
461
+ 116
462
+ 00:08:02,000 --> 00:08:08,000
463
+ It is a good way to test edge values and all classes of equivalent probably have the one question in
464
+
465
+ 117
466
+ 00:08:08,000 --> 00:08:11,000
467
+ a hat how to create mock.
468
+
469
+ 118
470
+ 00:08:11,000 --> 00:08:13,000
471
+ There are different ways to create more energy.
472
+
473
+ 119
474
+ 00:08:13,000 --> 00:08:20,000
475
+ And for Energy Unit five, I wrote and commented all possible ways to create more so you can use this
476
+
477
+ 120
478
+ 00:08:20,000 --> 00:08:22,000
479
+ file as a cheat sheet in the future.
480
+
481
+ 121
482
+ 00:08:22,000 --> 00:08:28,000
483
+ The first way to create more is to call Mauck method from Makita class and pass the user interface with
484
+
485
+ 122
486
+ 00:08:28,000 --> 00:08:30,000
487
+ specific class just like this.
488
+
489
+ 123
490
+ 00:08:31,000 --> 00:08:34,000
491
+ The second option is to use more connotation above the field that you want to mock.
492
+
493
+ 124
494
+ 00:08:35,000 --> 00:08:40,000
495
+ In this particular case, I have to put more concentration right above my field and now I have to call
496
+
497
+ 125
498
+ 00:08:41,000 --> 00:08:44,000
499
+ it Marks Masset from Makita annotations class and pass the reference.
500
+
501
+ 126
502
+ 00:08:44,000 --> 00:08:46,000
503
+ The object of this test class.
504
+
505
+ 127
506
+ 00:08:47,000 --> 00:08:50,000
507
+ If you would use this method, you would find that it works just perfect.
508
+
509
+ 128
510
+ 00:08:51,000 --> 00:08:55,000
511
+ But developers of the library consider this method as deprecated.
512
+
513
+ 129
514
+ 00:08:55,000 --> 00:08:57,000
515
+ I would dive into the details.
516
+
517
+ 130
518
+ 00:08:57,000 --> 00:08:59,000
519
+ Why exactly they marked it as deprecated?
520
+
521
+ 131
522
+ 00:09:00,000 --> 00:09:04,000
523
+ Because probably it wouldn't mean a lot for us right now what they recommend to use.
524
+
525
+ 132
526
+ 00:09:04,000 --> 00:09:10,000
527
+ Instead, it is recommended to use open source method, it turns out to closable.
528
+
529
+ 133
530
+ 00:09:10,000 --> 00:09:15,000
531
+ I saw this reference in a variable and in after each method I close it.
532
+
533
+ 134
534
+ 00:09:15,000 --> 00:09:18,000
535
+ You can use this option if you wish and last.
536
+
537
+ 135
538
+ 00:09:18,000 --> 00:09:23,000
539
+ But most convenient option, in my opinion, is to use Makita extension for Unit five.
540
+
541
+ 136
542
+ 00:09:24,000 --> 00:09:30,000
543
+ We have to place extant with annotation above our class and pass the class of McKetta extension.
544
+
545
+ 137
546
+ 00:09:30,000 --> 00:09:36,000
547
+ Make sure that your implicit all library is to a class pass properly was all necessary dependencies.
548
+
549
+ 138
550
+ 00:09:36,000 --> 00:09:41,000
551
+ In case you use this extension, you shouldn't use any static methods that I would just share it with
552
+
553
+ 139
554
+ 00:09:41,000 --> 00:09:42,000
555
+ you.
556
+
557
+ 140
558
+ 00:09:42,000 --> 00:09:48,000
559
+ This is pretty convenient, in my opinion, in jail for you to use special rounds that is called market.
560
+
561
+ 141
562
+ 00:09:48,000 --> 00:09:52,000
563
+ As a unit runner, we would use Macchi through all the options.
564
+
565
+ 142
566
+ 00:09:52,000 --> 00:09:53,000
567
+ Works fine.
568
+
569
+ 143
570
+ 00:09:53,000 --> 00:09:58,000
571
+ Just on the matter of your current style and specifics of your test, how exactly you would like to
572
+
573
+ 144
574
+ 00:09:58,000 --> 00:10:04,000
575
+ initialize mops, but now you know all possible ways to create Mock's, that is for sure.
576
+
577
+ 145
578
+ 00:10:05,000 --> 00:10:06,000
579
+ Also, one more thing.
580
+
581
+ 146
582
+ 00:10:06,000 --> 00:10:12,000
583
+ It is a rule of thumb to specify that some specific object is a mark by adding more suffix to a variable
584
+
585
+ 147
586
+ 00:10:12,000 --> 00:10:13,000
587
+ name like this.
588
+
589
+ 148
590
+ 00:10:14,000 --> 00:10:20,000
591
+ So now when you know how to create marks in test with the help of McKetta, let's get back to the place
592
+
593
+ 149
594
+ 00:10:20,000 --> 00:10:22,000
595
+ where we stopped here.
596
+
597
+ 150
598
+ 00:10:22,000 --> 00:10:28,000
599
+ In one method, I could prepare a message on my mark and pass specific client and specific template.
600
+
601
+ 151
602
+ 00:10:29,000 --> 00:10:35,000
603
+ And after that I call Zenovich on MassArt and I pass the value that has compatable.
604
+
605
+ 152
606
+ 00:10:35,000 --> 00:10:41,000
607
+ I was returned value of prepared message Massett, this is a value that I expect to be returned by my
608
+
609
+ 153
610
+ 00:10:41,000 --> 00:10:45,000
611
+ Molk when I will call prepare a message with this client and this template.
612
+
613
+ 154
614
+ 00:10:46,000 --> 00:10:47,000
615
+ Let's perform some action.
616
+
617
+ 155
618
+ 00:10:47,000 --> 00:10:50,000
619
+ We call, send a message message on our messenger object.
620
+
621
+ 156
622
+ 00:10:50,000 --> 00:10:54,000
623
+ I put the same client and template that I used during Stahmann.
624
+
625
+ 157
626
+ 00:10:55,000 --> 00:10:57,000
627
+ Now it is time to perform verifications.
628
+
629
+ 158
630
+ 00:10:58,000 --> 00:11:04,000
631
+ The first things that I wanted to test is that after call send message Zapopan message method of template
632
+
633
+ 159
634
+ 00:11:04,000 --> 00:11:11,000
635
+ engine is code with the same client and template that I used to send message and location.
636
+
637
+ 160
638
+ 00:11:11,000 --> 00:11:18,000
639
+ How to do that I call static Masset verified from McKetta class and I pass mark of template engine that
640
+
641
+ 161
642
+ 00:11:19,000 --> 00:11:22,000
643
+ you already saw how I initialized Mauck of template engine.
644
+
645
+ 162
646
+ 00:11:23,000 --> 00:11:28,000
647
+ The most interesting part is how to test integration between messenger and template engine.
648
+
649
+ 163
650
+ 00:11:29,000 --> 00:11:35,000
651
+ It sounds like a good idea to inject template engine into the messenger object to make sure that it
652
+
653
+ 164
654
+ 00:11:35,000 --> 00:11:37,000
655
+ uses exactly smok.
656
+
657
+ 165
658
+ 00:11:38,000 --> 00:11:43,000
659
+ This will help me to come up with the right conclusion about integration between these two modules.
660
+
661
+ 166
662
+ 00:11:43,000 --> 00:11:48,000
663
+ How to do that with McKetta, would you a field of type messenger?
664
+
665
+ 167
666
+ 00:11:48,000 --> 00:11:53,000
667
+ That would be our test instance and I would inject more connotation right above this field.
668
+
669
+ 168
670
+ 00:11:54,000 --> 00:11:54,000
671
+ What does it mean?
672
+
673
+ 169
674
+ 00:11:55,000 --> 00:12:01,000
675
+ First of all, object of this type will be created and all models that are declared in this test class
676
+
677
+ 170
678
+ 00:12:01,000 --> 00:12:07,000
679
+ and that are at the same time compatible with the fields declared in messenger type will be injected
680
+
681
+ 171
682
+ 00:12:07,000 --> 00:12:07,000
683
+ there.
684
+
685
+ 172
686
+ 00:12:08,000 --> 00:12:11,000
687
+ Let me show you my messenger class has two fields.
688
+
689
+ 173
690
+ 00:12:11,000 --> 00:12:16,000
691
+ One field is of type template engine and the second field is of type server.
692
+
693
+ 174
694
+ 00:12:17,000 --> 00:12:19,000
695
+ OK, let's get back to our test class.
696
+
697
+ 175
698
+ 00:12:19,000 --> 00:12:23,000
699
+ In our test class, I have most of template engine in the mail server.
700
+
701
+ 176
702
+ 00:12:24,000 --> 00:12:30,000
703
+ This means that these two marks will be injected in this object market is smart enough to understand
704
+
705
+ 177
706
+ 00:12:30,000 --> 00:12:37,000
707
+ this and it takes care about this that tries to perform an action with the help of the setters.
708
+
709
+ 178
710
+ 00:12:37,000 --> 00:12:44,000
711
+ But even in case there are no setters, Makita will try to inject it with the constructor and even Zano
712
+
713
+ 179
714
+ 00:12:44,000 --> 00:12:46,000
715
+ constructor was all necessary fields.
716
+
717
+ 180
718
+ 00:12:46,000 --> 00:12:53,000
719
+ Makita will use mechanism of reflection and inject these marks a bit later in this course will be on
720
+
721
+ 181
722
+ 00:12:53,000 --> 00:12:57,000
723
+ reflection mechanism so that you would also be able to create your own McKetta.
724
+
725
+ 182
726
+ 00:12:58,000 --> 00:13:04,000
727
+ I believe you understand that these two marks will be injected in our test instance, and I want to
728
+
729
+ 183
730
+ 00:13:04,000 --> 00:13:08,000
731
+ verify that repair method was invoked on template and an object.
732
+
733
+ 184
734
+ 00:13:08,000 --> 00:13:11,000
735
+ Moakes, allow me to verify the behavior.
736
+
737
+ 185
738
+ 00:13:11,000 --> 00:13:17,000
739
+ So in my test, after passing Mark to verify method, I invoke repair method with a specific arguments
740
+
741
+ 186
742
+ 00:13:17,000 --> 00:13:24,000
743
+ that I expect to be there, for example, in case I would pass here new object of client, not the one
744
+
745
+ 187
746
+ 00:13:24,000 --> 00:13:26,000
747
+ I used during the send message invocation.
748
+
749
+ 188
750
+ 00:13:27,000 --> 00:13:30,000
751
+ The test will fail and this is supercool.
752
+
753
+ 189
754
+ 00:13:30,000 --> 00:13:34,000
755
+ Can you see how I test interconnection between two classes?
756
+
757
+ 190
758
+ 00:13:34,000 --> 00:13:37,000
759
+ I checked after passing arguments to one class.
760
+
761
+ 191
762
+ 00:13:37,000 --> 00:13:40,000
763
+ The method of another class was exactly the same.
764
+
765
+ 192
766
+ 00:13:40,000 --> 00:13:41,000
767
+ Arguments is invoked.
768
+
769
+ 193
770
+ 00:13:42,000 --> 00:13:48,000
771
+ What I can also test here, I can test that same method was invoked on my mind server, mock the same
772
+
773
+ 194
774
+ 00:13:48,000 --> 00:13:49,000
775
+ syntax.
776
+
777
+ 195
778
+ 00:13:49,000 --> 00:13:55,000
779
+ The only difference here is that I don't know what an object will be here because in my object is created
780
+
781
+ 196
782
+ 00:13:55,000 --> 00:13:56,000
783
+ inside the method.
784
+
785
+ 197
786
+ 00:13:57,000 --> 00:14:01,000
787
+ For the sake of this particular test, I don't care what object to send there.
788
+
789
+ 198
790
+ 00:14:02,000 --> 00:14:08,000
791
+ What I am interested in is to verify that method sent, was invoked, was actually an email.
792
+
793
+ 199
794
+ 00:14:09,000 --> 00:14:13,000
795
+ The new things that you can see here is that I called any it what is it.
796
+
797
+ 200
798
+ 00:14:14,000 --> 00:14:16,000
799
+ This is so called argument moccia.
800
+
801
+ 201
802
+ 00:14:17,000 --> 00:14:20,000
803
+ This is a static method that returns Makita argument moccia.
804
+
805
+ 202
806
+ 00:14:20,000 --> 00:14:22,000
807
+ Let me explain how this work.
808
+
809
+ 203
810
+ 00:14:23,000 --> 00:14:29,000
811
+ There may be cases when in our test we have to respond to a wider range of values of before and unknown
812
+
813
+ 204
814
+ 00:14:29,000 --> 00:14:30,000
815
+ values.
816
+
817
+ 205
818
+ 00:14:30,000 --> 00:14:34,000
819
+ Let's review the same test method, but with argument matchers.
820
+
821
+ 206
822
+ 00:14:34,000 --> 00:14:41,000
823
+ The first thing you can see that I use any method with other classes I can do this with any reference
824
+
825
+ 207
826
+ 00:14:41,000 --> 00:14:45,000
827
+ is Stipe's when I don't care about the actual value that is passed to the masses.
828
+
829
+ 208
830
+ 00:14:46,000 --> 00:14:52,000
831
+ There are also different modules that you can use some of them and string any Ayinde and in Dumble,
832
+
833
+ 209
834
+ 00:14:52,000 --> 00:14:56,000
835
+ any char, any boolean, at least any set, any map and so on.
836
+
837
+ 210
838
+ 00:14:56,000 --> 00:15:00,000
839
+ You can just start typing any and look at the other suggestion.
840
+
841
+ 211
842
+ 00:15:00,000 --> 00:15:06,000
843
+ The important thing you have to remember here is that it is impossible to use arguments marchers for
844
+
845
+ 212
846
+ 00:15:06,000 --> 00:15:07,000
847
+ only few arguments.
848
+
849
+ 213
850
+ 00:15:07,000 --> 00:15:12,000
851
+ If you use arguments much for one argument, then you have to use it for all arguments.
852
+
853
+ 214
854
+ 00:15:13,000 --> 00:15:19,000
855
+ For example, in case you want to stop Massett invocation with specifying real client object and argument,
856
+
857
+ 215
858
+ 00:15:19,000 --> 00:15:23,000
859
+ much of a template marketable through an exception you can check.
860
+
861
+ 216
862
+ 00:15:24,000 --> 00:15:29,000
863
+ But what to do in case you want to use specific first argument and any argument of compatible type for
864
+
865
+ 217
866
+ 00:15:29,000 --> 00:15:30,000
867
+ the second argument.
868
+
869
+ 218
870
+ 00:15:31,000 --> 00:15:36,000
871
+ In this case, you have to use equal argument moccia in case you execute this statement.
872
+
873
+ 219
874
+ 00:15:36,000 --> 00:15:37,000
875
+ It will work as expected.
876
+
877
+ 220
878
+ 00:15:38,000 --> 00:15:42,000
879
+ Just pass objects that you want to use for equality verification.
880
+
881
+ 221
882
+ 00:15:42,000 --> 00:15:43,000
883
+ And that's it.
884
+
885
+ 222
886
+ 00:15:43,000 --> 00:15:44,000
887
+ That was easy.
888
+
889
+ 223
890
+ 00:15:44,000 --> 00:15:45,000
891
+ I agree.
892
+
893
+ 224
894
+ 00:15:46,000 --> 00:15:51,000
895
+ Also, Makita provides other marchers like is a that takes some classes.
896
+
897
+ 225
898
+ 00:15:51,000 --> 00:15:54,000
899
+ An argument is now is not null marches.
900
+
901
+ 226
902
+ 00:15:54,000 --> 00:15:57,000
903
+ That takes regular expression as an argument.
904
+
905
+ 227
906
+ 00:15:57,000 --> 00:15:58,000
907
+ Is that clear.
908
+
909
+ 228
910
+ 00:15:58,000 --> 00:16:04,000
911
+ A lot of marches are self-described Mezquita developers did a great job by providing us with a library
912
+
913
+ 229
914
+ 00:16:04,000 --> 00:16:06,000
915
+ that can help us to create readable tests.
916
+
917
+ 230
918
+ 00:16:07,000 --> 00:16:13,000
919
+ Are the important things to remember is that you can't use argument marchers as a return on values and
920
+
921
+ 231
922
+ 00:16:13,000 --> 00:16:15,000
923
+ exact value is required here.
924
+
925
+ 232
926
+ 00:16:15,000 --> 00:16:20,000
927
+ And also you can't use argument much outside of verification or STEINMANN.
928
+
929
+ 233
930
+ 00:16:20,000 --> 00:16:25,000
931
+ That is the raftis argument marchers were often in the past.
932
+
933
+ 234
934
+ 00:16:25,000 --> 00:16:31,000
935
+ My personal opinion is that in the case you use argument marcha in your test, that means you don't
936
+
937
+ 235
938
+ 00:16:31,000 --> 00:16:33,000
939
+ care about arguments for this specific test case.
940
+
941
+ 236
942
+ 00:16:34,000 --> 00:16:37,000
943
+ My personal opinion, again, this is ridiculous.
944
+
945
+ 237
946
+ 00:16:37,000 --> 00:16:42,000
947
+ In case you don't care about arguments in your test case, then why you should care about this test
948
+
949
+ 238
950
+ 00:16:42,000 --> 00:16:43,000
951
+ at all.
952
+
953
+ 239
954
+ 00:16:43,000 --> 00:16:44,000
955
+ Just remove it.
956
+
957
+ 240
958
+ 00:16:44,000 --> 00:16:45,000
959
+ It doesn't matter.
960
+
961
+ 241
962
+ 00:16:45,000 --> 00:16:52,000
963
+ Well, using marchers is so popular across developers, I can't hide my misunderstanding of using them
964
+
965
+ 242
966
+ 00:16:52,000 --> 00:16:57,000
967
+ because in the test I want to make sure that I control my test flow from the beginning to the end,
968
+
969
+ 243
970
+ 00:16:58,000 --> 00:17:04,000
971
+ including all arguments that my impact on behavior of my unit or on interaction between my units.
972
+
973
+ 244
974
+ 00:17:04,000 --> 00:17:09,000
975
+ So it is up to you as a to use argument munchers and my case a test and how often to use them.
976
+
977
+ 245
978
+ 00:17:09,000 --> 00:17:14,000
979
+ But you know, my opinion, OK, probably this is time to move to our next test.
980
+
981
+ 246
982
+ 00:17:15,000 --> 00:17:20,000
983
+ Now, I want to test it in case for some reason, Template Engine will throw a legal argument exception
984
+
985
+ 247
986
+ 00:17:20,000 --> 00:17:23,000
987
+ send message method won't be executed till the end.
988
+
989
+ 248
990
+ 00:17:23,000 --> 00:17:24,000
991
+ How to verify this?
992
+
993
+ 249
994
+ 00:17:25,000 --> 00:17:29,000
995
+ I already have template engine mock injected into my messenger object.
996
+
997
+ 250
998
+ 00:17:29,000 --> 00:17:34,000
999
+ So the only thing I have to do now is to stop, prepare a message and make sure that it was through.
1000
+
1001
+ 251
1002
+ 00:17:34,000 --> 00:17:35,000
1003
+ And the legal argument exception.
1004
+
1005
+ 252
1006
+ 00:17:35,000 --> 00:17:39,000
1007
+ When I work, prepare a message, my assertion will test that.
1008
+
1009
+ 253
1010
+ 00:17:39,000 --> 00:17:43,000
1011
+ The legal argument exception is from when I call prepare a message.
1012
+
1013
+ 254
1014
+ 00:17:43,000 --> 00:17:50,000
1015
+ This test shows us that in case error happens in template engine, then messenger wouldn't work too.
1016
+
1017
+ 255
1018
+ 00:17:50,000 --> 00:17:53,000
1019
+ And we can't successfully verify this interaction.
1020
+
1021
+ 256
1022
+ 00:17:53,000 --> 00:17:56,000
1023
+ Now, one of the most interesting tests.
1024
+
1025
+ 257
1026
+ 00:17:56,000 --> 00:17:57,000
1027
+ Let's now test and even.
1028
+
1029
+ 258
1030
+ 00:17:58,000 --> 00:18:04,000
1031
+ It was created instant message Macit, I want to be sure that client's email address is set to email
1032
+
1033
+ 259
1034
+ 00:18:04,000 --> 00:18:12,000
1035
+ object and underseas is correct, but not just a random one, but how I would tell this if email object
1036
+
1037
+ 260
1038
+ 00:18:12,000 --> 00:18:18,000
1039
+ is created inside the send message, how to get access to it to provide us with amazing tools, that
1040
+
1041
+ 261
1042
+ 00:18:18,000 --> 00:18:19,000
1043
+ is called argument.
1044
+
1045
+ 262
1046
+ 00:18:19,000 --> 00:18:25,000
1047
+ Capturing this tool allows us to capture arguments that was passed during the massive invocation and
1048
+
1049
+ 263
1050
+ 00:18:25,000 --> 00:18:27,000
1051
+ after that to be able to verify its state.
1052
+
1053
+ 264
1054
+ 00:18:28,000 --> 00:18:29,000
1055
+ Let me show you how to do this.
1056
+
1057
+ 265
1058
+ 00:18:30,000 --> 00:18:34,000
1059
+ The first thing we have to do is to declare a field of special type in our test.
1060
+
1061
+ 266
1062
+ 00:18:34,000 --> 00:18:37,000
1063
+ This type is called argument capture.
1064
+
1065
+ 267
1066
+ 00:18:37,000 --> 00:18:41,000
1067
+ It is parametrized by the type that we want to capture in the argument.
1068
+
1069
+ 268
1070
+ 00:18:42,000 --> 00:18:47,000
1071
+ And that's the important thing here, is to use special annotation to tell Makita that this is an object
1072
+
1073
+ 269
1074
+ 00:18:47,000 --> 00:18:48,000
1075
+ that will capture arguments.
1076
+
1077
+ 270
1078
+ 00:18:49,000 --> 00:18:52,000
1079
+ And you can see I have capture annotation here.
1080
+
1081
+ 271
1082
+ 00:18:52,000 --> 00:18:57,000
1083
+ Now we are going to proceed the first part of this test we have already discussed.
1084
+
1085
+ 272
1086
+ 00:18:57,000 --> 00:18:59,000
1087
+ Let's focus on the assertion part.
1088
+
1089
+ 273
1090
+ 00:18:59,000 --> 00:19:06,000
1091
+ I also verify that message was invoked and after that I will fight that sent method of mail server object
1092
+
1093
+ 274
1094
+ 00:19:06,000 --> 00:19:07,000
1095
+ was called.
1096
+
1097
+ 275
1098
+ 00:19:07,000 --> 00:19:14,000
1099
+ And instead of parsing arguments much easier, I object of my capture and kill capture method so that
1100
+
1101
+ 276
1102
+ 00:19:14,000 --> 00:19:19,000
1103
+ it could capture arguments that was passed to this method during the runtime.
1104
+
1105
+ 277
1106
+ 00:19:19,000 --> 00:19:26,000
1107
+ After a captured argument, I can extract the value from my capture my colon, get value Massett and
1108
+
1109
+ 278
1110
+ 00:19:26,000 --> 00:19:27,000
1111
+ that's it.
1112
+
1113
+ 279
1114
+ 00:19:27,000 --> 00:19:33,000
1115
+ Now I have reference to email object that was created inside the method and I can get and receive from
1116
+
1117
+ 280
1118
+ 00:19:33,000 --> 00:19:39,000
1119
+ this object and compare it was expected value and expect its value would be clients.
1120
+
1121
+ 281
1122
+ 00:19:39,000 --> 00:19:39,000
1123
+ Email.
1124
+
1125
+ 282
1126
+ 00:19:40,000 --> 00:19:42,000
1127
+ How do you feel the like Makita.
1128
+
1129
+ 283
1130
+ 00:19:42,000 --> 00:19:45,000
1131
+ I'm glad that we started this topic with you.
1132
+
1133
+ 284
1134
+ 00:19:45,000 --> 00:19:51,000
1135
+ We still have a lot of things to learn, including advanced McKetta features, but I suggest to call
1136
+
1137
+ 285
1138
+ 00:19:51,000 --> 00:19:53,000
1139
+ it today and proceed in the next lesson.
1140
+
1141
+ 286
1142
+ 00:19:54,000 --> 00:19:57,000
1143
+ Right now, let's recap what we have learned today.
1144
+
1145
+ 287
1146
+ 00:19:57,000 --> 00:19:58,000
1147
+ In this lesson.
1148
+
1149
+ 288
1150
+ 00:19:58,000 --> 00:20:04,000
1151
+ We learned what Markkula Library is and why we need it and in which cases we can figure it out.
1152
+
1153
+ 289
1154
+ 00:20:04,000 --> 00:20:07,000
1155
+ Development environment to be able to use Makita.
1156
+
1157
+ 290
1158
+ 00:20:07,000 --> 00:20:09,000
1159
+ You learned all necessary libraries.
1160
+
1161
+ 291
1162
+ 00:20:09,000 --> 00:20:12,000
1163
+ You have to add to your project to use Marketo features.
1164
+
1165
+ 292
1166
+ 00:20:12,000 --> 00:20:15,000
1167
+ Now you know how to use Marketo extension for your unit.
1168
+
1169
+ 293
1170
+ 00:20:16,000 --> 00:20:20,000
1171
+ I showed you how to create Mok's in your test and verify their behavior.
1172
+
1173
+ 294
1174
+ 00:20:20,000 --> 00:20:26,000
1175
+ With the help of tutor on real life examples, you saw how to inject more to our test instance.
1176
+
1177
+ 295
1178
+ 00:20:26,000 --> 00:20:32,000
1179
+ Also, you learned how to use different argument matchers and at the end of the lesson you saw how to
1180
+
1181
+ 296
1182
+ 00:20:32,000 --> 00:20:37,000
1183
+ use argument capture to capture arguments that are to our marks during the runtime.
1184
+
1185
+ 297
1186
+ 00:20:37,000 --> 00:20:38,000
1187
+ That's it for today.
1188
+
1189
+ 298
1190
+ 00:20:39,000 --> 00:20:40,000
1191
+ Thanks a lot for your attention.
1192
+
1193
+ 299
1194
+ 00:20:40,000 --> 00:20:43,000
1195
+ Have a great day and see you in the next lesson.
1196
+
35 - Integration testing & Mockito/002 Mockito-JUnit-Jupiter.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter/3.7.7
35 - Integration testing & Mockito/002 Mockito-core-library.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://mvnrepository.com/artifact/org.mockito/mockito-core/3.7.7
35 - Integration testing & Mockito/002 Objenesis-library.url ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [InternetShortcut]
2
+ URL=https://mvnrepository.com/artifact/org.objenesis/objenesis/3.1