Промежуточный коммит.
This commit is contained in:
parent
2ba5f3bf1d
commit
436fecf2ec
@ -8,7 +8,7 @@ button_s.addEventListener("click", function()
|
|||||||
{
|
{
|
||||||
console.log("Кнопка нажата.");
|
console.log("Кнопка нажата.");
|
||||||
|
|
||||||
fetch('http://localhost:8080/plus?num_1=' + one.value + '&num_2=' + two.value)
|
fetch('http://localhost:8080/sum?num_1=' + one.value + '&num_2=' + two.value)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((data) => result.value = data)
|
.then((data) => result.value = data)
|
||||||
});
|
});
|
||||||
@ -34,7 +34,7 @@ button_i.addEventListener("click", function()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fetch('http://localhost:8080/implement?num_1=' + one.value + '&num_2=' + two.value)
|
fetch('http://localhost:8080/cont?num_1=' + one.value + '&num_2=' + two.value)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((data) => result.value = data)
|
.then((data) => result.value = data)
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ button_m.addEventListener("click", function()
|
|||||||
{
|
{
|
||||||
console.log("Кнопка нажата.");
|
console.log("Кнопка нажата.");
|
||||||
|
|
||||||
fetch('http://localhost:8080/multiplication?num_1=' + one.value + '&num_2=' + two.value)
|
fetch('http://localhost:8080/mul?num_1=' + one.value + '&num_2=' + two.value)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((data) => result.value = data)
|
.then((data) => result.value = data)
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@ public class SpringOnlineCalculatorApplication {
|
|||||||
SpringApplication.run(SpringOnlineCalculatorApplication.class, args);
|
SpringApplication.run(SpringOnlineCalculatorApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@GetMapping("/plus")
|
@GetMapping("/plus")
|
||||||
public Integer Plus(@RequestParam(value="num_1") Integer num_1,
|
public Integer Plus(@RequestParam(value="num_1") Integer num_1,
|
||||||
@RequestParam(value="num_2") Integer num_2) {
|
@RequestParam(value="num_2") Integer num_2) {
|
||||||
@ -43,4 +44,5 @@ public class SpringOnlineCalculatorApplication {
|
|||||||
@RequestParam(value="num_2") Integer num_2) {
|
@RequestParam(value="num_2") Integer num_2) {
|
||||||
return num_1 * num_2;
|
return num_1 * num_2;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,62 @@
|
|||||||
package com.example.spring_online_calculator;
|
package com.example.spring_online_calculator;
|
||||||
|
|
||||||
|
import com.example.Service.MethodService;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class SpringOnlineCalculatorApplicationTests {
|
class SpringOnlineCalculatorApplicationTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MethodService methodService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void testMethodSumInt() {
|
||||||
|
final String res = methodService.Sum("1", "2", "int");
|
||||||
|
Assertions.assertEquals("3", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodSumString() {
|
||||||
|
final String res = methodService.Sum("1", "2", "string");
|
||||||
|
Assertions.assertEquals("12", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodMinusInt() {
|
||||||
|
final String res = methodService.Minus("1", "2", "int");
|
||||||
|
Assertions.assertEquals("-1", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodMinusString() {
|
||||||
|
final String res = methodService.Minus("214324", "4", "string");
|
||||||
|
Assertions.assertEquals("2132", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodMultInt() {
|
||||||
|
final String res = methodService.Multiply("1", "2", "int");
|
||||||
|
Assertions.assertEquals("2", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodMultString() {
|
||||||
|
final String res = methodService.Multiply("1", "2", "string");
|
||||||
|
Assertions.assertEquals("11", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodContainsInt() {
|
||||||
|
final String res = methodService.Contains("123", "2", "int");
|
||||||
|
Assertions.assertEquals("true", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMethodContainsString() {
|
||||||
|
final String res = methodService.Contains("1", "2", "string");
|
||||||
|
Assertions.assertEquals("false", res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user