Skip to content

Conversation

ivanvirchenko
Copy link

No description provided.

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>14</source>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 let's please use java 11 everywhere.

<modelVersion>4.0.0</modelVersion>

<artifactId>2-0-servlet-api</artifactId>
<build>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the scope of this task, please don't touch other modules (I believe this plugin can be just added to the parent pom.xml no?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to configure it in the parent pom.xml and please make sure that tests are running when you run mvn clean package

* - @RequestMapping("/api/notes") - to indicate the basic endpoint for all request methods;
* - @RequiredArgsConstructor (for using storage without explicit autowiring);
*/
public class NoteRestController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 in exercises we usually write Java Doc that describes what classes and methods do. Not what students should be adding. Most probably some theory will be added to the README, and here in code we can say something like this

/**
 * NoteRestController is a rest controller that provides two HTTP endpoints. One allows you to add a new note, and
 * another one allows you to get all notes. The URL starts from `/api`. It follows REST conventions. This means that in order to add a new note, you need to perform HTTP POST request to `../notes` and pass note JSON in the request body. This endpoint also returns the created note in the response JSON. In order to get all notes, you need to perform HTTP GET to `../notes`. 
 */

This is just an example, and I didn't expect you to come up with such descriptions... This should be provided in the ticket. (I will prepare a document on how to create new exercises for the future).

* - @RequiredArgsConstructor (for using storage without explicit autowiring);
*/
public class NoteRestController {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 Spring DI is not in the scope of this exercise, so let's make life easier for people and inject Notes for them.

// TODO define the storage variable Notes

// TODO
// Create method to get list of notes from storage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest comments should be removed...

}

@Test
void noteHasDateWhenSaveItToStorageAfterPost() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 same here, it's not in the scope of the exercise


@SpringBootTest(classes = HelloSpringMvcApp.class)
@AutoConfigureMockMvc
public class ControllerTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 let's call it NoteControllerTest

);

assertNotNull(notes.getAll().get(0).getCreationDate());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 you should test that addNote() redirects to the notes page

}

@Test
void returnValidDataWhenGetMethodCalled() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 again, it should be called getAllNotes()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plus you can expect the correct status in the same test

}

@Test
void addNoteWhenPostMethodCalled() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erneman1 you can have one test that verifies that note was added. And another one that checks if that note was returned to the client.

@tboychuk tboychuk merged commit 454d1a0 into main Mar 29, 2021
@tboychuk tboychuk deleted the GP-66-CreateANewHelloSpringMvcExercise branch March 29, 2021 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants