@Override
    public ExecuteContext doAfter(ExecuteContext context) {
        final Object result = context.getResult();
        if (isValidResult(result)) {
            if (result == null) {
                RegisterContext.INSTANCE.compareAndSet(true, false);
                return context;
            }
            long beat;
            if (result instanceof ObjectNode) {
                // New version
                ObjectNode node = (ObjectNode) result;
                beat = node.get("clientBeatInterval").asLong();
            } else if (result instanceof Long) {
                // Older versions
                beat = (Long) result;
            } else {
                return context;
            }

            // If the heartbeat is 0 L,
            // the current instance cannot communicate with the Nacos registry
            // and the registry for the instance is invalid
            if (beat == 0L) {
                RegisterContext.INSTANCE.compareAndSet(true, false);
            } else if (beat > 0L) {
                RegisterContext.INSTANCE.compareAndSet(false, true);
            } else {
                return context;
            }
        }
        return context;
    }
@Test
    public void doAfter() throws Exception {
        REGISTER_CONFIG.setEnableSpringRegister(true);
        REGISTER_CONFIG.setOpenMigration(true);
        final ExecuteContext context = buildContext();
        RegisterContext.INSTANCE.setAvailable(true);
        interceptor.after(context);
        Assert.assertFalse(RegisterContext.INSTANCE.isAvailable());

        // Heartbeats are available
        context.changeResult(1L);
        interceptor.after(context);
        Assert.assertTrue(RegisterContext.INSTANCE.isAvailable());

        // Heartbeat is not available
        context.changeResult(0L);
        interceptor.after(context);
        Assert.assertFalse(RegisterContext.INSTANCE.isAvailable());

        // ObjectNode available
        final ObjectNode node = Mockito.mock(ObjectNode.class);
        Mockito.when(node.get("clientBeatInterval")).thenReturn(new LongNode(1L));
        context.changeResult(node);
        interceptor.after(context);
        Assert.assertTrue(RegisterContext.INSTANCE.isAvailable());

        // ObjectNode not available
        Mockito.reset(node);
        Mockito.when(node.get("clientBeatInterval")).thenReturn(new LongNode(0L));
        context.changeResult(node);
        interceptor.after(context);
        Assert.assertFalse(RegisterContext.INSTANCE.isAvailable());
        REGISTER_CONFIG.setEnableSpringRegister(false);
        REGISTER_CONFIG.setOpenMigration(false);
        RegisterContext.INSTANCE.setAvailable(false);
    }