Unit Testing Errors

com.crio.warmup.stock.PortfolioManagerApplicationTest > testDebugValues() FAILED
java.lang.NullPointerException at PortfolioManagerApplicationTest.java:48

com.crio.warmup.stock.PortfolioManagerApplicationTest > mainReadFile() FAILED
java.lang.ArrayIndexOutOfBoundsException at PortfolioManagerApplicationTest.java:22

Receiving these errors.

It is because of :
@Test

public void testDebugValues() {

List<String> responses = PortfolioManagerApplication.debugOutputs();

Assertions.assertTrue(responses.get(0).contains("trades.json"));

}

In my main file, the functions exists as :
public static List debugOutputs() {

return null;

}

@prakul

See, here you need to modify all the methods the way suggested in the TODO’s.

You’re getting those errors because of the following problems in your code

1: You’re not making the API call perfectly, I suggest you to see the developers docs again and make the changes according to it. There are a lot of API calls given in the documentation, so you’ll have to pick up the perfect one which is suitable for the project.

2: The POJO in which you’re saving the fetched JSON objects is not implemented perfectly.

Please see them, if it’s not working, ping me, I’ll again take a look into the issue :slight_smile:

Did you throw exceptions?

Please refer to the following FAQ’s


In the debugOutputs function, it is expecting a list. You can follow the same procedure as you have done module 1, to fill the values into that function.

This is probably happening because there is an error in you debugOutput() function, you have not assigned the value properly.

For this one, make sure in your logic, that you are writing properly in a list Symbols, There is probably an error there.

Closing this topic as there is no response since last 12 hours. Please feel free to create a new topic and post this question as a reference link in the description of the new topic.