-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add dateUpdated field to Post model and update PostController t…
…o handle PUT requests
- Loading branch information
Showing
6 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/liatrio/dojo/devopsknowledgeshareapi/AuthorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.liatrio.dojo.devopsknowledgeshareapi; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@RestController | ||
public class AuthorController { | ||
|
||
@GetMapping("/authors") | ||
public ResponseEntity<List<String>> getAuthors() { | ||
// Mocked list of author names, replace with your actual data model if needed | ||
List<String> authors = Arrays.asList("Author One", "Author Two", "Author Three"); | ||
return ResponseEntity.ok(authors); // Return the list with an OK status | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/java/com/liatrio/dojo/devopsknowledgeshareapi/AuthorControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.liatrio.dojo.devopsknowledgeshareapi; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
@SpringBootTest | ||
@AutoConfigureMockMvc() | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public class AuthorControllerTest { | ||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@InjectMocks | ||
AuthorController mockAuthorController; | ||
|
||
@BeforeAll | ||
public void setup() throws Exception { | ||
this.mockMvc = standaloneSetup(mockAuthorController).build(); | ||
} | ||
|
||
@Test | ||
public void getAuthorsResponse() throws Exception { | ||
this.mockMvc.perform(get("/authors")).andDo(print()).andExpect(status().isOk()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters