lab2: tests and fixes
This commit is contained in:
parent
32cb0492c3
commit
5d6c6afeba
@ -15,11 +15,11 @@ public class TestController {
|
|||||||
return "Your number = " + random.nextInt(0,100);
|
return "Your number = " + random.nextInt(0,100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/sum")
|
// @GetMapping("/sum")
|
||||||
public String getSum(@RequestParam(name = "val1", defaultValue = "1") int val1,
|
// public String getSum(@RequestParam(name = "val1", defaultValue = "1") int val1,
|
||||||
@RequestParam(name="val2",defaultValue = "2") int val2) {
|
// @RequestParam(name="val2",defaultValue = "2") int val2) {
|
||||||
return "Your summa = " + (val1 + val2);
|
// return "Your summa = " + (val1 + val2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@GetMapping("/upperCase")
|
@GetMapping("/upperCase")
|
||||||
public String toUpperCase(String word) {
|
public String toUpperCase(String word) {
|
||||||
@ -28,8 +28,8 @@ public class TestController {
|
|||||||
return "Incorrect word";
|
return "Incorrect word";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/length")
|
// @GetMapping("/length")
|
||||||
public String length(String name) {
|
// public String length(String name) {
|
||||||
return "Length = " + name.length();
|
// return "Length = " + name.length();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.example.springip;
|
||||||
|
|
||||||
|
import com.example.springip.service.OperationService;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class SpringipApplicationTests {
|
||||||
|
@Autowired
|
||||||
|
OperationService operationService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSumString() {
|
||||||
|
final String res = (String) operationService.sum("Привет ", "Мир!");
|
||||||
|
Assertions.assertEquals("Привет Мир!", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSumNum() {
|
||||||
|
final Integer res = (Integer) operationService.sum("1", "2");
|
||||||
|
Assertions.assertEquals(3, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMulString() {
|
||||||
|
final String res = (String) operationService.mul("A", 4);
|
||||||
|
Assertions.assertEquals("AAAA", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMulNum() {
|
||||||
|
final Integer res = (Integer) operationService.mul("2", 4);
|
||||||
|
Assertions.assertEquals(8, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLengthString() {
|
||||||
|
final Integer res = (Integer) operationService.length("Hello");
|
||||||
|
Assertions.assertEquals(5, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLengthNum() {
|
||||||
|
final Integer res = (Integer) operationService.length("777");
|
||||||
|
Assertions.assertEquals(3, res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testStWString() {
|
||||||
|
final boolean res = (boolean) operationService.startsWith("Orange","Or");
|
||||||
|
Assertions.assertEquals(true, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStWNum() {
|
||||||
|
final boolean res = (boolean) operationService.startsWith("777","77");
|
||||||
|
Assertions.assertEquals(true, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user