diff --git a/src/main/java/ru/ulstu/is/lab1/Lab1.java b/src/main/java/ru/ulstu/is/lab1/Lab1.java index fb8823a..d46ba2f 100644 --- a/src/main/java/ru/ulstu/is/lab1/Lab1.java +++ b/src/main/java/ru/ulstu/is/lab1/Lab1.java @@ -2,8 +2,6 @@ package ru.ulstu.is.lab1; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication diff --git a/src/main/java/ru/ulstu/is/lab1/speaker/domain/MethodInt.java b/src/main/java/ru/ulstu/is/lab1/speaker/domain/MethodInt.java index ebd47bd..ba393b6 100644 --- a/src/main/java/ru/ulstu/is/lab1/speaker/domain/MethodInt.java +++ b/src/main/java/ru/ulstu/is/lab1/speaker/domain/MethodInt.java @@ -17,12 +17,10 @@ public class MethodInt implements IMethod{ } public Integer Comparison(Integer first, Integer second) { - int num1 = first; - int num2 = second; - if (num1 >= num2){ - return num1; + if (first >= second){ + return first; }else{ - return num2; + return second; } } } diff --git a/src/test/java/ru/ulstu/is/lab1/Lab1ApplicationTests.java b/src/test/java/ru/ulstu/is/lab1/Lab1ApplicationTests.java index 772942c..12110ed 100644 --- a/src/test/java/ru/ulstu/is/lab1/Lab1ApplicationTests.java +++ b/src/test/java/ru/ulstu/is/lab1/Lab1ApplicationTests.java @@ -1,5 +1,6 @@ package ru.ulstu.is.lab1; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; import ru.ulstu.is.lab1.speaker.service.MethodService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -55,4 +56,9 @@ class Lab1ApplicationTests { final String res = methodService.Com("846734", "312", "string"); Assertions.assertEquals("846734", res); } + @Test + void testNumberFormatException() { + final String res = methodService.Sum("п", 3, "int"); + Assertions.assertThrows(NumberFormatException.class, () -> methodService.Sum(5, 3, "int")); + } }