use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.
the class ResourceCacheImplTest method testContainsTrueValid.
@Test
public void testContainsTrueValid() throws URISyntaxException {
MetacardImpl cachedMetacard = generateMetacard();
MetacardImpl latestMetacard = generateMetacard();
String cacheKey = "cacheKey1";
resourceCache.put(new ReliableResource(cacheKey, "", null, "name", cachedMetacard));
assertFalse("cache should be noop", resourceCache.containsValid(cacheKey, latestMetacard));
}
use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.
the class ResourceCacheImplTest method getSpecificResourceInCache.
@Test
public void getSpecificResourceInCache() {
ReliableResource cachedResource = createCachedResource(cachedMetacard);
resourceCache.put(cachedResource);
Optional<Resource> optionalResource = newResourceCache.get(cachedMetacard, new ResourceRequestById(METACARD_ID));
assertFalse("cache should be noop", optionalResource.isPresent());
}
use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.
the class ResourceCacheImplTest method testContainsTrueInvalid2CantFindFile.
@Test
public void testContainsTrueInvalid2CantFindFile() throws URISyntaxException {
MetacardImpl cachedMetacard = generateMetacard();
cachedMetacard.setId("different-id");
MetacardImpl latestMetacard = generateMetacard();
String cacheKey = "cacheKey1";
resourceCache.put(new ReliableResource(cacheKey, "", null, "name", cachedMetacard));
assertFalse(resourceCache.containsValid(cacheKey, latestMetacard));
}
use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.
the class ResourceCacheImplTest method createCachedResource.
private ReliableResource createCachedResource(Metacard metacard) {
String fileName = "15bytes.txt";
String productLocation = this.getClass().getResource("/" + fileName).getFile();
File rrCachedFile = new File(productLocation);
return new ReliableResource(CACHED_RESOURCE_KEY, rrCachedFile.getAbsolutePath(), new MimeType(), fileName, metacard);
}
Aggregations