Fix case insensitive bug #1

Merged
ansv7779 merged 2 commits from fix-case-bug into main 2025-05-05 14:13:25 +02:00
2 changed files with 17 additions and 15 deletions

View File

@ -13,24 +13,17 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Set up JDK 21 - name: Set up JDK 21
uses: actions/setup-java@v3 uses: actions/setup-java@v4
with: with:
java-version: '21' java-version: '21'
distribution: 'temurin' distribution: 'temurin'
cache: 'maven'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven - name: Build with Maven
run: mvn clean install run: ./mvnw clean verify
- name: Run tests - name: Run tests
run: mvn test run: ./mvnw test
- name: Run Checkstyle - name: Run Checkstyle
run: mvn checkstyle:check run: ./mvnw checkstyle:check

View File

@ -1,5 +1,6 @@
package dsv.su.apimposter.service; package dsv.su.apimposter.service;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -93,10 +94,18 @@ public class MockService {
if (expected == null) return true; // No condition defined pass if (expected == null) return true; // No condition defined pass
if (actual == null) return false; if (actual == null) return false;
Map<String, String> lowerCasedActual = new HashMap<>();
for (Map.Entry<String, String> entry : actual.entrySet()) {
lowerCasedActual.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue());
}
for (Map.Entry<String, String> entry : expected.entrySet()) { for (Map.Entry<String, String> entry : expected.entrySet()) {
String key = entry.getKey().toLowerCase(Locale.ROOT); String expectedKey = entry.getKey().toLowerCase(Locale.ROOT);
String value = entry.getValue(); String expectedValue = entry.getValue();
if (!value.equals(actual.get(key))) return false;
if (!expectedValue.equals(lowerCasedActual.get(expectedKey))) {
return false;
}
} }
return true; return true;