### Question:
DetachedState extends NodeState { @Override public void handlePersist(NodeStateContext nodeStateContext) { throw new IllegalArgumentException("Persist operation not allowed in Detached state"); }  @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() { Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST); try { state.handlePersist(storeNode); Assert.fail("Persist operation in Detached state should have thrown exception"); } catch (Exception e) { Assert.assertEquals(IllegalArgumentException.class, e.getClass()); } }