Skip to content

Tag: spring

Mockito How to mock and assert a thrown exception

I have this junit: but I have this error: I also tried: Answer The problem is that you are stubbing, but not really testing anything. And if you are not testing anything, then there is no need for stubbing. That’s why you have unnecessary Mockito stubbings. I assume that you want to test your SecurityMa…

CST to UTC conversion in java

This is my class.. here i am changing the time zone CST to UTC so its adding +5 hrs because of its adding 5hrs its changing the date 25-26 to 25-27 .. but i want the output same as 25-26 same even after the time zone conversion… please anyone help me out struck on this issue for 2 days… for

JPA createQuery where condition does not work

I am trying to use JPA to fetch records from database. However I am able to insert records indatabse and even get all the records using createQuery method of class EntityManager. But in below case I am not getting why the condition in where clause is not working. Please help me figure it out. POJO class : DAO…

Spring POST Method Microservice 500 exception

So, im trying to write a microservice with basic GET POST PUT DELETE commands. Its a Spring Maven Java programm with a mysql server When I try to post something it works, however if I dont include the Id it returns an exception: This is weird, because in the mysql console I can Insert a customer without the i…