summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-04-09 09:48:56 -0700
committerJesse Morgan <jesse@jesterpm.net>2016-04-09 09:48:56 -0700
commit10c5fd17b603f125ae2c0ef14b1a65341dbdf961 (patch)
tree573fd7379044bfd6d4ce2d32b3612cb149395002
parent918e806c83f812721f0e9527fbc3e3e67d071580 (diff)
CustomFieldCache is now case-insensitive.
-rw-r--r--src/com/p4square/grow/ccb/CustomFieldCache.java6
-rw-r--r--tst/com/p4square/grow/ccb/CustomFieldCacheTest.java20
2 files changed, 23 insertions, 3 deletions
diff --git a/src/com/p4square/grow/ccb/CustomFieldCache.java b/src/com/p4square/grow/ccb/CustomFieldCache.java
index ba473fb..d93e6d9 100644
--- a/src/com/p4square/grow/ccb/CustomFieldCache.java
+++ b/src/com/p4square/grow/ccb/CustomFieldCache.java
@@ -72,7 +72,7 @@ public class CustomFieldCache {
items = mItemByNameTable.get(type);
}
- return items.get(name);
+ return items.get(name.toLowerCase());
}
private synchronized void refresh() {
@@ -113,8 +113,8 @@ public class CustomFieldCache {
private synchronized boolean cacheLookupTable(final LookupTableType type) {
try {
final GetLookupTableResponse resp = mAPI.getLookupTable(new GetLookupTableRequest().withType(type));
- mItemByNameTable.put(type,
- resp.getItems().stream().collect(Collectors.toMap(LookupTableItem::getName, Function.identity())));
+ mItemByNameTable.put(type, resp.getItems().stream().collect(
+ Collectors.toMap(item -> item.getName().toLowerCase(), Function.identity())));
return true;
} catch (IOException e) {
diff --git a/tst/com/p4square/grow/ccb/CustomFieldCacheTest.java b/tst/com/p4square/grow/ccb/CustomFieldCacheTest.java
index e374496..bcfd260 100644
--- a/tst/com/p4square/grow/ccb/CustomFieldCacheTest.java
+++ b/tst/com/p4square/grow/ccb/CustomFieldCacheTest.java
@@ -175,6 +175,26 @@ public class CustomFieldCacheTest {
}
@Test
+ public void testGetPullDownOptionsMixedCase() throws Exception {
+ // Setup mocks
+ Capture<GetLookupTableRequest> requestCapture = EasyMock.newCapture();
+ EasyMock.expect(api.getLookupTable(EasyMock.capture(requestCapture))).andReturn(lookupTableResponse);
+ EasyMock.replay(api);
+
+ // Test the cache
+ LookupTableItem item = cache.getPulldownItemByName(
+ LookupTableType.valueOf("udf_ind_pulldown_6".toUpperCase()),
+ "BeLiEvEr");
+
+ // Verify result.
+ EasyMock.verify(api);
+ assertEquals(LookupTableType.UDF_IND_PULLDOWN_6, requestCapture.getValue().getType());
+ assertEquals(2, item.getId());
+ assertEquals(2, item.getOrder());
+ assertEquals("Believer", item.getName());
+ }
+
+ @Test
public void testGetPullDownOptionMissing() throws Exception {
// Setup mocks
EasyMock.expect(api.getLookupTable(EasyMock.anyObject())).andReturn(lookupTableResponse);