Let's continue our work on the machine project! Next we'll begin the next project checkpoint, MP2. We'll install the test suites and begin work on our first test case.
MP2 represents a step up from MP1. Rather than making small changes, we'll be writing larger chunks of code. However! The code we ask you to write will be similar to the code that we've given you. So you can use our starter code as a guide and inspiration.
Before you can get to work on MP2 in earnest, we need to install the MP2 test suites. Before we continue, please commit your work.
You should have received the MP2 test suites via email.
Move the file to the
app/src/test/java/edu/illinois/cs/cs124/ay2022/mp/ directory in your machine project, and make sure it's named
You'll also want to reconfigure
grade.yaml in the root directory of your project to request that we grade Checkpoint 2.
We've completed this steps before, so if you need to review please examine the lessons for MP1.
Like MP1, when we add
MP2Test.java to our project our code will no longer compile.
This is because the test suite expects us to have created some new methods and classes that don't exist yet.
The task here isn't too involved, but let's go through it together.
Note that you should also make sure to update
grade.yaml before you push changes for MP2, to ensure that MP2 is what is graded.
The walkthrough above may be missing that step.
With the test suites in place, let's get started on our first test case:
We're going to approach this in two steps, each accompanied by a walkthrough.
First, we'll examine the test suite carefully and gain an understanding of what we need to do. We'll create our own test case to allow us to experiment with the different requests that the test suite is expecting the server to handle. We'll also discuss the basics of how HTTP POST requests allow clients to send data to the server.
Next, we'll work through an outline of what our server code needs to do to handle requests to add a new place to the map. You will have code left to write to complete this test case! And this is one of the more difficult test cases to pass for MP2. However, you should have a strong idea of what you need to do after watching the walkthrough below.
As outlined above, here's a specification for how your
/favoriteplace route should work.
It should accept
If the body is not valid JSON, or does not contain a valid
Place object, you should return a response with the HTTP error code 400: Bad Request.
Place object is valid if:
descriptionare present and non-empty
longitudeare present and within valid ranges
idcontains a valid UUID
Given a valid
Place object, a POST to
/favoriteplace should add it to the list of places returned by a GET request to
id in the new
Place matches an existing
Place in the list, replace that
Place with the new
Otherwise add the new
Place to the list.
The Internet is probably the most important piece of technology that computer scientists have ever created. Without the ability to communicate across the globe, computers would really be nothing more than glorified typewriters or calculators.
There are a lot of ways to find out more about the internet. But I'll take the liberty of pointing you at some videos that I've created on the topic that you might enjoy. Note that this is completely optional content! The playlist above focuses on internet concepts related to the world wide web, including the HTTP protocol. But there is a much longer playlist here that covers everything from physical infrastructure all the way up to Internet policy.
As a reminder, on lessons where we focus on the machine project we will not assign a homework problem! However, the lesson will usually focus on helping you complete a particular part of the MP test suite, and so we encourage you to spend time on that in lieu of a homework problem.
Right now your goal should be to
Need more practice? Head over to the practice page.