CachedExportStrategy extends BaseSampleExportStrategy { @Override public boolean test(ExportParameters parameters) { if (parameters == null) { return false; } if (parameters.getContent() != null) { return false; } if (StringUtils.isEmpty(parameters.getPreparationId())) { return false; } try { final TransformationCacheKey contentKey = getCacheKey(parameters); return contentCache.has(contentKey); } catch (TDPException e) { LOGGER.debug("Unable to use cached export strategy.", e); return false; } }  @Override boolean test(ExportParameters parameters); @Override StreamingResponseBody execute(ExportParameters parameters);  }
@Test public void shouldNotAcceptIfCacheEntryDoesNotExists() throws Exception { final ExportParameters parameters = new ExportParameters(); parameters.setDatasetId("1234"); parameters.setPreparationId("2345"); parameters.setStepId("0"); parameters.setExportType("text"); parameters.setFrom(HEAD); assertFalse(cachedExportStrategy.test(parameters)); }
@Test public void shouldNotAcceptNullParameter() throws Exception { assertFalse(cachedExportStrategy.test(null)); }
@Test public void shouldNotAcceptWhenParameterContentIsPresent() throws Exception { final ExportParameters parameters = new ExportParameters(); parameters.setContent(new DataSet()); assertFalse(cachedExportStrategy.test(parameters)); }
@Test public void shouldNotAcceptNullPreparationId() throws Exception { final ExportParameters parameters = new ExportParameters(); parameters.setContent(new DataSet()); parameters.setPreparationId(null); assertFalse(cachedExportStrategy.test(parameters)); }