Skip to content

Latest commit

 

History

History
120 lines (87 loc) · 5.35 KB

File metadata and controls

120 lines (87 loc) · 5.35 KB

Lab Tasks

  • Questions that you need to answer (as a group!) are indicated with question mark symbols (:question:).
  • Tasks that specify work to do without a written response will be bulleted.

Responses to questions should be submitted as specified by your instructor.

If you're ever confused about what you need to do for a given task, ask.

Table of Contents

Exploring the project

The structure of this project should be nearly identical to that of lab #3, and as such there really isn't much excitement in that department.

Exploring the server

The server is, for the most part, the same as it has been in the past two labs. The difference to look for here is in how the server gets the data it sends out in reply to requests.

Answer questions 1-6 in QUESTIONS.

More Todos!

  • Re-implement the ToDo API, this time pulling data from MongoDB rather than from a flat JSON file.
  • When displaying the ToDos in your Angular front-end, make thoughtful decisions about whether work like filtering should be done in Angular or via database queries. It would be reasonable, for example, to have the database filter out all the ToDos belonging to a single user, but let Angular filter by category or status.

Writing Todos to the Database

  • We have included an example of writing to the database with addUser functionality. Add to both the front-end and back-end to make it possible to add ToDos so that they appear both in your list and in the database.

Summary Information About ToDos

To see an example of using the database and the server to do some useful work (instead of having everything happen in Angular), implement an API endpoint /api/todoSummary which provides summary information about a group of ToDos in the following format:

{
  percentToDosComplete: Float,
  categoriesPercentComplete: {
    groceries: Float,
    ...
  }
  ownersPercentComplete: {
    Blanche: Float,
    ...
  }
}

So you should add a new endpoint to your Spark routes, and then have that call some method (possibly in a new class?) that queries the DB for the relevant data and assembles this JSON response. Note that you can use MongoDB aggregation to do most of this calculation without having to actually download all the todos, organize, and count them yourself.

Make it pretty

Remember to test!

Test test and more test! Your project again should have tests. You should contiue expanding upon your previous end-to-end test as well as implement Unit Test for both your client-side and the server-side.

Client-side testing

  • The gradle task runClientTestsWithCoverage will be extremely useful to see how covered your client-side is by test.

  • Continue expanding upon your TESTCOVERAGE.md file with any additional end-to-end test added.

Server-side testing

  • Remember to add JUnit Test as you re-implement your ToDo API.

❗Pro-Tip: Test Coverage can be produced on IntelliJ as well! Go to to your server test folder and Right-click on the test folder and select Run 'All Test' with Coverage which will then provide a report of coverage in your server code in the side bar.

Additionally you can Right-click, select Analyze -> Generate Coverage Report... which will prompt you for an output directory and give you the option to view the report an HTML report in a browser.

Questions

  1. ❓ What do we do in the Server and UserController constructors to set up our connection to the development database?
  2. ❓ How do we retrieve a user by ID in the UserController.getUser(String) method?
  3. ❓ How do we retrieve all the users with a given age in UserController.getUsers(Map...)? What's the role of filterDoc in that method?
  4. ❓ What are these Document objects that we use in the UserController? Why and how are we using them?
  5. ❓ What does UserControllerSpec.clearAndPopulateDb do?
  6. ❓ What's being tested in UserControllerSpec.getUsersWhoAre37()? How is that being tested?