diff --git a/combinator/src/main/java/com/iluwatar/combinator/CombinatorApp.java b/combinator/src/main/java/com/iluwatar/combinator/CombinatorApp.java index a69f933b1359..2ca6e16d774e 100644 --- a/combinator/src/main/java/com/iluwatar/combinator/CombinatorApp.java +++ b/combinator/src/main/java/com/iluwatar/combinator/CombinatorApp.java @@ -44,6 +44,20 @@ @Slf4j public class CombinatorApp { + private static final String TEXT = """ + It was many and many a year ago, + In a kingdom by the sea, + That a maiden there lived whom you may know + By the name of ANNABEL LEE; + And this maiden she lived with no other thought + Than to love and be loved by me. + I was a child and she was a child, + In this kingdom by the sea; + But we loved with a love that was more than love- + I and my Annabel Lee; + With a love that the winged seraphs of heaven + Coveted her and me."""; + /** * main. * @param args args @@ -69,19 +83,8 @@ public static void main(String[] args) { } private static String text() { - return - "It was many and many a year ago,\n" - + "In a kingdom by the sea,\n" - + "That a maiden there lived whom you may know\n" - + "By the name of ANNABEL LEE;\n" - + "And this maiden she lived with no other thought\n" - + "Than to love and be loved by me.\n" - + "I was a child and she was a child,\n" - + "In this kingdom by the sea;\n" - + "But we loved with a love that was more than love-\n" - + "I and my Annabel Lee;\n" - + "With a love that the winged seraphs of heaven\n" - + "Coveted her and me."; + + return TEXT; } } diff --git a/combinator/src/test/java/com/iluwatar/combinator/FinderTest.java b/combinator/src/test/java/com/iluwatar/combinator/FinderTest.java index db41098ed311..4f0d42258d62 100644 --- a/combinator/src/test/java/com/iluwatar/combinator/FinderTest.java +++ b/combinator/src/test/java/com/iluwatar/combinator/FinderTest.java @@ -32,7 +32,10 @@ class FinderTest { @Test void contains() { - var example = "the first one \nthe second one \n"; + var example = """ + the first one + the second one\s + """; var result = Finder.contains("second").find(example); assertEquals(1, result.size()); diff --git a/combinator/src/test/java/com/iluwatar/combinator/FindersTest.java b/combinator/src/test/java/com/iluwatar/combinator/FindersTest.java index 67972fd0bab8..bf34af1704f7 100644 --- a/combinator/src/test/java/com/iluwatar/combinator/FindersTest.java +++ b/combinator/src/test/java/com/iluwatar/combinator/FindersTest.java @@ -67,18 +67,19 @@ void expandedFinderTest() { private String text() { return - "It was many and many a year ago,\n" - + "In a kingdom by the sea,\n" - + "That a maiden there lived whom you may know\n" - + "By the name of ANNABEL LEE;\n" - + "And this maiden she lived with no other thought\n" - + "Than to love and be loved by me.\n" - + "I was a child and she was a child,\n" - + "In this kingdom by the sea;\n" - + "But we loved with a love that was more than love-\n" - + "I and my Annabel Lee;\n" - + "With a love that the winged seraphs of heaven\n" - + "Coveted her and me."; + """ + It was many and many a year ago, + In a kingdom by the sea, + That a maiden there lived whom you may know + By the name of ANNABEL LEE; + And this maiden she lived with no other thought + Than to love and be loved by me. + I was a child and she was a child, + In this kingdom by the sea; + But we loved with a love that was more than love- + I and my Annabel Lee; + With a love that the winged seraphs of heaven + Coveted her and me."""; } } diff --git a/composite-view/src/main/java/com/iluwatar/compositeview/AppServlet.java b/composite-view/src/main/java/com/iluwatar/compositeview/AppServlet.java index 7de1982a31bb..0cef25d2dd22 100644 --- a/composite-view/src/main/java/com/iluwatar/compositeview/AppServlet.java +++ b/composite-view/src/main/java/com/iluwatar/compositeview/AppServlet.java @@ -40,9 +40,14 @@ public final class AppServlet extends HttpServlet { private static final String CONTENT_TYPE = "text/html"; private String msgPartOne = "

This Server Doesn't Support"; - private String msgPartTwo = "Requests

\n" - + "

Use a GET request with boolean values for the following parameters

\n" - + "

'name'

\n

'bus'

\n

'sports'

\n

'sci'

\n

'world'

"; + private String msgPartTwo = """ + Requests +

Use a GET request with boolean values for the following parameters

+

'name'

+

'bus'

+

'sports'

+

'sci'

+

'world'

"""; private String destination = "newsDisplay.jsp"; diff --git a/composite-view/src/test/java/com/iluwatar/compositeview/AppServletTest.java b/composite-view/src/test/java/com/iluwatar/compositeview/AppServletTest.java index 547c6ed467f2..c585be29ebfb 100644 --- a/composite-view/src/test/java/com/iluwatar/compositeview/AppServletTest.java +++ b/composite-view/src/test/java/com/iluwatar/compositeview/AppServletTest.java @@ -40,9 +40,14 @@ class AppServletTest extends Mockito{ private String msgPartOne = "

This Server Doesn't Support"; - private String msgPartTwo = "Requests

\n" - + "

Use a GET request with boolean values for the following parameters

\n" - + "

'name'

\n

'bus'

\n

'sports'

\n

'sci'

\n

'world'

"; + private String msgPartTwo = """ + Requests +

Use a GET request with boolean values for the following parameters

+

'name'

+

'bus'

+

'sports'

+

'sci'

+

'world'

"""; private String destination = "newsDisplay.jsp"; @Test diff --git a/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java b/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java index 37ec26179c5c..07dbacd09702 100644 --- a/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java +++ b/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java @@ -24,7 +24,6 @@ */ package com.iluwatar.embedded.value; -import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; /** @@ -73,7 +72,7 @@ public static void main(String[] args) throws Exception { } // Initially, database is empty - LOGGER.info("Orders Query: {}", dataSource.queryOrders().collect(Collectors.toList())); + LOGGER.info("Orders Query: {}", dataSource.queryOrders().toList()); //Insert orders where shippingAddress is mapped to different columns of the same table dataSource.insertOrder(order1); @@ -83,7 +82,7 @@ public static void main(String[] args) throws Exception { // Query orders. // We'll create ShippingAddress object from city, state, pincode values from the table and add it to Order object - LOGGER.info("Orders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n"); + LOGGER.info("Orders Query: {}", dataSource.queryOrders().toList() + "\n"); //Query order by given id LOGGER.info("Query Order with id=2: {}", dataSource.queryOrder(2)); @@ -93,7 +92,7 @@ public static void main(String[] args) throws Exception { //Since we'd mapped address in the same table, deleting order will also take out the shipping address details. LOGGER.info("Remove Order with id=1"); dataSource.removeOrder(1); - LOGGER.info("\nOrders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n"); + LOGGER.info("\nOrders Query: {}", dataSource.queryOrders().toList() + "\n"); //After successful demonstration of the pattern, drop the table if (dataSource.deleteSchema()) { diff --git a/embedded-value/src/main/java/com/iluwatar/embedded/value/DataSource.java b/embedded-value/src/main/java/com/iluwatar/embedded/value/DataSource.java index 520331b50000..5704dff8f62a 100644 --- a/embedded-value/src/main/java/com/iluwatar/embedded/value/DataSource.java +++ b/embedded-value/src/main/java/com/iluwatar/embedded/value/DataSource.java @@ -87,7 +87,7 @@ public String getSchema() { var resultSet = getschema.executeQuery(GET_SCHEMA); var sb = new StringBuilder(); while (resultSet.next()) { - sb.append("Col name: " + resultSet.getString(1) + ", Col type: " + resultSet.getString(2) + "\n"); + sb.append("Col name: ").append(resultSet.getString(1)).append(", Col type: ").append(resultSet.getString(2)).append("\n"); } getschema.close(); return sb.toString(); diff --git a/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/App.java b/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/App.java index b65c4e94fa62..33a61def59ff 100644 --- a/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/App.java +++ b/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/App.java @@ -150,7 +150,12 @@ public void runInteractiveMode() { var option = -1; while (option != 4) { LOGGER.info("Hello. Would you like to boil some eggs?"); - LOGGER.info("(1) BOIL AN EGG \n(2) STOP BOILING THIS EGG \n(3) HOW ARE MY EGGS? \n(4) EXIT"); + LOGGER.info(""" + (1) BOIL AN EGG + (2) STOP BOILING THIS EGG + (3) HOW ARE MY EGGS? + (4) EXIT + """); LOGGER.info("Choose [1,2,3,4]: "); option = s.nextInt(); diff --git a/metadata-mapping/src/main/java/com/iluwatar/metamapping/utils/DatabaseUtil.java b/metadata-mapping/src/main/java/com/iluwatar/metamapping/utils/DatabaseUtil.java index 2a47c29ced20..5f5dddcbc833 100644 --- a/metadata-mapping/src/main/java/com/iluwatar/metamapping/utils/DatabaseUtil.java +++ b/metadata-mapping/src/main/java/com/iluwatar/metamapping/utils/DatabaseUtil.java @@ -34,13 +34,13 @@ @Slf4j public class DatabaseUtil { private static final String DB_URL = "jdbc:h2:mem:metamapping"; - private static final String CREATE_SCHEMA_SQL = "DROP TABLE IF EXISTS `user_account`;" - + "CREATE TABLE `user_account` (\n" - + " `id` int(11) NOT NULL AUTO_INCREMENT,\n" - + " `username` varchar(255) NOT NULL,\n" - + " `password` varchar(255) NOT NULL,\n" - + " PRIMARY KEY (`id`)\n" - + ");"; + private static final String CREATE_SCHEMA_SQL = """ + DROP TABLE IF EXISTS `user_account`;CREATE TABLE `user_account` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + PRIMARY KEY (`id`) + );"""; /** * Hide constructor. diff --git a/property/src/test/java/com/iluwatar/property/CharacterTest.java b/property/src/test/java/com/iluwatar/property/CharacterTest.java index dfc22a6d2640..bbfe5e879d5c 100644 --- a/property/src/test/java/com/iluwatar/property/CharacterTest.java +++ b/property/src/test/java/com/iluwatar/property/CharacterTest.java @@ -79,15 +79,33 @@ void testToString() { prototype.set(Stats.ARMOR, 1); prototype.set(Stats.AGILITY, 2); prototype.set(Stats.INTELLECT, 3); - assertEquals("Stats:\n - AGILITY:2\n - ARMOR:1\n - INTELLECT:3\n", prototype.toString()); + var message = """ + Stats: + - AGILITY:2 + - ARMOR:1 + - INTELLECT:3 + """; + assertEquals(message, prototype.toString()); final var stupid = new Character(Type.ROGUE, prototype); stupid.remove(Stats.INTELLECT); - assertEquals("Character type: ROGUE\nStats:\n - AGILITY:2\n - ARMOR:1\n", stupid.toString()); + String expectedStupidString = """ + Character type: ROGUE + Stats: + - AGILITY:2 + - ARMOR:1 + """; + assertEquals(expectedStupidString, stupid.toString()); final var weak = new Character("weak", prototype); weak.remove(Stats.ARMOR); - assertEquals("Player: weak\nStats:\n - AGILITY:2\n - INTELLECT:3\n", weak.toString()); + String expectedWeakString = """ + Player: weak + Stats: + - AGILITY:2 + - INTELLECT:3 + """; + assertEquals(expectedWeakString, weak.toString()); }