* BAEL-4811

* BAEL-4811 Add unit tests

* JAVA-8794: Upgrade Spring Boot to 2.6.1 in the parent-boot-2

* JAVA-8794: Upgrade spring-mybatis dependencies

* JAVA-8794: Make spring-boot-springdoc 2.6 compatible

* JAVA-8794: Add spring.mongodb.embedded.version property

* JAVA-8794: Upgrade spring-boot-environment cloud dependencies

* JAVA-8794: Set spring.mvc.pathmatch.matching-strategy property

* JAVA-8794: Update Spring Cloud dependencies

* JAVA-8794: allow-circular-references in spring-cloud-ribbon-client

* JAVA-8794: Replace deprecated ConfigFileApplicationContextInitializer

* JAVA-8794: Fix spring-resttemplate pom

* JAVA-8794: Use spring.mongodb.embedded.version=3.5.5

* JAVA-8794: Use spring.mongodb.embedded.version=3.5.5

* JAVA-8794: Fix circural dependencies in spring-security-web-boot-2

* JAVA-8794: Fix circural dependencies in spring-security-core

* JAVA-8794: Fix quart schema initialization

* JAVA-8794: Set spring.mvc.pathmatch.matching-strategy=ant-path-matcher

* JAVA-8794: Leave spring-kafka on Spring Boot 2.5.4

* JAVA-8794: Set spring.mongodb.embedded.version=3.5.5 in spring-jenkins-pipeline

* JAVA-8794: Update Spring Cloud version

* JAVA-8794: Update spring-cloud-zuul dependencies

* JAVA-8794: Update Spring Cloud version in spring-cloud-bus

* JAVA-8794: Set spring.mongodb.embedded.version=3.5.5 in spring-boot-persistence-mongodb

* JAVA-8794: Fix spring-data-jpa-query-2 dependencies

* JAVA-8794: Fix circular dependency issue in spring-security-web-thymeleaf

* JAVA-8794: Fix circular dependency issue in spring-session-redis

* JAVA-8794: Fix circular dependency issue in spring-boot-libraries-2

* JAVA-8794: Update spring-cloud-starter version

* JAVA-8794: Leave spring-zuul-rate-limiting on 2.4.7

* JAVA-8794: Ignore EnversFooBarAuditIntegrationTest

* BAEL-4811 Fix formatting

* BAEL-4811 Fix formatting

Co-authored-by: Krzysiek <krzysztofwoyke@gmail.com>
Co-authored-by: Loredana Crusoveanu <lore.crusoveanu@gmail.com>
This commit is contained in:
Amy DeGregorio
2021-12-19 14:53:05 -05:00
committed by GitHub
parent 8a40a0a012
commit 0cf64901b5
10 changed files with 154 additions and 148 deletions

View File

@@ -19,50 +19,50 @@ import com.baeldung.micronaut.vs.springboot.CompareApplication;
@SpringBootTest(classes = CompareApplication.class)
@AutoConfigureMockMvc
public class ArithmeticControllerUnitTest {
@Autowired
@Autowired
private MockMvc mockMvc;
@Test
public void givenTwoNumbers_whenAdd_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(10 + 20);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/sum/10/20")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void givenTwoNumbers_whenSubtract_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(20 - 10);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/subtract/20/10")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void givenTwoNumbers_whenMultiply_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(20 * 10);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/multiply/20/10")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void givenTwoNumbers_whenDivide_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(20 / 10);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/divide/20/10")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void whenMemory_thenMemoryStringReturned() throws Exception {
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/memory")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(containsString("Initial:")));
}
@Test
public void givenTwoNumbers_whenAdd_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(10 + 20);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/sum/10/20")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void givenTwoNumbers_whenSubtract_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(20 - 10);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/subtract/20/10")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void givenTwoNumbers_whenMultiply_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(20 * 10);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/multiply/20/10")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void givenTwoNumbers_whenDivide_thenCorrectAnswerReturned() throws Exception {
Float expected = Float.valueOf(20 / 10);
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/divide/20/10")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(expected.toString()));
}
@Test
public void whenMemory_thenMemoryStringReturned() throws Exception {
this.mockMvc.perform(MockMvcRequestBuilders.get("/math/memory")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(containsString("Initial:")));
}
}