Issue with Ticket: User Preferences

After doing necessary changes in the code, all tests pass.

But application gives following error:

com.mongodb.MongoWriteException: E11000 duplicate key error collection: mflix.sessions index: user_id_1 dup key: { : “bteixlzw2@e5ctz.as4” }

1 Like

I just removed whole sessions collection. It worked.

What if sessions data is used in other tests/tickets?

You can load data again :stuck_out_tongue:

I think it is a very good idea to cheat with the test data to have the correct answer.

Note to the readers about the above comment.

I am very sarcastic.

Real comments:

@Manish_75171, you are right, you never changes unit tests drivers unless the requirements change. You do not cheat with the unit test data to have a passing grade. At least, you do not write that you did it in a public forum.

1 Like

This course just has bugs. Unit tests aren’t deterministic, they don’t cover all requirements. Validation messages don’t specify the real reason of error. It’s not cheating, it’s a workaround.

Ok, I checked it again. @Manish_75171, check detailed answer for User Management task. Probably you implemented createUserSession incorrectly. It shouldn’t create new session if one exists, just update it then. After fixes, User Preferences validation work for me without workarounds.

Can you give specific example of the non-deterministic behaviors of the unit tests?

Can you give a list of the bugs you found?

Which requirements are not covered?

Do you have an example of the validation messages that are misleading?

Your comment so far does not help the MongoDB university to improve.

For example in UserTest tests are not independent. Of what I remember, when I rerun them without any changes some test from red became green.
Regarding requirements: sorting in getMovie isn’t covered, createUserSession isn’t covered well – we can pass this stage and have problems later.
I think that in create/update comment I had some strange message and didn’t know what to do until I checked in forum that problem was in getMovie in earlier stage – maybe the message wasn’t misleading but this situation was confusing.

I too made these observations.

I am sure the staff will be happy to take your comments in consideration.

However for Regarding requirements: sorting in getMovie isn’t covered. The following is written for the lab.

Task

For this ticket, you’ll be required to extend the getMovie method inMovieDao.java so that it also fetches the comments for a given movie. The comments should be returned in order from most recent to least recent using the date key.

I have embolden the sort part of the requirement. However, you are right about the fact that the unit tests for this ticket does not catch the error in your code if you fail to sort. In fact they do test the sort however the way they create the test comments is in the natural order so the test comments are in the correct order even if you do not sort.

1 Like

Manish, just implement the upsert options in the updateone() method for createusersession() function
Take a look to the BasicWrites.java in the Lessons folder

1 Like