Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ private static class TypedKeyMapInternal implements TypedKeyMap, Map<String, Obj
private Entry[] findWithPrevious(String typedKeyName) {
Entry current = _head;
if (current != null) {
if (current._key.getName().equals(typedKeyName)) {
if (current._key.getName().equalsIgnoreCase(typedKeyName)) {
return new Entry[]{null, current};
}
while (current._next != null) {
if (current._next._key.getName().equals(typedKeyName)) {
if (current._next._key.getName().equalsIgnoreCase(typedKeyName)) {
return new Entry[]{current, current._next};
}
current = current._next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ public void FlowData_AddDataString_GetDataString() {
assertEquals(data, result);
}

@Test
public void FlowData_AddDataString_GetDataStringOtherCase() {
flowData.process();
ElementData data = flowData.getOrAdd(
"device",
(FlowElement.DataFactory<ElementData>) flowData -> new TestElementData(mock(Logger.class), flowData));

assertEquals(data, flowData.get("Device"));
assertEquals(data, flowData.get("DEVICE"));
}

@Test
public void FlowData_GetOrAddOtherCase_SameData() {
flowData.process();
ElementData data = flowData.getOrAdd(
"device",
(FlowElement.DataFactory<ElementData>) flowData -> new TestElementData(mock(Logger.class), flowData));

ElementData again = flowData.getOrAdd(
"Device",
(FlowElement.DataFactory<ElementData>) flowData -> new TestElementData(mock(Logger.class), flowData));

assertSame(data, again);
}

@Test
public void FlowData_AddDataString_GetDataTypedKey() {
flowData.process();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

package fiftyone.pipeline.core.typed;

import org.junit.Test;

import java.util.Collections;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* Keys ignore case, as the specification's access to results asks of
* string keys, in both kinds of map the builder makes.
*/
public class TypedKeyMapKeyCaseTests {

private static final boolean[] CONCURRENT = {false, true};

@Test
public void get_OtherCase_FindsTheValue() {
for (boolean concurrent : CONCURRENT) {
TypedKeyMap map = new TypedKeyMapBuilder(concurrent).build();
map.put(new TypedKeyDefault<>("device", String.class), "value");

assertEquals("value",
map.get(new TypedKeyDefault<>("Device", String.class)));
assertEquals("value",
map.get(new TypedKeyDefault<>("DEVICE", String.class)));
assertTrue(map.containsKey("Device"));
}
}

@Test
public void put_OtherCase_ReplacesTheValue() {
for (boolean concurrent : CONCURRENT) {
TypedKeyMap map = new TypedKeyMapBuilder(concurrent).build();
map.put(new TypedKeyDefault<>("device", String.class), "first");
map.put(new TypedKeyDefault<>("Device", String.class), "second");

assertEquals(1, map.getKeys().size());
assertEquals("second",
map.get(new TypedKeyDefault<>("device", String.class)));
}
}

@Test
public void getKeys_KeepsTheSpellingFirstGiven() {
for (boolean concurrent : CONCURRENT) {
TypedKeyMap map = new TypedKeyMapBuilder(concurrent).build();
map.put(new TypedKeyDefault<>("device", String.class), "first");
map.put(new TypedKeyDefault<>("DEVICE", String.class), "second");

assertEquals(Collections.singletonList("device"), map.getKeys());
}
}
}
Loading