@Override
    public OFAgent removeAgent(NetworkId networkId) {
        checkNotNull(networkId, ERR_NULL_NETID);
        synchronized (this) {
            OFAgent existing = ofAgentStore.ofAgent(networkId);
            if (existing == null) {
                final String error = String.format(MSG_OFAGENT, networkId, ERR_NOT_EXIST);
                throw new IllegalStateException(error);
            }
            if (existing.state() == STARTED) {
                final String error = String.format(MSG_OFAGENT, networkId, ERR_IN_USE);
                throw new IllegalStateException(error);
            }
            log.info(String.format(MSG_OFAGENT, networkId, MSG_REMOVED));
            return ofAgentStore.removeOfAgent(networkId);
        }
    }
@Test(expected = IllegalStateException.class)
    public void testRemoveNotFoundAgent() {
        target.removeAgent(NETWORK_1);
    }