diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
new file mode 100644
index 0000000..2f44ced
--- /dev/null
+++ b/.github/workflows/maven.yml
@@ -0,0 +1,29 @@
+# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+name: Test Case Report
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 11 Amazon Corretto
+ uses: actions/setup-java@v3
+ with:
+ java-version: '11'
+ distribution: 'corretto'
+ cache: maven
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
+ - name: Test with Maven
+ run: mvn -B test --file pom.xml
+
diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml
new file mode 100644
index 0000000..bd14a83
--- /dev/null
+++ b/.github/workflows/super-linter.yml
@@ -0,0 +1,29 @@
+# This workflow executes several linters on changed files based on languages used in your code base whenever
+# you push a code or open a pull request.
+#
+# You can adjust the behavior by modifying this file.
+# For more information, see:
+# https://github.com/github/super-linter
+name: Lint Code Base
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+jobs:
+ run-lint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ # Full git history is needed to get a proper list of changed files within `super-linter`
+ fetch-depth: 0
+
+ - name: Lint Code Base
+ uses: github/super-linter@v4
+ env:
+ VALIDATE_ALL_CODEBASE: false
+ DEFAULT_BRANCH: main
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 9f91b2d..e9ddf70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@ target/
!**/src/test/**/target/
### IntelliJ IDEA ###
+.idea/
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
@@ -38,4 +39,5 @@ build/
.DS_Store
### SonarLint ###
-.idea/sonarlint/
\ No newline at end of file
+
+!/.idea/sonarlint/
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4258c62..0bc224b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec b/.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec
deleted file mode 100644
index e69de29..0000000
diff --git a/.idea/sonarlint/issuestore/8/a/8a6dae537be9f47878c6964c6ee40cab0ca75e28 b/.idea/sonarlint/issuestore/8/a/8a6dae537be9f47878c6964c6ee40cab0ca75e28
deleted file mode 100644
index e69de29..0000000
diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb
index ff5edbe..e69de29 100644
--- a/.idea/sonarlint/issuestore/index.pb
+++ b/.idea/sonarlint/issuestore/index.pb
@@ -1,5 +0,0 @@
-
-w
-G.idea/sonarlint/issuestore/e/d/ed67eb178d523a4b3f117dcbe0eda5196367ceec,8\a\8a6dae537be9f47878c6964c6ee40cab0ca75e28
-w
-G.idea/sonarlint/issuestore/4/4/442292b8a7efeabbe4cc176709b833b1792140ec,8\6\863e0292fd7e9b3e74dafd6cc01f73ba76346482
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 33f4569..4e9c26f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,7 @@
-
-
-
-
-
+
@@ -52,7 +48,18 @@
"com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrarySuperClass.JUnit5": "",
"full.screen.before.presentation.mode": "false",
"last_opened_file_path": "C:/Users/divya/Exercism/java/need-for-speed",
- "settings.editor.selected.configurable": "reference.settingsdialog.IDE.editor.colors.Color Scheme Font"
+ "project.structure.last.edited": "Project",
+ "project.structure.proportion": "0.15",
+ "project.structure.side.proportion": "0.0",
+ "settings.editor.selected.configurable": "preferences.pluginManager"
+ },
+ "keyToStringList": {
+ "DatabaseDriversLRU": [
+ "mysql"
+ ],
+ "com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
+ "Markdown"
+ ]
}
}
@@ -157,6 +164,7 @@
+ 1652464516513
@@ -277,7 +285,28 @@
1652633662838
-
+
+ 1652816083393
+
+
+
+ 1652816083393
+
+
+ 1652819174296
+
+
+
+ 1652819174296
+
+
+ 1652819472258
+
+
+
+ 1652819472258
+
+
@@ -310,7 +339,10 @@
-
+
+
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..742effe
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 Divyansh Bhardwaj
+
+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.
diff --git a/README.md b/README.md
index 5779e48..454aed7 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+[](https://github.com/dbc2201/JavaCodingProblem1/actions/workflows/maven.yml)
# Java Coding Problems
## Chapter 1: Strings, Numbers, and Math
@@ -37,4 +38,4 @@ Write a program that counts duplicate characters from a given `String`.
**Suggested Reading:**
1. [HashMap (Java SE 18 & JDK 18)](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/HashMap.html)
-2. [Managing the Content of a Map (dev.java)](https://dev.java/learn/managing-the-content-of-a-map/)
\ No newline at end of file
+2. [Managing the Content of a Map (dev.java)](https://dev.java/learn/managing-the-content-of-a-map/)
diff --git a/pom.xml b/pom.xml
index 1149d30..629d57c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,8 +17,31 @@
- 18
- 18
+ UTF-8
+ 11
+ 11
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.9.0
+
+ 11
+ 11
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/io/github/dbc/DuplicateCharactersCounter.java b/src/main/java/io/github/dbc/DuplicateCharactersCounter.java
index 9020649..49cee5a 100644
--- a/src/main/java/io/github/dbc/DuplicateCharactersCounter.java
+++ b/src/main/java/io/github/dbc/DuplicateCharactersCounter.java
@@ -8,6 +8,7 @@ public class DuplicateCharactersCounter {
*
* @param string String to count duplicate characters.
* @return Map with characters and their count.
+ * @throws IllegalArgumentException if the input is null or empty.
*/
public Map countDuplicateCharacters(String string) {
return Map.of();
diff --git a/src/test/java/io/github/dbc/DuplicateCharactersCounterTest.java b/src/test/java/io/github/dbc/DuplicateCharactersCounterTest.java
index 1489a67..537d1df 100644
--- a/src/test/java/io/github/dbc/DuplicateCharactersCounterTest.java
+++ b/src/test/java/io/github/dbc/DuplicateCharactersCounterTest.java
@@ -26,8 +26,7 @@ void shouldReturnMapOfCorrectSize(String input) {
// Act
var characterIntegerMap = counter.countDuplicateCharacters(input);
// Assert
- assertEquals(input.length(), characterIntegerMap.size(),
- "the map should have the same size as the input string");
+ assertEquals(input.length(), characterIntegerMap.size(), "the map should have the same size as the input string");
}
@Test