### Question:
RemovedState extends NodeState { @Override public void handleFlush(NodeStateContext nodeStateContext) { Client client = nodeStateContext.getClient(); Node node = (Node) nodeStateContext; Object entityId = node.getEntityId(); client.remove(node.getData(), entityId); nodeStateContext.setDirty(false); nodeStateContext.getPersistenceCache().getMainCache().removeNodeFromCache(node); }  @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 testHandleFlush() { try { Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST); state.handleFlush(storeNode); Assert.fail("Exception should be thrown because client is not available"); } catch (Exception e) { Assert.assertNotNull(e); } }