1
00:00:00,180 --> 00:00:05,970
Hi, guys, my name is Karthik and I am from Automation Dotcom, and welcome to part 22 of our API testing

2
00:00:05,970 --> 00:00:07,510
with the and Australian workforce.

3
00:00:07,830 --> 00:00:12,900
And in this video, we're going to talk about contract API testing with a pattern using Lombok.

4
00:00:13,050 --> 00:00:18,360
And before writing this part, I would strongly recommend to watch Part 21 because this video is going

5
00:00:18,360 --> 00:00:23,520
to be a complete continuation of our previous video, Lombok Project.

6
00:00:23,520 --> 00:00:30,120
Lombok Spillar is a useful mechanism for using builder pattern without writing boilerplate code, and

7
00:00:30,120 --> 00:00:34,070
we can apply this annotation to a class or even a method.

8
00:00:34,470 --> 00:00:37,440
And again, guys, if you remember in our previous videos, No.

9
00:00:37,460 --> 00:00:44,310
Part 21 video we wrote and discussed about builder pattern and we saw the importance of having builder

10
00:00:44,310 --> 00:00:49,980
pattern and how it eliminates the problem with the telescopic constructors, with the poggio classes.

11
00:00:50,370 --> 00:00:56,930
But we also saw that there was a lot of boilerplate cause like you can write a static builder class

12
00:00:56,940 --> 00:01:01,840
and then you can write the getters and set an operation for each and every podell classes.

13
00:01:02,100 --> 00:01:06,960
So if the object is going to be very, very complex, then you probably have to write the same kind

14
00:01:06,960 --> 00:01:13,980
of code for each and every poggio classes that makes or introduce a lot of boilerplate code writing.

15
00:01:14,250 --> 00:01:20,190
And that is the reason this Lombok plugin is going to be very, very handy, because the Lumberg plugin

16
00:01:20,190 --> 00:01:24,240
gives a way that how you can reduce it by coding.

17
00:01:24,400 --> 00:01:31,290
So the first and foremost thing that we been doing for working with Lumberg plugin is to install the

18
00:01:31,290 --> 00:01:35,250
Lumberg itself, as you can see in here, as a Mabon dependency.

19
00:01:35,670 --> 00:01:43,010
So once we install this Lumberg plugin, but then can also install the plugin within our intelligent

20
00:01:43,020 --> 00:01:45,730
idy or any idea of your choice.

21
00:01:45,780 --> 00:01:51,990
So this way it reduces so much of the coding that you are currently doing in the existing core business

22
00:01:51,990 --> 00:01:53,770
that we are discussing in our previous video.

23
00:01:53,880 --> 00:01:58,950
So the current Podio class for the pause that we have is going to look something like this.

24
00:01:59,430 --> 00:02:05,730
As you can see, we have a post class and then we also have a better class and then we call this particular

25
00:02:05,730 --> 00:02:08,490
code in our code and we worked with it.

26
00:02:08,490 --> 00:02:15,630
But we also know that in our earlier videos, we had complex classes like address and locations and

27
00:02:15,630 --> 00:02:16,440
things of that nature.

28
00:02:16,710 --> 00:02:23,100
But now in order to simplify things for the post class, if we install this particular beta pattern,

29
00:02:23,340 --> 00:02:30,830
the only two annotation that we need to be using is the add data and add builder for the first class.

30
00:02:31,050 --> 00:02:31,940
That's it.

31
00:02:32,640 --> 00:02:38,850
This is the only thing that we need to be doing within our code or within our Poggio class, and that

32
00:02:38,850 --> 00:02:44,730
where this is going to eliminate so much of our coding that we are doing all these days.

33
00:02:44,730 --> 00:02:53,460
Guys, you can see that the code has now tremendously reduced from around 70 lines of code to just three

34
00:02:53,460 --> 00:02:55,920
lines of code or maybe five lines of code.

35
00:02:55,950 --> 00:02:56,450
That's it.

36
00:02:56,850 --> 00:02:59,970
This is the only thing that we need to be doing for our class.

37
00:03:00,180 --> 00:03:07,650
And this way it increases a lot of readability and removes the boilerplate code that we have written

38
00:03:07,650 --> 00:03:08,370
all these days.

39
00:03:08,730 --> 00:03:12,810
So let's quickly see everything in action and understand how things work so far that I'm not flip to

40
00:03:12,810 --> 00:03:14,850
my intelligent idee.

41
00:03:15,270 --> 00:03:15,720
All right.

