MyWorkspaceStorageConnection con = new MyWorkspaceStorageConnection();
con.childNodesCount = 1;
WorkspaceDataContainer wdc = new MyWorkspaceDataContainer(con);
WorkspaceContainerFacade wsc = repository.getWorkspaceContainer("ws");
WorkspaceEntry wconf = (WorkspaceEntry)wsc.getComponent(WorkspaceEntry.class);
final CacheableWorkspaceDataManager cwdm =
new CacheableWorkspaceDataManager(wconf, wdc, getCacheImpl(), new SystemDataContainerHolder(wdc));
final NodeData parentNode =
new PersistedNodeData("testGetChildNodesCount2", QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName(null,
"getChildNodesCount")), null, 0, 1, null, null, null);
assertEquals(0, con.getChildNodesCountCalls.get());
int result = cwdm.getChildNodesCount(parentNode);
assertEquals(1, result);
assertEquals(1, con.getChildNodesCountCalls.get());
result = cwdm.getChildNodesCount(parentNode);
assertEquals(1, result);
assertEquals(1, con.getChildNodesCountCalls.get());
PlainChangesLog chlog = new PlainChangesLogImpl();
chlog.add(ItemState.createAddedState(new PersistedNodeData("id-node" + parentNode.getIdentifier(), QPath
.makeChildPath(parentNode.getQPath(), new InternalQName(null, "node")), parentNode.getIdentifier(), 1, 0,
Constants.NT_UNSTRUCTURED, new InternalQName[0], null)));
cwdm.save(new TransactionChangesLog(chlog));
result = cwdm.getChildNodesCount(parentNode);
assertEquals(2, result);
assertEquals(2, con.getChildNodesCountCalls.get());
}