diff --git a/pom.xml b/pom.xml index db06c59a9479..dc8bb25d644b 100644 --- a/pom.xml +++ b/pom.xml @@ -227,6 +227,12 @@ + + org.junit.platform + junit-platform-launcher + 1.8.2 + test + org.springframework.boot spring-boot-dependencies diff --git a/update-header.sh b/update-header.sh index 48da4dcd6125..568d00d52a03 100755 --- a/update-header.sh +++ b/update-header.sh @@ -1,4 +1,29 @@ #!/bin/bash +# +# This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). +# +# The MIT License +# Copyright © 2014-2022 Ilkka Seppälä +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + # Find all README.md files in subdirectories one level deep # and replace "### " with "## " at the beginning of lines diff --git a/visitor/src/main/java/com/iluwatar/visitor/example/DataTransferHashMap.java b/visitor/src/main/java/com/iluwatar/visitor/example/DataTransferHashMap.java new file mode 100644 index 000000000000..c3d5c13ac4f4 --- /dev/null +++ b/visitor/src/main/java/com/iluwatar/visitor/example/DataTransferHashMap.java @@ -0,0 +1,51 @@ +package com.iluwatar.visitor.example; +import java.util.HashMap; +import java.util.Map; + +public class DataTransferHashMap { + private Map dataMap; + + public DataTransferHashMap() { + // Initialize the map + dataMap = new HashMap<>(); + } + + // Method to add data + public void addData(String key, String value) { + dataMap.put(key, value); + } + + // Method to retrieve data + public String getData(String key) { + return dataMap.get(key); + } + + // Method to remove data + public void removeData(String key) { + dataMap.remove(key); + } + + // Method to display all data in the map + public void displayData() { + for (Map.Entry entry : dataMap.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + } + + public static void main(String[] args) { + // Creating an instance of the DataTransferHashMap class + DataTransferHashMap transfer = new DataTransferHashMap(); + + // Adding some data + transfer.addData("Name", "John"); + transfer.addData("Age", "25"); + transfer.addData("Location", "New York"); + + // Displaying all data + transfer.displayData(); + + // Retrieve a single value + System.out.println("Retrieved Name: " + transfer.getData("Name")); + } +} + diff --git a/visitor/src/test/java/com/iluwatar/visitor/example/datatransfer/DataTransferHashMapTest.java b/visitor/src/test/java/com/iluwatar/visitor/example/datatransfer/DataTransferHashMapTest.java new file mode 100644 index 000000000000..cec318d98bfd --- /dev/null +++ b/visitor/src/test/java/com/iluwatar/visitor/example/datatransfer/DataTransferHashMapTest.java @@ -0,0 +1,47 @@ +package com.iluwatar.visitor.example.datatransfer; +import com.iluwatar.visitor.example.DataTransferHashMap; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +public class DataTransferHashMapTest { + + @Test + public void testAddData() { + DataTransferHashMap transferHash = new DataTransferHashMap(); + transferHash.addData("Name", "Alice"); + + // Assert that the data is added correctly + assertEquals("Alice", transferHash.getData("Name")); + } + + @Test + public void testGetData() { + DataTransferHashMap transferHash = new DataTransferHashMap(); + transferHash.addData("City", "Paris"); + + // Assert that the correct value is retrieved + assertEquals("Paris", transferHash.getData("City")); + } + + @Test + public void testRemoveData() { + DataTransferHashMap transferHash = new DataTransferHashMap(); + transferHash.addData("Country", "France"); + transferHash.removeData("Country"); + + // Assert that the data is removed + assertNull(transferHash.getData("Country")); + } + + @Test + public void testDisplayData() { + DataTransferHashMap transferHash = new DataTransferHashMap(); + transferHash.addData("Name", "John"); + transferHash.addData("Age", "30"); + + + // Mock a console output if needed (or just visually verify it during test runs) + transferHash.displayData(); + + } +}