42
00:03:15,720 --> 00:03:17,580
So now I'm an intelligent idee.

43
00:03:17,820 --> 00:03:25,410
And before I started this video, I have also installed the plugin within my intelligent ID.

44
00:03:25,500 --> 00:03:32,700
So if you go to the settings and then to the plugin, you can see that I have already installed the

45
00:03:32,730 --> 00:03:36,840
Lombok plugin, which I'm really not going to be doing as of now at this particular point.

46
00:03:37,110 --> 00:03:38,340
I'm just going to cancel that.

47
00:03:38,640 --> 00:03:43,560
But just make sure that you install this particular plugin with an intelligent idee so that you can

48
00:03:43,560 --> 00:03:44,460
start working with it.

49
00:03:44,850 --> 00:03:52,890
But within our project, with our Pumbaa XML file, we don't really have the Lumberg plugin Mabon dependency.

50
00:03:52,890 --> 00:03:56,820
So we need to somehow install Lumberg within our project as a dependency.

51
00:03:56,850 --> 00:04:07,530
So for doing that, I'm just going to go over here, I'm going to search for Lombok Mavin, this one.

52
00:04:07,770 --> 00:04:09,150
I think this is the latest version.

53
00:04:09,540 --> 00:04:15,360
I'm just gonna copy it and then I'm going to come all the way over here on this particular dependency,

54
00:04:15,630 --> 00:04:19,680
the same serried and you can see that the the dependency has been resolved.

55
00:04:20,040 --> 00:04:21,060
And there you go.

56
00:04:21,600 --> 00:04:26,070
So now we have this particular class with the builder class.

57
00:04:26,310 --> 00:04:32,910
So what I'm going to do is I'm just going to rename the speaker Podio class folder or the package so

58
00:04:32,910 --> 00:04:34,800
that I can make use of the builder pattern.

59
00:04:35,100 --> 00:04:38,850
And you can see that because I want to check in the code in the GitHub repo.

60
00:04:38,850 --> 00:04:41,010
This is going to create so much of confusion.

61
00:04:41,280 --> 00:04:48,110
So I'm just going to show this in an explorer and I'm going to make a copy of this.

62
00:04:48,190 --> 00:04:54,750
I'm it over here and I'm gonna call this aspergillus without further.

63
00:04:57,440 --> 00:05:02,480
And this is Podio with Better, the one which you have is going to be popular with Builder, basically

64
00:05:03,440 --> 00:05:08,950
leave it and we can see that we still have got these guys over here.

65
00:05:09,050 --> 00:05:10,850
So I'm just going to call this as possible.

66
00:05:11,450 --> 00:05:14,810
Let's rename this to Without Valdo.

67
00:05:15,020 --> 00:05:17,570
Copy this paste over here.

68
00:05:19,010 --> 00:05:21,850
And the address is OK.

69
00:05:21,890 --> 00:05:23,150
And the location.

70
00:05:25,030 --> 00:05:32,080
The posts and the login body, so you can see that this is going to be a separate package, which we

71
00:05:32,080 --> 00:05:33,570
are not going to be using at all.

72
00:05:33,580 --> 00:05:38,920
But just for your reference, because the students who are going to be learning the earlier videos are

73
00:05:38,920 --> 00:05:44,110
going to find this particular class missing within the GitHub repo just for their reference, like how

74
00:05:44,110 --> 00:05:45,780
we evolved with the speaker code.

75
00:05:45,970 --> 00:05:48,070
I'm just going to hold this guy as it is over here.

76
00:05:48,430 --> 00:05:53,440
But the code that we're going to be changing are these cards that you are seeing over here.

77
00:05:54,310 --> 00:05:57,700
So what I'm going to do is I'm going to use this particular builder pattern.

78
00:05:58,000 --> 00:06:06,550
So as I told you, the 50 lines of code or maybe fifty five lines of code is going to be completely

79
00:06:07,000 --> 00:06:08,170
synched into.

80
00:06:08,870 --> 00:06:12,400
As you can see here, that's the data.

81
00:06:12,940 --> 00:06:17,450
And you can see that it is telling me which particular dependence that it will be using.

82
00:06:17,920 --> 00:06:25,180
So I'm just going to hit all the enter and I'm going to use the Lembke Mabern dependency basically going

83
00:06:25,180 --> 00:06:25,720
to say it.

84
00:06:26,050 --> 00:06:29,650
And you can see that pretty much good to go now and now.

