Skip to content

Tag: java

Does the following Java code really contain cyclic dependency?

‘ At a recent discussion within our team I had written the following code which was later flagged as having the cyclic dependency although to my knowledge and experience it is not. I need some fresh eyes to take a look at it so that I can learn more. disclaimer: The production code was converted into th…

How do I return to the beginning of a while loop?

I’ve only been taking coding classes for a month, so I’m really sorry if I’m using some wrong/wacky constructions. I’m trying to make an addition game using two random numbers; r1 determines the number of terms in the addition problem, while r2 assigns a value to each of them. The scan…

How to mock factory method in service test with mockito

Hi I am trying to test service layer. I have already wrote tests for ConverterFactory. I think I need the mock dependency classes which ConverterServiceImpl using but Still I got NullPointerException This is my service class And this is the test This code throws error says. What am i doing wrong here?: Answer…

Null Check in Jolt while converting string to integer For an Object

I am doing conversion of string to integer/double in my jolt spec. If elements does not come in request, then empty object is coming in response. Instead I do not want to pass that object itself as its empty. Input Request Working: Jolt Spec: Output if tag is there in request: But when input request is like b…