Compare commits
No commits in common. "402150991666ac6f9a600163356d073dc00e1fbe" and "784487e3a0d2374215a2716a6631611181744eb6" have entirely different histories.
4021509916
...
784487e3a0
|
@ -2,7 +2,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<annotationProcessing>
|
<annotationProcessing>
|
||||||
<profile default="true" name="Default" enabled="true" />
|
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<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>
|
|
|
@ -1,18 +0,0 @@
|
||||||
<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>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<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>
|
|
|
@ -1,9 +0,0 @@
|
||||||
<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>
|
|
|
@ -1,36 +0,0 @@
|
||||||
<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>
|
|
16
dummy/src/main/java/com/learningpulse/dummy/Test.java
Normal file
16
dummy/src/main/java/com/learningpulse/dummy/Test.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
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!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,27 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.learningpulse.dummy.services;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class GreetingService {
|
|
||||||
public String greet() {
|
|
||||||
return "I work!";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
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!")));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.learningpulse.dummy;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class DummyApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
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