### Question:
RemovedState extends NodeState { @Override public void handleRollback(NodeStateContext nodeStateContext) { if (PersistenceContextType.EXTENDED.equals(nodeStateContext.getPersistenceCache().getPersistenceContextType())) { moveNodeToNextState(nodeStateContext, new ManagedState()); } else if (PersistenceContextType.TRANSACTION.equals(nodeStateContext.getPersistenceCache() .getPersistenceContextType())) { nodeStateContext.detach(); } }  @Override void initialize(NodeStateContext nodeStateContext); @Override void handlePersist(NodeStateContext nodeStateContext); @Override void handleRemove(NodeStateContext nodeStateContext); @Override void handleRefresh(NodeStateContext nodeStateContext); @Override void handleMerge(NodeStateContext nodeStateContext); @Override void handleFind(NodeStateContext nodeStateContext); @Override void handleClose(NodeStateContext nodeStateContext); @Override void handleClear(NodeStateContext nodeStateContext); @Override void handleFlush(NodeStateContext nodeStateContext); @Override void handleLock(NodeStateContext nodeStateContext); @Override void handleDetach(NodeStateContext nodeStateContext); @Override void handleCommit(NodeStateContext nodeStateContext); @Override void handleRollback(NodeStateContext nodeStateContext); @Override void handleGetReference(NodeStateContext nodeStateContext); @Override void handleContains(NodeStateContext nodeStateContext);  }### Answer:
@Test public void testHandleRollback() { pc.setPersistenceContextType(PersistenceContextType.EXTENDED); Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST); state.handleRollback(storeNode); Assert.assertEquals(ManagedState.class, storeNode.getCurrentNodeState().getClass()); for (Node childNode : storeNode.getChildren().values()) { Assert.assertEquals(BillingCounter.class, childNode.getDataClass()); Assert.assertEquals(RemovedState.class, childNode.getCurrentNodeState().getClass()); } pc.setPersistenceContextType(PersistenceContextType.TRANSACTION); storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST); state.handleRollback(storeNode); Assert.assertEquals(DetachedState.class, storeNode.getCurrentNodeState().getClass()); for (Node childNode : storeNode.getChildren().values()) { Assert.assertEquals(BillingCounter.class, childNode.getDataClass()); Assert.assertEquals(RemovedState.class, childNode.getCurrentNodeState().getClass()); } }