Compare commits
3 commits
784487e3a0
...
4021509916
Author | SHA1 | Date | |
---|---|---|---|
hirst | 4021509916 | ||
hirst | 806264de9a | ||
hirst | 59ce9d1a37 |
|
@ -2,6 +2,7 @@
|
|||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
|
|
9
.idea/runConfigurations/DummyApplication.xml
Normal file
9
.idea/runConfigurations/DummyApplication.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="DummyApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||
<module name="dummy" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.learningpulse.dummy.DummyApplication" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
18
.idea/runConfigurations/DummyApplicationTests.xml
Normal file
18
.idea/runConfigurations/DummyApplicationTests.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="DummyApplicationTests" type="JUnit" factoryName="JUnit">
|
||||
<module name="dummy" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.learningpulse.dummy.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<option name="PACKAGE_NAME" value="com.learningpulse.dummy" />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="package" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
9
.idea/runConfigurations/EurekaApplication.xml
Normal file
9
.idea/runConfigurations/EurekaApplication.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="EurekaApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||
<module name="eureka" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.learningpulse.eureka.EurekaApplication" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
9
.idea/runConfigurations/GatewayApplication.xml
Normal file
9
.idea/runConfigurations/GatewayApplication.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="GatewayApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||
<module name="gateway" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.learningpulse.gateway.GatewayApplication" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
36
.idea/runConfigurations/server__jib_build_.xml
Normal file
36
.idea/runConfigurations/server__jib_build_.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="server [jib:build]" type="MavenRunConfiguration" factoryName="Maven">
|
||||
<MavenSettings>
|
||||
<option name="myGeneralSettings" />
|
||||
<option name="myRunnerSettings" />
|
||||
<option name="myRunnerParameters">
|
||||
<MavenRunnerParameters>
|
||||
<option name="cmdOptions" />
|
||||
<option name="profiles">
|
||||
<set />
|
||||
</option>
|
||||
<option name="goals">
|
||||
<list>
|
||||
<option value="clean" />
|
||||
<option value="compile" />
|
||||
<option value="jib:build" />
|
||||
<option value="-e" />
|
||||
<option value="-X" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="multimoduleDir" />
|
||||
<option name="pomFileName" value="pom.xml" />
|
||||
<option name="profilesMap">
|
||||
<map />
|
||||
</option>
|
||||
<option name="projectsCmdOptionValues">
|
||||
<list />
|
||||
</option>
|
||||
<option name="resolveToWorkspace" value="false" />
|
||||
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||
</MavenRunnerParameters>
|
||||
</option>
|
||||
</MavenSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
|
@ -1,16 +0,0 @@
|
|||
package com.learningpulse.dummy;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/dummy")
|
||||
public class Test {
|
||||
|
||||
@GetMapping("/test")
|
||||
public ResponseEntity<String> test() {
|
||||
return ResponseEntity.ok("Hello, World!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.learningpulse.dummy;
|
||||
|
||||
import com.learningpulse.dummy.services.GreetingService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/dummy")
|
||||
@RequiredArgsConstructor
|
||||
public class TestController {
|
||||
|
||||
private final GreetingService greetingService;
|
||||
|
||||
@GetMapping("/test")
|
||||
public ResponseEntity<String> test() {
|
||||
return ResponseEntity.ok("Hello, World!");
|
||||
}
|
||||
|
||||
@GetMapping("/greeting")
|
||||
public @ResponseBody String greeting() {
|
||||
return greetingService.greet();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.learningpulse.dummy.services;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@NoArgsConstructor
|
||||
public class GreetingService {
|
||||
public String greet() {
|
||||
return "I work!";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.learningpulse.dummy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
|
||||
@SpringBootTest
|
||||
public class DummyApplicationSmokeTest {
|
||||
|
||||
@Autowired
|
||||
private TestController testController;
|
||||
|
||||
@Autowired
|
||||
private DummyApplication dummyApplication;
|
||||
|
||||
@Test
|
||||
void TestControllerExist() {
|
||||
assertThat(testController).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void DummyApplicationExist() {
|
||||
assertThat(dummyApplication).isNotNull();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.learningpulse.dummy;
|
||||
|
||||
import com.learningpulse.dummy.services.GreetingService;
|
||||
import org.apache.catalina.security.SecurityConfig;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.mockito.Mockito.when;
|
||||
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.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(TestController.class)
|
||||
@ContextConfiguration(classes = {TestController.class, SecurityConfig.class})
|
||||
@WithMockUser(username = "admin", password = "admin")
|
||||
class DummyApplicationTest {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext webApplicationContext;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
private GreetingService greetingService;
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
mockMvc = MockMvcBuilders
|
||||
.webAppContextSetup(webApplicationContext)
|
||||
.apply(SecurityMockMvcConfigurers.springSecurity())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnDefaultMessage() throws Exception {
|
||||
this.mockMvc.perform(get("/api/v1/dummy/test"))
|
||||
.andDo(print())
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("Hello, World!")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void greetingShouldReturnMessageFromService() throws Exception {
|
||||
when(greetingService.greet()).thenReturn("I work!");
|
||||
this.mockMvc.perform(get("/api/v1/dummy/greeting"))
|
||||
.andDo(print())
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("I work!")));
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.learningpulse.dummy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DummyApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.learningpulse.dummy.services;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class GreetingServiceTest {
|
||||
|
||||
private GreetingService greetingService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
greetingService = new GreetingService();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenGreet_thenReturnGreet() {
|
||||
assertEquals("I work!", greetingService.greet());
|
||||
}
|
||||
}
|
Reference in a new issue