From 46ecf5eac3dd7e4fc8db2de81ab0401914988c9b Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Tue, 28 Feb 2023 11:36:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=A02=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ru/ulstu/is/lab1/Lab1.java | 2 -- .../java/ru/ulstu/is/lab1/speaker/domain/MethodInt.java | 8 +++----- src/test/java/ru/ulstu/is/lab1/Lab1ApplicationTests.java | 6 ++++++ 3 files changed, 9 insertions(+), 7 deletions(-) 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")); + } }