Hi, everyone.
Welcome back.
In this lecture, we will build the risk line for the get up jobs API.
The very first thing is we are going to add the necessary dependencies and not build our file.
So I'm going to open the file.
As you can see, I have the builder open and here we are going to add the spring.
The client and Jackson dependencies into our build will find.
What I'm going to do is I have the necessary dependencies already available in my GitHub repo.
I'm going to go ahead and copy the dependencies from there.
There you go.
I'm back to my guitar profile.
This is my guitar profile.
And the repository that I'm in is parallel asynchronous using Java.
I'll be sharing the link as part of this lecture so that you can navigate to this particular GitHub
repo.
And in here I'm going to go inside the blogger file.
You'll find the necessary dependencies.
The very first thing is we need to switch to the final branch because final branch is where the complete
code will be available.
And in here you can see the client dependencies, which has two different dependencies.
Springle, Flux and Reactionary Reactionary is needed in order for the HDB client connection pool.
And number two, the Jackson dependencies, because behind the scenes of a client users these Jackson
dependencies in order to perform the serialization and dissolution of the payload that we are going
to receive via the rescue vehicle.
So let's copy this whole thing.
And then I'm going to put it in our blog.
So I'm back to my biological file and inclusion and paste this one, I would recommend you to refresh
this using this icon.
And it's going to pull all the dependencies from the Internet and have it set in your workspace.
As you can see, it's downloading all the different dependencies.
Once this is complete, then we will be able to use the spring.
The plaint.
The way you can verify this is by expanding this section libraries and then search for spring IFN the
flux.
So when you search for that phone, you will see some results matching the spring, the plugs dependency
that we just ordered.
As you can see, we have added the spring, the flux five point two point nine dot release.
That's what we see or hear.
Now we have the necessary dependencies to build a risk.
The next step, we are going to start writing code to build the Raskind.
Before I go ahead and jump into building this client, we need to have a representation of the GitHub
job API response, because if you go and take a look at the response, the response is going to be an
array of adjacent objects.
Right?
So I want to have a decent representation of this particular response object.
So what I did was I went ahead and created a class with the name of GitHub position, and it is under
the package of domain and you have a package named GitHub and you will find this GitHub position in
your workspace, too.
If you had downloaded the Mattea branch during the initial part of the course, then you will have this
domain object.
Also as part of the repository in here, we have all the necessary attributes that are needed by the
GitHub Jobs API.
And as you can see, if you look at it, we have the ID type.
You all you have all the necessary properties that are needed to map to that Jason response.
So now we have the dependencies ready.
And a class that represents the GitHub jobs API response is really the next thing is we are going to
start building the claim saying here I went ahead and created a package named App Client, and inside
that there is a class named GitHub Jobs clanked.
Please go ahead and create the package on the class name before you start building the client.
There you go.
I'm in the get up jobs plan class and now we are going to start building the plane.
So the very first thing that we need is a background instance, right?
So what I'm going to do, I'm going to create private plane, the plane, and we will be initializing
this through our test case.
For now, we are going to have this variable, our property available in this class, and then I'm going
to create a constructor.
So we will reinjecting the airplane instance through this constructor.
There you go.
We have the constructor ready and we planned instance.
The next thing is I'm going to create a function.
The function name is going to be so that's public.
And this function is going to give you an array of GitHub positions.
So in Java, I'm going to represent the same thing as a list.
So it's going to be a list of.
Get up.
That's what it's going to return, right?
Let me put this.
There you go.
That's part of the job you do.
So we have the function getting created and the name of the function is going to be in book.
Geta job zippi that no.
So what are the different things that are going to be accepted by this function, meaning what are the
different parameters?
The parameters are going to be the page number and the description, actually.
So it's going to be in.
Page number followed by that, it's going to be a string, let me zoom out a little bit.
Description that he got.
Now we have for now I'm going to just return, not to come back to that in a bit so we have the necessary
inputs ready.
The next thing is we are going to use a sprinkler plant in order to build a plant.
OK, so let's start doing it.
So it's going to be a client dog.
Get an offer that we need to pass.
You want.
So you are right is a function which is going to accept the whole.
You are.
So now use case that you are told is going to be whatever you see in the address bar.
So that's the water which we are going to build.
Spring Framework has a handy clause named You are a Confidence Builder.
Let's go out and start using that.
So it's going to be you are a confidence builder.
And then what we are going to do, we are going to do from you are a string.
And we are going to pass the part.
So what is the path, the path is going to be slashing positions, Dodgson, because obviously what
it will be said from a different class.
Also the technique in a bit.
So now we have those positions, Dodgson and after that, we are going to pass the codependents so no
one could promise it's going to be Corporan.
So what is a first goal?
So we are going to pass the description, right.
So let's copy the description from here.
So this is the first group and then we are going to set the curriculum from our argument.
So what is the second clip from?
The second clip from is going to be so it's going to be it's going to be the page number.
So what is the variable name?
It's going to be page.
There you go.
And Puzder page number in here, D'Errico.
And what we will do there is a handy method called build and expand.
And followed by that, what we will do, we will do to you worry string.
So this is going to give you the complete world that we are going to use to invoke the get up job CPI.
So it's going to be let's give it a name, actually.
So it's going to be strong.
You are.
So now we have the you are ready.
The next thing is we are going to pass.
You worry to this one.
OK, so the next step is we have to invoke that endpoint.
How do we do it?
The way to do it is by using one of the Handey function that's part of the client that US retreat.
So Retriever's of one, which is going to basically go ahead and invoke that endpoint in our case,
is that you want to after this retreat, we are going to receive the response from the endpoint call.
So there is a handy method called Body.
Body is the one which is going to handle the response party.
So in our case, we are going to receive an array of GitHub job positions.
Right.
So whenever you are dealing with a multiple response objects, you need to use the body to flux the
flux and mono or two different reactive types.
That's part of the spring of flux.
Flux is can be used if you are dealing with multiple objects, a model can be used if you are dealing
with a single object, since we are dealing with an array.
I'm going to use the body to flux and I'm going to provide the type of object that I'm going to receive
in the response.
In our case, it is the giddap position plus.
And after that, I'm going to convert this result to wordlist so there is a handy method called a dart
colliculus.
Collector lost, and after that, we are going to do the block because we are not doing any kind of
reactive programming that got introduced as part of the.
If you are interested to have a separate course on the topic, please go ahead and look at it.
So and here we are going to block on it because this is up blocking Rescorla.
We are going to wait until the response is received and then we will proceed further on what I'm going
to do here.
I'm going to create a variable and nothing this value that's going to be list of GitHub position and
let's give it a name, get positions that we go, and we are going to return this as a response.
That's cool.
Now, what I'm going to do here is that I'm going to print the wall.
So we want to I want to see what is the wall that we are printing over here.
There you go.
We are going to do the input static method and we are going to select the first option in here.
It's going to be you are right.
Plus.
Rory, there you go, there you go.
So now what we are going to do, we have the client ready.
Now let's go ahead and write a test case for this one.
So I'm going to create a test case that he go and give me the option us create new test in here.
I'm going to have the class name get up jobs client just so like this one and then click.
OK, there you go.
Now I have the test case ready.
I'm going to put this in a side-by-side view that he go in here, we are going to first instantiate
dug it up, jobs clean.
So let's start creating an instance.
It's going to be good jobs claimed.
It's going to be jantsch client.
Called the new Guiteau.
Jobs declined.
So what is a constructor argument we need to parse a constructor argument, the constructor argument?
Well, here is the plane.
So we need to parse that actually right now.
Let's go ahead and create an instance off the plane.
It's going to be will plant, dot create saying here we are going to passerby's you.
So what is our base?
You are the base.
You all is basically.
Let's go ahead and select one.
So this is the best you all get of jobs, jobs, target dot com.
I'm going to pause that as a base, you all the legal.
And then what I'm going to do, I'm going to assign this to a variable.
It's going to be a blend of client equal to let you go.
So we have this client instance created and this instance will automatically connect to this base,
you all.
And what we are going to do, we are going to pass that to this particular get jobs client instance.
So now we have the client instance ready and get a jobs client and stands ready.
The next step is we are going to make a call to this function, which is in GitHub jobs API underscore
with the page.
No, let's copy this.
And then Peruggia in multi-function, and then we are going to participate.
No, I'm going to add the page number in the given block.
So it's going to be page number is one.
And what is the second argument?
The second argument is a description.
So I'm going to parse the description as a string.
Description equal to I'm going to pass the Values Java script.
There you go.
And it's going to be page number come up.
Description.
There you go.
So now we have all the necessary input, boss, that function and the next step is we are going to assign
this to a variable rate, that it's going to be the similar variable.
So I'm going to put it here.
Very good.
The next step is we are going to be sitting on it.
So what I'm going to do is I want to assert whether the list is not null.
Basically, I want to see whether the list has more than one.
So the very first thing is I'm going to do also true.
I said true of guitar positions dot sise greater than zero.
So the size is greater than zero.
That means I received some data from that particular call.
Right.
That's very true.
And the next thing which I want, which I would like to do, was I want to check whether the the values
inside the guitar portion of the list is not empty.
So I'm going to do a up positions dot for each center for each.
We are going to pass the guitar, push an object in here.
I'm going to a certain ordinal on that object.
It's going to be this very goal included is giving me a recommendation.
I'm going to see what the recommendation is.
Replace Lambda with the reference.
I'm going to choose that the go because the compact index.
Now what I'm going to do is I'm going to go to the wall and then see whether is it returning me any
data.
So we are invoking the pagination you all want to conduct in here.
I'm going to parse the JavaScript.
So when I do that, this is a response that I receive.
So basically when we invoke the same endpoint from our code, it should give us a value and all these
associations will happen.
So now I'm going to go ahead and run this case.
There you go, that this case is getting launched, as you can see, the water that we're passing is
also getting printed here.
And we got a green bar, which means we have the invocation working us expected just to make it more
fun.
What I'm going to do, I'm going to log this whole process and actually.
There you go.
Let's import the right import, which is logorrhea log.
Now I'm going to run to this case again.
There you go.
We got the response printed here, and if you go and take a look at that in the console, there you
go.
So this is the response that we had received for the call that we had made.
So we have successfully built our risk line using spring the plane.
And we have the Busquets also written for testing the risk.
This marks the end of this lecture.
Thank you for watching.