85
00:06:30,690 --> 00:06:35,400
If I go to the posts of this particular.

86
00:06:37,190 --> 00:06:43,310
Or you can see that it's showing us at this particular theater just fine, because we also need to add

87
00:06:43,820 --> 00:06:47,530
the at Baylor over here.

88
00:06:47,540 --> 00:06:51,560
So once I add this, if I go back in here.

89
00:06:53,170 --> 00:06:59,400
You can see that the Savar will now throw us an error, which is fine, but the builder that you can

90
00:06:59,410 --> 00:07:03,330
see in here is going to be this builder.

91
00:07:03,520 --> 00:07:10,080
So you can see that builders, builders actually coming from the Lumberg and the VA.

92
00:07:10,090 --> 00:07:12,790
I can change it to post, basically.

93
00:07:13,880 --> 00:07:20,150
And this one I can pertain to post as well, and you can see that this is throwing as an editor, the

94
00:07:20,150 --> 00:07:23,810
reason being I don't really have to use this particular new keyword in here.

95
00:07:24,560 --> 00:07:28,700
You can see that the court will now completely transform into something like this.

96
00:07:29,060 --> 00:07:33,080
And you may be wondering like what is the big deal with this particular piece of court and what's really

97
00:07:33,080 --> 00:07:33,560
happening?

98
00:07:33,830 --> 00:07:41,570
And you can see that within this particular assertions, I just called the post start, get out there

99
00:07:42,050 --> 00:07:44,360
and it is automatically coming as well.

100
00:07:44,480 --> 00:07:48,980
And within this picture, postcards, basically, I have not even written any of the letters or the

101
00:07:49,000 --> 00:07:54,290
SEDAR, but even if I hit the dot, you can see that it automatically brings me all the getters and

102
00:07:54,310 --> 00:07:54,840
setters.

103
00:07:55,460 --> 00:08:00,850
So how is this actually coming in with the Lombok plug in, how it is generating all these kind of steps?

104
00:08:01,250 --> 00:08:08,900
So basically, if you see the structure of this particular class, once they enter this particular data,

105
00:08:08,900 --> 00:08:17,720
it automatically added the get author and the set and also the builder's class over here, which is

106
00:08:17,720 --> 00:08:18,290
pretty cool.

107
00:08:18,850 --> 00:08:25,070
Now, let's say if I just remove this particular builder, you can see that the builder has been completely

108
00:08:25,070 --> 00:08:25,490
gone.

109
00:08:25,730 --> 00:08:33,040
And once I removed the data, you can see that it now becomes just like and class with just three properties.

110
00:08:33,290 --> 00:08:39,290
So the Lombok plugin actually generate all these cool stuff for us automatically with the plugin, which

111
00:08:39,290 --> 00:08:42,000
is which is already installed in our intelligent idee.

112
00:08:42,050 --> 00:08:45,680
And now this Lombok plug in is we are doing all the magic for us.

113
00:08:45,830 --> 00:08:49,940
And now how I can transform this code is going to be even more fascinating.

114
00:08:50,210 --> 00:08:57,890
So now if I just go back to my posts, I can even simplify this bigger piece of code, something like

115
00:08:57,890 --> 00:09:02,240
maybe I don't really even need to a better pattern because I don't really have to go through all those

116
00:09:02,600 --> 00:09:03,230
problems.

117
00:09:03,230 --> 00:09:10,310
Now, I just kind of call this book a postcard class, like how I used to do for the earlier core that

118
00:09:10,520 --> 00:09:12,200
which was that without builder pattern.

119
00:09:12,560 --> 00:09:15,530
So I can just call the same code here.

120
00:09:15,590 --> 00:09:19,490
Maybe I don't even require this book a piece of code from here.

121
00:09:19,760 --> 00:09:22,040
I can just call this a postcard get body.

122
00:09:24,260 --> 00:09:30,290
And then you can see that this particular code that we were using before is now going to be legal as

123
00:09:30,290 --> 00:09:32,100
well, which is pretty cool.

124
00:09:32,420 --> 00:09:38,090
So now I can just call the post class, but still it is going to use the same builder pattern.

125
00:09:38,360 --> 00:09:38,870
As you can see.

126
00:09:38,870 --> 00:09:45,320
It automatically brings that get author, get title, get it set author and surtitles and all that stuff,

127
00:09:45,890 --> 00:09:47,620
including the builder pattern.

128
00:09:48,230 --> 00:09:50,590
Now everything is working fine without any problem.

