@Test public void should_compute_graph_with_many_level() throws Exception { Unit unit = new Unit(); unit.put("_id", "1"); Unit unit1 = new Unit(); unit1.put("_id", "11"); unit1.put("_up", newHashSet("1")); Unit unit2 = new Unit(); unit2.put("_id", "12"); unit2.put("_up", newHashSet("1")); Unit unit21 = new Unit(); unit21.put("_id", "21"); unit21.put("_up", newHashSet("11", "12")); given(mongoDbMetadataRepository.selectByIds(newHashSet("11", "12"), UNIT_VITAM_GRAPH_PROJECTION)) .willReturn(newArrayList(unit1, unit2)); given(mongoDbMetadataRepository.selectByIds(newHashSet("1"), UNIT_VITAM_GRAPH_PROJECTION)) .willReturn(newArrayList(unit)); given(mongoDbMetadataRepository.selectByIds(newHashSet("21"), UNIT_VITAM_GRAPH_PROJECTION)) .willReturn(newArrayList(unit21)); graphLoader.loadGraphInfo(newArrayList("21")); verify(mongoDbMetadataRepository).selectByIds(newHashSet("11", "12"), UNIT_VITAM_GRAPH_PROJECTION); verify(mongoDbMetadataRepository).selectByIds(newHashSet("1"), UNIT_VITAM_GRAPH_PROJECTION); verify(mongoDbMetadataRepository).selectByIds(newHashSet("21"), UNIT_VITAM_GRAPH_PROJECTION); }
public Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids) throws MetaDataNotFoundException { try { return unitLoadingCache.getAll(ids); } catch (CacheLoader.InvalidCacheLoadException e) { Matcher matcher = pattern.matcher(e.getMessage()); if (matcher.matches()) { String id = matcher.group(1); throw new MetaDataNotFoundException("Cannot find parents: [" + id + "]"); } throw new MetaDataNotFoundException(e); } catch (ExecutionException e) { throw new VitamRuntimeException(e); } }
GraphLoader implements AutoCloseable { public Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids) throws MetaDataNotFoundException { try { return unitLoadingCache.getAll(ids); } catch (CacheLoader.InvalidCacheLoadException e) { Matcher matcher = pattern.matcher(e.getMessage()); if (matcher.matches()) { String id = matcher.group(1); throw new MetaDataNotFoundException("Cannot find parents: [" + id + "]"); } throw new MetaDataNotFoundException(e); } catch (ExecutionException e) { throw new VitamRuntimeException(e); } } }
GraphLoader implements AutoCloseable { public Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids) throws MetaDataNotFoundException { try { return unitLoadingCache.getAll(ids); } catch (CacheLoader.InvalidCacheLoadException e) { Matcher matcher = pattern.matcher(e.getMessage()); if (matcher.matches()) { String id = matcher.group(1); throw new MetaDataNotFoundException("Cannot find parents: [" + id + "]"); } throw new MetaDataNotFoundException(e); } catch (ExecutionException e) { throw new VitamRuntimeException(e); } } GraphLoader(MongoDbMetadataRepository<Unit> mongoDbMetadataRepository); }
GraphLoader implements AutoCloseable { public Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids) throws MetaDataNotFoundException { try { return unitLoadingCache.getAll(ids); } catch (CacheLoader.InvalidCacheLoadException e) { Matcher matcher = pattern.matcher(e.getMessage()); if (matcher.matches()) { String id = matcher.group(1); throw new MetaDataNotFoundException("Cannot find parents: [" + id + "]"); } throw new MetaDataNotFoundException(e); } catch (ExecutionException e) { throw new VitamRuntimeException(e); } } GraphLoader(MongoDbMetadataRepository<Unit> mongoDbMetadataRepository); Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids); void cleanCache(); @Override void close(); }
GraphLoader implements AutoCloseable { public Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids) throws MetaDataNotFoundException { try { return unitLoadingCache.getAll(ids); } catch (CacheLoader.InvalidCacheLoadException e) { Matcher matcher = pattern.matcher(e.getMessage()); if (matcher.matches()) { String id = matcher.group(1); throw new MetaDataNotFoundException("Cannot find parents: [" + id + "]"); } throw new MetaDataNotFoundException(e); } catch (ExecutionException e) { throw new VitamRuntimeException(e); } } GraphLoader(MongoDbMetadataRepository<Unit> mongoDbMetadataRepository); Map<String, UnitGraphModel> loadGraphInfo(Iterable<? extends String> ids); void cleanCache(); @Override void close();  }