Can anyone please explain why mainReadQuotesInvalidDates test in module 2 should throw an exception?

mainReadQuotesInvalidDates test in ModuleTwoTest.java checks for invalid dates!!. But i am not getting what kind of invalid dates is it checking for for 2017-12-12 is a valid date and also every date in tradesinvaliddates.json seems fine. I can just spot that one date in resources/assesment/tradesinvaliddates.json on which stock is brought is sunday?? am i on right track??

You are taking the history of stock. So You need to understand which dates would be right for getting stocks and which date you need to take care of from the given two dates.

Your start date should not go beyond end date. Please ensure this in your code. Then this exception won’t come.

1 Like

Hint: Read the to do section above mainReadQuotes() carefully.

Hey i am facing the same issue 1 of 8 test case is failing when i do ./gradlew build

com.crio.warmup.stock.ModuleTwoTest > mainReadQuotesInvalidDates() FAILED
org.opentest4j.AssertionFailedError at ModuleTwoTest.java:44

TEST RESULT: FAILURE
TEST SUMMARY: RAN 8 TESTS, 7 SUCCEEDED, 1 FAILED, 0 SKIPPED

8 tests completed, 1 failed

I have handled the case startdate < enddate
and then did the next things mentioned in the TODOs

What do we have to do when the end date is not present in json

I’m sorry but end date is present in args[1], right?

Not like that when we get result as json and if there is no result for enddate
Suppose 1jan 2020 is end date and json contains 31 dec 2019 as last date

crio-user@manmodesanket:~/workspace/manmodesanket-ME_QMONEY$ ./gradlew run --args=“trades.json 2020-01-01”

Task :qmoney:run
Feb 22, 2020 3:32:07 PM com.crio.warmup.stock.PortfolioManagerApplication printJsonObject
INFO: [“AAPL”,“MSFT”,“GOOGL”]
Feb 22, 2020 3:32:09 PM com.crio.warmup.stock.PortfolioManagerApplication printJsonObject
INFO: []

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/5.2.1/userguide/command_line_interface.html#sec:command_line_warnings

crio-user@manmodesanket:~/workspace/manmodesanket-ME_QMONEY$ ./gradlew run --args=“trades.json 2019-12-03”

Task :qmoney:run
Feb 22, 2020 3:32:28 PM com.crio.warmup.stock.PortfolioManagerApplication printJsonObject
INFO: [“AAPL”,“MSFT”,“GOOGL”]
259.45
149.31
1294.74
Feb 22, 2020 3:32:30 PM com.crio.warmup.stock.PortfolioManagerApplication printJsonObject
INFO: [“MSFT”,“AAPL”,“GOOGL”]

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/5.2.1/userguide/command_line_interface.html#sec:command_line_warnings

For first case there is no result and for second case there is.
For first case there dates present are till 31 dec 2019 and end date is 01 jan 2020

what do you do for wrong or incorrect user inputs?

i didnt get it. Can you give me an example

if the input is invalid or unexpected, your code should throw an exception to tell the user about the invalid input

if startdate > enddate do we have to throw exception?

yes. The tiingo api call will also return null in that case

okay then if startdate > enddate throw exception

1 Like

isn’t the args[1] the start date and the end date both ?

Arg[1] has enddate only

and start date is the purchase date of that stock ?

Read TODOS everything is mentioned there.

@manmodesanket can you give some hints abut what to do if invalid date is entered?