@Test public void testEmptyDateReturnsToday() { RelatedItem product = new RelatedItem("1".toCharArray(),null,null,new RelatedItemAdditionalProperties()); String name = cachingDayBasedMapper.getLocationName(product); SimpleDateFormat today = new SimpleDateFormat("yyyy-MM-dd"); assertEquals(cachingDayConfig.getStorageIndexNamePrefix() + "-" + today.format(new Date()),name); }
@Override public String getLocationName(RelatedItem product) { String dateStr = product.getDate(); String date; if(dateStr==null) { date = currentDayFormatter.getCurrentDay(); } else { date = currentDayFormatter.parseToDate(dateStr); } if(dateCachingEnabled) { String cachedIndexName = dayCache.get(date); if(cachedIndexName==null) { StringBuilder indexName = new StringBuilder(indexNameSize); String theIndexName = indexName.append(this.indexPrefixName).append(date).toString(); String previous = dayCache.putIfAbsent(date,theIndexName); if(previous!=null) { return previous; } else { return theIndexName; } } else { return cachedIndexName; } } else { StringBuilder indexName = new StringBuilder(indexNameSize); return indexName.append(this.indexPrefixName).append(date).toString(); } }
DayBasedStorageLocationMapper implements RelatedItemStorageLocationMapper { @Override public String getLocationName(RelatedItem product) { String dateStr = product.getDate(); String date; if(dateStr==null) { date = currentDayFormatter.getCurrentDay(); } else { date = currentDayFormatter.parseToDate(dateStr); } if(dateCachingEnabled) { String cachedIndexName = dayCache.get(date); if(cachedIndexName==null) { StringBuilder indexName = new StringBuilder(indexNameSize); String theIndexName = indexName.append(this.indexPrefixName).append(date).toString(); String previous = dayCache.putIfAbsent(date,theIndexName); if(previous!=null) { return previous; } else { return theIndexName; } } else { return cachedIndexName; } } else { StringBuilder indexName = new StringBuilder(indexNameSize); return indexName.append(this.indexPrefixName).append(date).toString(); } } }
DayBasedStorageLocationMapper implements RelatedItemStorageLocationMapper { @Override public String getLocationName(RelatedItem product) { String dateStr = product.getDate(); String date; if(dateStr==null) { date = currentDayFormatter.getCurrentDay(); } else { date = currentDayFormatter.parseToDate(dateStr); } if(dateCachingEnabled) { String cachedIndexName = dayCache.get(date); if(cachedIndexName==null) { StringBuilder indexName = new StringBuilder(indexNameSize); String theIndexName = indexName.append(this.indexPrefixName).append(date).toString(); String previous = dayCache.putIfAbsent(date,theIndexName); if(previous!=null) { return previous; } else { return theIndexName; } } else { return cachedIndexName; } } else { StringBuilder indexName = new StringBuilder(indexNameSize); return indexName.append(this.indexPrefixName).append(date).toString(); } } DayBasedStorageLocationMapper(Configuration configuration,
                                         UTCCurrentDateFormatter dateFormatter); }
DayBasedStorageLocationMapper implements RelatedItemStorageLocationMapper { @Override public String getLocationName(RelatedItem product) { String dateStr = product.getDate(); String date; if(dateStr==null) { date = currentDayFormatter.getCurrentDay(); } else { date = currentDayFormatter.parseToDate(dateStr); } if(dateCachingEnabled) { String cachedIndexName = dayCache.get(date); if(cachedIndexName==null) { StringBuilder indexName = new StringBuilder(indexNameSize); String theIndexName = indexName.append(this.indexPrefixName).append(date).toString(); String previous = dayCache.putIfAbsent(date,theIndexName); if(previous!=null) { return previous; } else { return theIndexName; } } else { return cachedIndexName; } } else { StringBuilder indexName = new StringBuilder(indexNameSize); return indexName.append(this.indexPrefixName).append(date).toString(); } } DayBasedStorageLocationMapper(Configuration configuration,
                                         UTCCurrentDateFormatter dateFormatter); @Override String getLocationName(RelatedItem product); }
DayBasedStorageLocationMapper implements RelatedItemStorageLocationMapper { @Override public String getLocationName(RelatedItem product) { String dateStr = product.getDate(); String date; if(dateStr==null) { date = currentDayFormatter.getCurrentDay(); } else { date = currentDayFormatter.parseToDate(dateStr); } if(dateCachingEnabled) { String cachedIndexName = dayCache.get(date); if(cachedIndexName==null) { StringBuilder indexName = new StringBuilder(indexNameSize); String theIndexName = indexName.append(this.indexPrefixName).append(date).toString(); String previous = dayCache.putIfAbsent(date,theIndexName); if(previous!=null) { return previous; } else { return theIndexName; } } else { return cachedIndexName; } } else { StringBuilder indexName = new StringBuilder(indexNameSize); return indexName.append(this.indexPrefixName).append(date).toString(); } } DayBasedStorageLocationMapper(Configuration configuration,
                                         UTCCurrentDateFormatter dateFormatter); @Override String getLocationName(RelatedItem product);  }