Raja Avrv

Greenhorn
+ Follow
since Jun 25, 2020
Cows and Likes
Cows
Total received
1
In last 30 days
1
Total given
0
Likes
Total received
1
Received in last 30 days
1
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raja Avrv

Ok, I'll post most of my code here (did a little bit of refactoring) to provide a complete picture.

Controller:


Service:


ControllerTest:


ServiceTest:
1 week ago

Himai Minh wrote:Hi ,
You may want to add an encoder to encode the password:



Sure, thank you but the "myPassword" above will be the actual password in plain text, correct?
1 week ago

Junilu Lacar wrote:

Raja Avrv wrote:
The service class actually does all the computation, so I thought I could just test that the controller calls the service (using verify) here and that I can see the result of that service call come out of the controller (through expect). Is that expect maybe not necessary?


1. Your test method name does not give that impression
2. The test code does not clearly communicate its intent



Please tell me what changes I can make to make it convey intent better.
1 week ago

Junilu Lacar wrote:Line 10 of the test looks very wrong to me. Especially when you look at line 22.



The service class actually does all the computation, so I thought I could just test that the controller calls the service (using verify) here and that I can see the result of that service call come out of the controller (through expect). Is that expect maybe not necessary?

1 week ago

Stephan van Hulst wrote:There's very little I can say about the correctness of your test without knowing what it is testing.

What is subject? Why are you mocking the word counting service?



subject is the class under test here, the controller. I am mocking the service because the service is the one that's doing the actual work. All the controller does is delegate the work to the service class, by passing the input (list of strings) it receives and another list of strings (to search in).
1 week ago
Thank you. Can you please review this for unit test of the above method?

1 week ago

Campbell Ritchie wrote:There's a space in that regex, too. I am not sure I like that regex; it will have to get bigger every time you add a punctuation mark. It also risks producing zero‑length Strings whenever separating characters are juxtaposed. I might consider something like this instead, using "\\w+" to match. You can augment that regex to permit included apostrophes and hyphens, etc.



I currently have this "\\w+" which seems to be working for words including alphabets and numbers only. How should I change it to include special characters within the word, like abc-def and abc'd?
1 week ago
Actually, I found something that might work, but I don't know how to print key and value in the format I described earlier:

1 week ago
I have a Hashmap that I'd like to print to the response in this format:


I've tried something like this, but it won't quite print it in the format I need.


Kindly help! I've looked at OpenCSV and others, but can't figure out a way
1 week ago

Himai Minh wrote:Hi Raja,
You can encode the password in a database. Here is an example : https://www.baeldung.com/spring-security-registration-password-encoding-bcrypt



Hello Himai,

If I don't have a DB, then is it just done by hardcoding like this?
1 week ago
Hello,

I am trying to learn spring security and just created an API with basic auth. Is there any way to not hardcode the password within the app?

Thanks,
Raja
1 week ago
How do I form a regex for splitting this type of sentence. I had this , but it gives me a result for space or some blank character.

Sample text:
1 week ago

Paul Clapham wrote:Which one? There's several instances of converting to lower case in your code.

Could all of the individual conversions (from input to InputInLowerCase and content to ContentInLowerCase) be avoided and the case ignore comparison be done within the stream and filter functions?
1 week ago
Ok, I was able to get a linked map from groupingBy but I am not sure how to do counting() and also put a default value.



Now this counts, but I need to add the value to the map and put a 0 if the key is not found.
1 week ago
Thank you. Is there a way to also do the lowercase within the stream function? I convert to lowercase list but then again I return the output with the original list, so could that be simplified as well?
1 week ago