Skip to content

Commit

Permalink
Updando código do M02
Browse files Browse the repository at this point in the history
  • Loading branch information
fkeglevich committed Aug 23, 2018
1 parent f6cae17 commit 5810a55
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>

<properties>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/hello/HelloController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.joda.time.LocalTime;

@RestController
public class HelloController {

@RequestMapping("/data")
public String index() {
return "Greetings from Spring Boot!"; //"<html><body>Greetings from <i>Spring Boot!</i></body></html>";
LocalTime currentTime = new LocalTime();
return "Greetings from Spring Boot!" + currentTime; //"<html><body>Greetings from <i>Spring Boot!</i></body></html>";
}

}
2 changes: 1 addition & 1 deletion src/test/java/hello/HelloControllerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public void setUp() throws Exception {
public void getHello() throws Exception {
ResponseEntity<String> response = template.getForEntity(base.toString(),
String.class);
assertThat(response.getBody(), equalTo("Greetings from Spring Boot!"));
assertThat(response.getBody(), containsString("Greetings from Spring Boot!"));
}
}
4 changes: 2 additions & 2 deletions src/test/java/hello/HelloControllerTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hello;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

Expand All @@ -26,6 +26,6 @@ public class HelloControllerTest {
public void getHello() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/data").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(equalTo("Greetings from Spring Boot!")));
.andExpect(content().string(containsString("Greetings from Spring Boot!")));
}
}

0 comments on commit 5810a55

Please sign in to comment.