-
-
Notifications
You must be signed in to change notification settings - Fork 94
GP-66 Create a new hello spring mvc exercise #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…GP-66-CreateANewHelloSpringMvcExercise # Conflicts: # 0-0-intro/pom.xml
0-0-intro/pom.xml
Outdated
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>14</source> |
There was a problem hiding this comment.
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.
2-0-servlet-api/pom.xml
Outdated
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>2-0-servlet-api</artifactId> | ||
<build> |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { | ||
|
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()); | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
…GP-66-CreateANewHelloSpringMvcExercise # Conflicts: # 3-0-spring-mvc/3-0-1-hello-spring-mvc/src/main/java/com/bobocode/mvc/controller/NoteController.java # 3-0-spring-mvc/3-0-1-hello-spring-mvc/src/test/java/NoteControllerTest.java # 3-0-spring-mvc/pom.xml
…SpringMvcExercise # Conflicts: # 0-0-intro/pom.xml # 2-0-servlet-api/pom.xml # 3-0-spring-mvc/pom.xml # pom.xml
No description provided.