I'm quite new to Java and I'm working on a project that has a web-based UI and it then makes various calls to Java code. The calls to the code seem to be done via URL's and Spring @RequestMapping similar to this:
public class myClass()
{
@RequestMapping(value="aUrlHere/SomeOtherPieceofUrl", method.request.GET)
Public ResponseEntity doStuff()
{
//Code here that does stuff
return;
}
}
The problem is that I've never worked on @RequestMapping or ResponseEntity things and I don't really understand how it works. I think what happens is when the appropriate URL is navigated to in the UI, the corresponding method is called from the code, and the @RequestMapping is used to map those URL calls to the various methods.
What I would like to be able to do is call these methods without having to use the web-based UI, e.g. like in the form of some sort of unit test.
Can I call these methods using something like this?
myCLass testClass = new myClass();
testClass.doStuff();
I think I tried something like the above but it didn't work. However I don't really know how to use these methods. I didn't write the original code and the person who did is no longer available to speak to.
I tried using something like a HttpWebRequest in Java to just make a call to the URL but I was running into issues with security certificate exceptions. Normally you would have to be logged in via the web UI to use this thing and due to the security setup, it seems to be hard to navigate around.
I was just wondering if I could write some sort of unit test to fire off those methods and get a response?
Thanks.