Create/Update Comments

my test case gets successfully passed but at the time of retrieving the validation code- error message-“unable to update comment”

Kindly help for further process.

Please post a screenshot of the problem and a screenshot of the related unit test passing.

Is there any error in the terminal used to start the application?

Also there is no error on the terminal

I do not know if the issue is still present with the validation scripts but an error was found during unit tests but was found in the app.

The problem was when the comments were not sorted correctly in getMovie or getComments. The way the unit tests were written the tests would pass even if the comments are not sorted but it would failed in the app.

But i dont think this is the case… because in such case, it will show msg as ‘Unable to post a comment’ but i am getting ‘Unable to update comment’.Also i have tried with sorting but to no avail.

The next step will be to add some println() to pinpoint where is the problem.

Another thing to check is to make sure ObjectId are ObjectId everywhere they should be.

I print logs…

There were 2 update request against id - 5a9427648b0beebeb6962ac0 with emailId dqckccmkq@pxvdn.pvv and amni532f1@251fa.6e1 but in dB actual emailId is w2jomwmo1@06i0n.p3e for id - 5a9427648b0beebeb6962ac0 hence no update for text but still getting status response as 'unable to update comment. kindly help to resolve this.

What do you return when trying to update a comment with the wrong email?

boolean type - false

I have same problem

This is an old thread. Please elaborate the issue in detail so that we can help you better.

Kanika

Hi @kanikasingla
The validation Delete comments doesn’t work
My implementation is:

public boolean deleteComment(String commentId, String email) {
    Bson deleteFilter = Filters.and(Filters.eq("_id", new ObjectId(commentId)), Filters.eq("email", email));
    return commentCollection.deleteOne(deleteFilter).getDeletedCount() > 0;
}

All tests are passed but when I try to validate the functionality it shows error message

Your code is correct, one thing you want to see here is this function expects boolean (true/false) as an output.

So, check the output of commentCollection.deleteOne(....) and see if you can output logical true/ false on the basis of this.

Kanika

@kanikasingla

I tried to debug the validation process and can see the next things:

  1. Firstly, validation process adds a new comment

  2. After, it tries to delete not exist comment (because a comment with such email doesn’t exist)

  3. Finally, the validation process tries to delete the comment but actually it doesn’t exist in the database
    image
    Comment with such email in database (because we created it in the first step) but id of comment is wrong

Could you share a validation uid for this ticket or provide UI part with right validation process?

You just need to check the output of deleteOne and if it is greater than 0 that means there was a comment that got deleted, you need to return true else false.

Kanika

1 Like

@kanikasingla
I know, please check my comment before.

What else can you suggest?

I found a solution. Need to change MovieDao.getMovie with that code:

No! Let me explain you, sending you a message.

Kanika