public void addToFrontCache_someNew() {
final EHCachingPositionSource cache = new EHCachingPositionSource(Mockito.mock(PositionSource.class), _cacheManager);
try {
// Add two similar portfolios with some positions (and hence nodes) shared; shared nodes and positions to be reused in returned node
final PortfolioNode root1 = createPortfolioA1();
final PortfolioNode root2 = createPortfolioA3();
final VersionCorrection vc = VersionCorrection.of(Instant.now(), Instant.now());
assertSame(cache.addToFrontCache(root1, vc), root1);
final PortfolioNode root2b = cache.addToFrontCache(root2, VersionCorrection.ofVersionAsOf(vc.getVersionAsOf().plusSeconds(1)));
assertNotSame(root2b, root2);
assertEquals(root2b.getName(), root2.getName());
assertEquals(root2b.getParentNodeId(), root2.getParentNodeId());
assertEquals(root2b.getUniqueId(), root2.getUniqueId());
assertEquals(root2b.getPositions(), root2.getPositions());
assertSame(root2b.getPositions().get(0), root1.getPositions().get(0));
assertSame(root2b.getPositions().get(1), root1.getPositions().get(1));
assertSame(root2b.getChildNodes().get(0), root1.getChildNodes().get(0));
assertEquals(root2b.getChildNodes().get(1), root2.getChildNodes().get(1));
assertNotSame(root2b.getChildNodes().get(1), root2.getChildNodes().get(1));
assertSame(root2b.getChildNodes().get(1).getPositions().get(0), root1.getChildNodes().get(1).getPositions().get(0));
assertSame(root2b.getChildNodes().get(1).getPositions().get(1), root2.getChildNodes().get(1).getPositions().get(1));
} finally {
cache.shutdown();
}
}