-
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 findByTitle, findByFirstName, and findByLink methods to Pos…
…tRepository
- Loading branch information
Showing
6 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/liatrio/dojo/devopsknowledgeshareapi/InfoController.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.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@CrossOrigin(origins = "*", maxAge = 3600) | ||
@RestController | ||
@Slf4j | ||
public class InfoController { | ||
|
||
@GetMapping("/info") | ||
public String getInfo() { | ||
log.info("Received a GET request for /info"); | ||
return "Welcome to the API version 1.0"; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/test/java/com/liatrio/dojo/devopsknowledgeshareapi/InfoControllerTest.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,31 @@ | ||
package com.liatrio.dojo.devopsknowledgeshareapi; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption; | ||
import org.springframework.boot.web.server.LocalServerPort; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
class InfoControllerTest { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Autowired | ||
private TestRestTemplate restTemplate; | ||
|
||
@Test | ||
void testInfoEndpoint() { | ||
String url = "http://localhost:" + port + "/info"; | ||
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class); | ||
|
||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
assertThat(response.getBody()).contains("Welcome to the API version 1.0"); | ||
assertThat(response.getBody()).doesNotContain("error"); | ||
} | ||
} |
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