### Question:
TransientState extends NodeState { @Override public void handlePersist(NodeStateContext nodeStateContext) { moveNodeToNextState(nodeStateContext, new ManagedState()); nodeStateContext.setDirty(true); nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node) nodeStateContext); }  @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 testHandlePersist() throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST); EntityManagerFactory emf = Persistence.createEntityManagerFactory("kunderatest"); Constructor constructor = PersistenceDelegator.class.getDeclaredConstructor(KunderaMetadata.class, PersistenceCache.class); constructor.setAccessible(true); PersistenceDelegator pd = (PersistenceDelegator) constructor.newInstance( ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), new PersistenceCache()); storeNode.setPersistenceDelegator(pd); state.handlePersist(storeNode); Assert.assertEquals(ManagedState.class, storeNode.getCurrentNodeState().getClass()); Assert.assertTrue(storeNode.isDirty()); Assert.assertNotNull(storeNode.getPersistenceCache().getMainCache() .getNodeFromCache(storeNode.getNodeId(), null)); }