From 270acf62e46bc420a0517d756fa63b1742b904b2 Mon Sep 17 00:00:00 2001 From: Niket Agrawal Date: Tue, 7 Nov 2023 21:49:49 +0530 Subject: [PATCH] Formatter Changes --- .../ResultSetToMapUnitTest.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/persistence-modules/core-java-persistence-3/src/test/java/com/baeldung/resultsettomap/ResultSetToMapUnitTest.java b/persistence-modules/core-java-persistence-3/src/test/java/com/baeldung/resultsettomap/ResultSetToMapUnitTest.java index c8a6351804..e449beb83a 100644 --- a/persistence-modules/core-java-persistence-3/src/test/java/com/baeldung/resultsettomap/ResultSetToMapUnitTest.java +++ b/persistence-modules/core-java-persistence-3/src/test/java/com/baeldung/resultsettomap/ResultSetToMapUnitTest.java @@ -45,7 +45,8 @@ public class ResultSetToMapUnitTest { @Test public void whenUsingContainsKey_thenConvertResultSetToMap() throws SQLException { - ResultSet resultSet = connection.prepareStatement("SELECT * FROM employee").executeQuery(); + ResultSet resultSet = connection.prepareStatement("SELECT * FROM employee") + .executeQuery(); Map> valueMap = new HashMap<>(); while (resultSet.next()) { @@ -54,22 +55,27 @@ public class ResultSetToMapUnitTest { if (!valueMap.containsKey(empCity)) { valueMap.put(empCity, new ArrayList<>()); } - valueMap.get(empCity).add(empName); + valueMap.get(empCity) + .add(empName); } - assertEquals(3, valueMap.get("London").size()); + assertEquals(3, valueMap.get("London") + .size()); } @Test public void whenUsingComputeIfAbsent_thenConvertResultSetToMap() throws SQLException { - ResultSet resultSet = connection.prepareStatement("SELECT * FROM employee").executeQuery(); + ResultSet resultSet = connection.prepareStatement("SELECT * FROM employee") + .executeQuery(); Map> valueMap = new HashMap<>(); while (resultSet.next()) { String empCity = resultSet.getString("empCity"); String empName = resultSet.getString("empName"); - valueMap.computeIfAbsent(empCity, data -> new ArrayList<>()).add(empName); + valueMap.computeIfAbsent(empCity, data -> new ArrayList<>()) + .add(empName); } - assertEquals(3, valueMap.get("London").size()); + assertEquals(3, valueMap.get("London") + .size()); } @Test @@ -81,15 +87,17 @@ public class ResultSetToMapUnitTest { while (resultSet.next()) { String empCity = resultSet.getString("empCity"); String empName = resultSet.getString("empName"); - result.computeIfAbsent(empCity, data -> new ArrayList<>()).add(empName); + result.computeIfAbsent(empCity, data -> new ArrayList<>()) + .add(empName); } return result; } }; - + QueryRunner run = new QueryRunner(); Map> valueMap = run.query(connection, "SELECT * FROM employee", handler); - assertEquals(3, valueMap.get("London").size()); + assertEquals(3, valueMap.get("London") + .size()); } @After