NacosRepository implements ConfigurationRepository { @Override public String get(final String key) { try { String dataId = pathToKey(key); String group = nacosProperties.getValue(NacosPropertyKey.GROUP); long timeoutMs = nacosProperties.getValue(NacosPropertyKey.TIMEOUT); return configService.getConfig(dataId, group, timeoutMs); } catch (final NacosException ex) { log.debug("Nacos get config value exception for: {}", ex.toString()); return null; } }  @Override void init(final String name, final GovernanceCenterConfiguration config); @Override String get(final String key); @Override List<String> getChildrenKeys(final String key); @Override void persist(final String key, final String value); @Override void watch(final String key, final DataChangedEventListener listener); @Override void delete(final String key); @Override void close(); @Override String getType();  }
@Test public void assertGet() throws NacosException { String value = "value"; when(configService.getConfig(eq("sharding.test"), eq(group), anyLong())).thenReturn(value); assertThat(REPOSITORY.get("/sharding/test"), is(value)); }
@Test public void assertGetWithNonExistentKey() { assertNull(REPOSITORY.get("/sharding/nonExistentKey")); }
@Test public void assertGetWhenThrowException() throws NacosException { doThrow(NacosException.class).when(configService).getConfig(eq("sharding.test"), eq(group), anyLong()); assertNull(REPOSITORY.get("/sharding/test")); }