class NacosConfigEndpoint implements ApplicationListener<NacosConfigMetadataEvent> {

	@ReadOperation
	public Map<String, Object> invoke() {
		Map<String, Object> result = new HashMap<>(8);

		if (!(ClassUtils.isAssignable(applicationContext.getEnvironment().getClass(),
				ConfigurableEnvironment.class))) {
			result.put("error", "environment type not match ConfigurableEnvironment: "
					+ applicationContext.getEnvironment().getClass().getName());
		}
		else {

			result.put("nacosConfigMetadata", nacosConfigMetadataMap.values());

			result.put("nacosConfigGlobalProperties",
					PropertiesUtils.extractSafeProperties(applicationContext.getBean(
							CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME, Properties.class)));
		}

		return result;
	}

}

class NacosConfigEndpointTest {

	@Autowired
	private NacosConfigEndpoint nacosConfigEndpoint;

	@Test
	public void testInvoke() {

		Map<String, Object> metadata = nacosConfigEndpoint.invoke();
		Assert.assertNotNull(metadata.get("nacosConfigMetadata"));
	}

}