I can't pass ConnectionTest

When I run:

mvn test -Dtest=ConnectionTest

the result is:

[ERROR] Failures:

[ERROR] ConnectionTest.testMoviesCount:44 Check your connection string expected:<45993> but was:<44993>

Whats is wrong?

did you change the connection string in spring.mongodb.uri to something like this:

spring.mongodb.uri=mongodb+srv://m220student:m220password@mflix-xxxxxxxx.mongodb.net/admin?retryWrites=true

this example is using Atlas and you should customize to your connection string.

1 Like

Thanks vssouza, but i get the same error.

Can’t you paste your connectionstring and replace the servername fix xxxx like I did? The problem is there and you just need to spot.

If you don’t feel comfortable to post it you can test the same connectionstring with compass and mongoshell to check if it works.

This is my application.properties:
jwtSecret=SUPER_SECRET_KEY_YOU_WANT_TO_REPLACE_THIS
jwtExpirationInMs=604800000
spring.mongodb.uri=mongodb+srv://m220student:m220password@mflix-xxxxx.mongodb.net/admin?retryWrites=true
spring.mongodb.database=mflix
server.port=5000
logging.level.api.controllers=DEBUG
api.movies.movies_per_page=20
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/build

I have replaced whit xxxx the server.
Thanks.

The test result says:
" expected: <45993> but was:<44993>"
And as for me the connection looks good, but you’ve lost 1000 movies somewhere…
I’d suggest you to open MongoDB Compass and check documents in movies collection:


If the documents in movies collection will not be 45993 try to repeat the step with “mongorestore”.

1 Like

Sorry but I’m working outdoors today and don’t have my laptop. I’m answering from my phone. The application properties seems ok to me. Maybe u can compare it with the application properties I have in my github

There is a repo named mflix. I replaced the server name with xxxxx too.

Can u compare and see if u find any differences??

I was checking the ConnectionTest class and the message u are getting is from a method that counts the movies:

@ViacheslavT pointed it right. U have the database… u have the collections but there are 1000 movies missing.

Did u get any errors during mongorestore process?? You can try to drop the database and mongorestore the dump again! That should be really fast and straight forward.

Cheers.

Thanks very much vssouza. Now works !!
I have drop the database, and restore it.

That’s really good to know man! :slight_smile: