Last active
September 25, 2019 09:25
-
-
Save simonrenoult/e6fd7d08e3c9e1319d129bf0886319c8 to your computer and use it in GitHub Desktop.
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
plugins { | |
id 'java' | |
id 'idea' | |
id 'org.springframework.boot' version '2.1.8.RELEASE' | |
id 'io.spring.dependency-management' version '1.0.8.RELEASE' | |
} | |
group 'com.octo.skool13' | |
sourceCompatibility = 11 | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
// Web | |
implementation 'org.springframework.boot:spring-boot-starter-web' | |
// Tests | |
testImplementation 'org.springframework.boot:spring-boot-starter-test' | |
testImplementation 'junit:junit:4.12' | |
} |
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
@RestController | |
public class HealthcheckApi { | |
private final SayImAlive sayImAlive; | |
public HealthcheckApi(SayImAlive sayImAlive) { | |
this.sayImAlive = sayImAlive; | |
} | |
@RequestMapping(value = "/healthcheck") | |
public Boolean healthcheck() { | |
return sayImAlive.execute(); | |
} | |
} |
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
package com.octo.skool13.infra; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
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.context.junit4.SpringRunner; | |
import org.springframework.test.web.servlet.MockMvc; | |
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
@RunWith(SpringRunner.class) | |
@SpringBootTest | |
@AutoConfigureMockMvc | |
public class HealthcheckApiTest { | |
@Autowired | |
private MockMvc mvc; | |
@Test | |
public void isAlive() throws Exception { | |
mvc.perform(MockMvcRequestBuilders.get("/healthcheck")) | |
.andExpect(status().isOk()) | |
.andExpect(content().string("true")); | |
} | |
} |
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
package com.octo.skool13; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication | |
public class ManageoApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(ManageoApplication.class, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment