diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock index bd47bf0..8bae2e3 100644 Binary files a/.gradle/7.3.3/checksums/checksums.lock and b/.gradle/7.3.3/checksums/checksums.lock differ diff --git a/.gradle/7.3.3/checksums/md5-checksums.bin b/.gradle/7.3.3/checksums/md5-checksums.bin index cef76af..1d2d681 100644 Binary files a/.gradle/7.3.3/checksums/md5-checksums.bin and b/.gradle/7.3.3/checksums/md5-checksums.bin differ diff --git a/.gradle/7.3.3/checksums/sha1-checksums.bin b/.gradle/7.3.3/checksums/sha1-checksums.bin index 7f507df..5611eb1 100644 Binary files a/.gradle/7.3.3/checksums/sha1-checksums.bin and b/.gradle/7.3.3/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index a9df4dd..ebb1a9f 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.bin and b/.gradle/7.3.3/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index 14a01b6..660b846 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.lock and b/.gradle/7.3.3/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index abb13b4..f8b4371 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.bin and b/.gradle/7.3.3/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index ed4d7d8..a48066d 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and b/.gradle/7.3.3/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index ba5920e..8741a06 100644 Binary files a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin and b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 3212ac5..210296c 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 9a91245..161d6b8 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 30f592b..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -sbapp \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 49504ef..e258bdc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -2,4 +2,7 @@ + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5e13045..8447969 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,9 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'junit:junit:4.13.1' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'com.h2database:h2:2.1.214' + implementation 'junit:junit:4.13.2' testImplementation 'org.springframework.boot:spring-boot-starter-test' } diff --git a/src/main/java/ru/ulstu/is/sbapp/Controllers/StringController.java b/src/main/java/ru/ulstu/is/sbapp/Controllers/StringController.java deleted file mode 100644 index f8424b2..0000000 --- a/src/main/java/ru/ulstu/is/sbapp/Controllers/StringController.java +++ /dev/null @@ -1,44 +0,0 @@ -package ru.ulstu.is.sbapp.Controllers; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import ru.ulstu.is.sbapp.Services.ConverterService; - -@RestController -public class StringController { - private final ConverterService converterService; - - public StringController(ConverterService converterService) - { - this.converterService = converterService; - } - @GetMapping("/toupper") - public Object toUpper(@RequestParam(value = "value",defaultValue = " ") Object value, - @RequestParam(value = "type",defaultValue = "String") String converterType) - { - return converterService.toUpper(value,converterType); - } - - @GetMapping("/removews") - public Object removeWhitespaces(@RequestParam(value = "value",defaultValue = " ") Object value, - @RequestParam(value = "type",defaultValue = "String") String converterType) - { - return converterService.removeWhitespaces(value,converterType); - } - - @GetMapping("/removedigits") - public Object removeDigits(@RequestParam(value = "value",defaultValue = " ") Object value, - @RequestParam(value = "type",defaultValue = "String") String converterType) - { - return converterService.removeDigits(value,converterType); - } - - @GetMapping("/tolower") - public Object toLower(@RequestParam(value = "value",defaultValue = " ") Object value, - @RequestParam(value = "type",defaultValue = "String") String converterType) - { - return converterService.toLower(value,converterType); - } -} diff --git a/src/main/java/ru/ulstu/is/sbapp/Implementation/StringArrayConverter.java b/src/main/java/ru/ulstu/is/sbapp/Implementation/StringArrayConverter.java deleted file mode 100644 index a986f80..0000000 --- a/src/main/java/ru/ulstu/is/sbapp/Implementation/StringArrayConverter.java +++ /dev/null @@ -1,31 +0,0 @@ -package ru.ulstu.is.sbapp.Implementation; - -import org.springframework.stereotype.Component; -import ru.ulstu.is.sbapp.Interfaces.Converter; - -import java.util.Arrays; -import java.util.stream.Collectors; - -@Component(value = "AString") -public class StringArrayConverter implements Converter -{ - @Override - public String[] toUpper(String[] value) { - return Arrays.stream(value).map(word -> word.toUpperCase()).toArray(String[]::new); - } - - @Override - public String[] removeWhitespaces(String[] value) { - return (String[]) Arrays.stream(value).map(word -> word.replaceAll("\s+","")).toArray(String[]::new); - } - - @Override - public String[] removeDigits(String[] value) { - return (String[]) Arrays.stream(value).map(word -> word.replaceAll("\\d","")).toArray(String[]::new); - } - - @Override - public String[] toLower(String[] value) { - return (String[]) Arrays.stream(value).map(word -> word.toLowerCase()).toArray(String[]::new); - } -} diff --git a/src/main/java/ru/ulstu/is/sbapp/Implementation/StringConverter.java b/src/main/java/ru/ulstu/is/sbapp/Implementation/StringConverter.java deleted file mode 100644 index 504d8c9..0000000 --- a/src/main/java/ru/ulstu/is/sbapp/Implementation/StringConverter.java +++ /dev/null @@ -1,28 +0,0 @@ -package ru.ulstu.is.sbapp.Implementation; - -import org.springframework.stereotype.Component; -import ru.ulstu.is.sbapp.Interfaces.Converter; - -@Component(value = "String") -public class StringConverter implements Converter -{ - @Override - public String toUpper(String value) { - return value.toString().toUpperCase(); - } - - @Override - public String removeWhitespaces(String value) { - return value.toString().replaceAll("\s+",""); - } - - @Override - public String removeDigits(String value) { - return value.toString().replaceAll("\\d",""); - } - - @Override - public String toLower(String value) { - return value.toString().toLowerCase(); - } -} diff --git a/src/main/java/ru/ulstu/is/sbapp/Interfaces/Converter.java b/src/main/java/ru/ulstu/is/sbapp/Interfaces/Converter.java deleted file mode 100644 index 6d6d6fb..0000000 --- a/src/main/java/ru/ulstu/is/sbapp/Interfaces/Converter.java +++ /dev/null @@ -1,11 +0,0 @@ -package ru.ulstu.is.sbapp.Interfaces; - -import org.springframework.context.annotation.Bean; - -public interface Converter -{ - public T toUpper(T value); - public T removeWhitespaces(T value); - public T removeDigits(T value); - public T toLower(T value); -} diff --git a/src/main/java/ru/ulstu/is/sbapp/Services/ConverterService.java b/src/main/java/ru/ulstu/is/sbapp/Services/ConverterService.java deleted file mode 100644 index c1faf53..0000000 --- a/src/main/java/ru/ulstu/is/sbapp/Services/ConverterService.java +++ /dev/null @@ -1,52 +0,0 @@ -package ru.ulstu.is.sbapp.Services; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Service; -import ru.ulstu.is.sbapp.Interfaces.Converter; -import java.util.Arrays; - -@Service -public class ConverterService -{ - private final ApplicationContext applicationContext; - public ConverterService(ApplicationContext applicationContext) - { - this.applicationContext = applicationContext; - } - public Object toUpper(Object value, String converterType) - { - Converter converter = (Converter) applicationContext.getBean(converterType); - if(converterType.equals("String")) { - return converter.toUpper(value); - } - - return converter.toUpper(value.toString().split("\s+")); - } - public Object removeWhitespaces(Object value, String converterType) - { - Converter converter = (Converter) applicationContext.getBean(converterType); - if(converterType.equals("String")) { - return converter.removeWhitespaces(value); - } - return converter.removeWhitespaces(value.toString().split("\s+")); - } - public Object removeDigits(Object value, String converterType) - { - Converter converter = (Converter) applicationContext.getBean(converterType); - if(converterType.equals("String")) - { - return converter.removeDigits(value); - } - return converter.removeDigits(value.toString().split("\s+")); - } - public Object toLower(Object value, String converterType) - { - Converter converter = (Converter) applicationContext.getBean(converterType); - if(converterType.equals("String")) - { - return converter.toLower(value); - } - return converter.toLower(value.toString().split("\s+")); - } -} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..da7b0b1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,11 @@ - +spring.main.banner-mode=off +#server.port=8080 +spring.datasource.url=jdbc:h2:file:./data +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password=password +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.jpa.hibernate.ddl-auto=update +spring.h2.console.enabled=true +spring.h2.console.settings.trace=false +spring.h2.console.settings.web-allow-others=false diff --git a/src/test/java/ru/ulstu/is/sbapp/ConverterServiceTests.java b/src/test/java/ru/ulstu/is/sbapp/ConverterServiceTests.java deleted file mode 100644 index b9d3f68..0000000 --- a/src/test/java/ru/ulstu/is/sbapp/ConverterServiceTests.java +++ /dev/null @@ -1,60 +0,0 @@ -package ru.ulstu.is.sbapp; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import ru.ulstu.is.sbapp.Services.ConverterService; - -@SpringBootTest -public class ConverterServiceTests -{ - @Autowired - ConverterService converterService; - - @Test - public void stringToUpper() - { - Assertions.assertEquals("LOVE PROGRAMMING",converterService.toUpper("love programming","String")); - } - @Test - public void stringToLower() - { - Assertions.assertEquals("love programming",converterService.toLower("LOVE PROGRAMMING","String")); - } - @Test - public void stringRemoveDigits() - { - Assertions.assertEquals("LVE PRGRAMMNG",converterService.removeDigits("L0VE PR0GRAMM1NG","String")); - } - @Test - public void stringRemoveWhitespaces() - { - Assertions.assertEquals("loveprogramming",converterService.removeWhitespaces("lo ve pro gramm i ng","String")); - } - - @Test - public void aStringToUpper() - { - String expected[] = new String[]{"LOVE","PROGRAMMING"}; - Assertions.assertArrayEquals(expected,(String[])converterService.toUpper("love programming","AString")); - } - @Test - public void aStringToLower() - { - String expected[] = new String[]{"love","programming"}; - Assertions.assertArrayEquals(expected,(String[])converterService.toLower("LOVE PROGRAMMING","AString")); - } - @Test - public void aStringRemoveDigits() - { - String expected[] = new String[]{"LVE","PRGRAMMNG"}; - Assertions.assertArrayEquals(expected, (String[]) converterService.removeDigits("L0VE PR0GRAMM1NG","AString")); - } - @Test - public void aStringRemoveWhitespaces() - { - String expected[] = new String[]{"lo","ve","pro","gramm","i","ng"}; - Assertions.assertArrayEquals(expected,(String[])converterService.removeWhitespaces("lo ve pro gramm i ng","AString")); - } -}