129
00:09:50,840 --> 00:09:51,190
Right.

130
00:09:51,440 --> 00:09:58,460
And now if I try to execute this particular piece of code, we will be getting an error here and you

131
00:09:58,460 --> 00:10:03,290
can see that it is going to tell us that there is no default constructor.

132
00:10:03,440 --> 00:10:10,700
As you can see, it is trying to bind and and it wouldn't be able to construct an instance of the Podio

133
00:10:10,700 --> 00:10:11,690
of the posts.

134
00:10:11,960 --> 00:10:17,240
So it's going to be the same matter that we discussed in our part 13 of this, cause we're just going

135
00:10:17,240 --> 00:10:23,120
to be adding a default constructor, but it doesn't really make any sense while using the Lombok plugin

136
00:10:23,120 --> 00:10:23,720
to do that.

137
00:10:24,020 --> 00:10:28,850
So basically, you can see that with the with the Podemos post class.

138
00:10:28,850 --> 00:10:34,370
We have used this builder pattern, but you don't really require it because you have not used any one

139
00:10:34,370 --> 00:10:36,680
of those option or hear it in our code.

140
00:10:36,890 --> 00:10:42,740
So probably you can just remove the builder alone because we're just using the getter and setter operation.

141
00:10:43,070 --> 00:10:47,890
We will talk about how we can even extend this accord with the builder pattern in our next video.

142
00:10:48,080 --> 00:10:52,940
But as of now, you can see that this particular code doesn't require that particular stuff.

143
00:10:53,210 --> 00:10:58,850
So I can probably just leave this guy as it is because I'm just going to call the get an operation.

144
00:10:58,850 --> 00:11:00,440
That's what I'm too much interested in.

145
00:11:00,710 --> 00:11:06,020
And now if I try to execute this bigger piece of code, you can see that the scenario got tested and

146
00:11:06,020 --> 00:11:08,310
the test has got passed, which is pretty cool.

147
00:11:08,720 --> 00:11:15,490
So this is how we can actually use the Lombok plugin to do a greater job for us.

148
00:11:15,740 --> 00:11:22,920
So this reduces too much of our codings that we were doing all these days so we can even reduce the

149
00:11:22,970 --> 00:11:27,230
dialogue in operation that we were doing before using the Lombok plugin.

150
00:11:27,410 --> 00:11:31,250
So I'm just going to get rid of this and I'm going to put the data.

151
00:11:31,790 --> 00:11:32,420
There you go.

152
00:11:32,930 --> 00:11:34,550
And use the.

153
00:11:37,470 --> 00:11:44,940
Used to Lombok, that's it, and you can see that it has been reduced tremendously and also I can use

154
00:11:44,940 --> 00:11:48,950
the Lombok for the location as well.

155
00:11:49,440 --> 00:11:50,820
So I'm not going to remove this.

156
00:11:51,110 --> 00:11:53,120
I'm going to put data here.

157
00:11:54,310 --> 00:12:01,720
That's it, and you can see that it's done and similarly for the address, I can remove all of them

158
00:12:02,650 --> 00:12:08,260
for here and I can put that data and there you go.

159
00:12:08,260 --> 00:12:08,720
So we're done.

160
00:12:08,920 --> 00:12:14,380
So now we have the address, location and body, very, very super simple called then compared to the

161
00:12:14,380 --> 00:12:17,650
code that we were writing so big all these days.

162
00:12:17,860 --> 00:12:18,180
Right.

163
00:12:18,490 --> 00:12:21,040
So this code is now reduced tremendously.

164
00:12:21,250 --> 00:12:26,650
And now if I tried to even execute the complex operation code over here.

165
00:12:28,240 --> 00:12:34,600
You can see that the test has got passed successfully, so this way you can see that we can reduce tremendous

166
00:12:34,600 --> 00:12:39,750
number of coatings using the Lombok plug in and with the Lumberg package itself.

167
00:12:39,760 --> 00:12:46,650
And this is a keen observer pattern as well, because he even farther with the situation, suffusing

168
00:12:46,660 --> 00:12:49,630
builder patterns, because we have not used that builder yet.

169
00:12:49,900 --> 00:12:55,000
We will be discussing about that, how we can set it in a body or maybe in the header, and then how

170
00:12:55,000 --> 00:12:57,970
we can extend that particular piece of code in much greater detail.

171
00:12:58,120 --> 00:13:01,510
So, once again, thank you very much watching this video and have a great day.

