@Test @RunWithCustomExecutor public void testReLoadingFromCache() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(3); GUID guid = GUIDFactory.newRequestIdGUID(3); VitamThreadUtils.getVitamSession().setRequestId(guid); String schema = "{\"$schema\":\"http: CachedSchemaValidatorLoader schemaValidatorLoader = new CachedSchemaValidatorLoader(10, 60); Set<JsonSchemaValidator> results = Sets.newIdentityHashSet(); for (int i = 0; i < 10; i++) { results.add(schemaValidatorLoader.loadSchemaValidator(schema)); } assertThat(results).hasSize(1); }
public JsonSchemaValidator loadSchemaValidator(String jsonSchema) throws InvalidJsonSchemaException { try { return schemaValidatorCache.get(jsonSchema, () -> JsonSchemaValidator.forUserSchema(jsonSchema)); } catch (ExecutionException e) { if (e.getCause() instanceof InvalidJsonSchemaException) { throw (InvalidJsonSchemaException) e.getCause(); } else { throw new InvalidJsonSchemaException("Could not load schema validator", e); } } }
CachedSchemaValidatorLoader { public JsonSchemaValidator loadSchemaValidator(String jsonSchema) throws InvalidJsonSchemaException { try { return schemaValidatorCache.get(jsonSchema, () -> JsonSchemaValidator.forUserSchema(jsonSchema)); } catch (ExecutionException e) { if (e.getCause() instanceof InvalidJsonSchemaException) { throw (InvalidJsonSchemaException) e.getCause(); } else { throw new InvalidJsonSchemaException("Could not load schema validator", e); } } } }
CachedSchemaValidatorLoader { public JsonSchemaValidator loadSchemaValidator(String jsonSchema) throws InvalidJsonSchemaException { try { return schemaValidatorCache.get(jsonSchema, () -> JsonSchemaValidator.forUserSchema(jsonSchema)); } catch (ExecutionException e) { if (e.getCause() instanceof InvalidJsonSchemaException) { throw (InvalidJsonSchemaException) e.getCause(); } else { throw new InvalidJsonSchemaException("Could not load schema validator", e); } } } CachedSchemaValidatorLoader(int maxEntriesInCache, int cacheTimeoutInSeconds); }
CachedSchemaValidatorLoader { public JsonSchemaValidator loadSchemaValidator(String jsonSchema) throws InvalidJsonSchemaException { try { return schemaValidatorCache.get(jsonSchema, () -> JsonSchemaValidator.forUserSchema(jsonSchema)); } catch (ExecutionException e) { if (e.getCause() instanceof InvalidJsonSchemaException) { throw (InvalidJsonSchemaException) e.getCause(); } else { throw new InvalidJsonSchemaException("Could not load schema validator", e); } } } CachedSchemaValidatorLoader(int maxEntriesInCache, int cacheTimeoutInSeconds); JsonSchemaValidator loadSchemaValidator(String jsonSchema); }
CachedSchemaValidatorLoader { public JsonSchemaValidator loadSchemaValidator(String jsonSchema) throws InvalidJsonSchemaException { try { return schemaValidatorCache.get(jsonSchema, () -> JsonSchemaValidator.forUserSchema(jsonSchema)); } catch (ExecutionException e) { if (e.getCause() instanceof InvalidJsonSchemaException) { throw (InvalidJsonSchemaException) e.getCause(); } else { throw new InvalidJsonSchemaException("Could not load schema validator", e); } } } CachedSchemaValidatorLoader(int maxEntriesInCache, int cacheTimeoutInSeconds); JsonSchemaValidator loadSchemaValidator(String jsonSchema);  }