提交 299aab35 编写于 作者: M menghaoranss

resolve checkstyle problems

上级 dc045312
......@@ -74,13 +74,7 @@ public final class ApolloCenterRepository implements ConfigCenterRepository {
@Override
public void persist(final String key, final String value) {
try {
openApiWrapper.persist(ConfigKeyUtils.pathToKey(key), value);
// CHECKSTYLE:OFF
} catch (Exception ex) {
// CHECKSTYLE:ON
log.error("Apollo persist key '{}' throw exception: {}", key, ex);
}
openApiWrapper.persist(ConfigKeyUtils.pathToKey(key), value);
}
@Override
......
......@@ -40,10 +40,8 @@ import java.util.concurrent.TimeoutException;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.doThrow;
public final class ApolloCenterRepositoryTest {
......@@ -153,13 +151,6 @@ public final class ApolloCenterRepositoryTest {
verify(OPEN_API_WRAPPER).persist(ConfigKeyUtils.pathToKey("/test/children/6"), "value6");
}
@Test
public void assertPersistWhenThrowException() {
doThrow(Exception.class).when(OPEN_API_WRAPPER).persist(anyString(), anyString());
REPOSITORY.persist("/test/children/7", "value7");
verify(OPEN_API_WRAPPER).persist(ConfigKeyUtils.pathToKey("/test/children/7"), "value7");
}
@Test
public void assertGetType() {
assertThat(REPOSITORY.getType(), is("apollo"));
......
......@@ -41,10 +41,15 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.junit.Assert.assertNull;
@RunWith(MockitoJUnitRunner.class)
public final class ApolloOpenApiWrapperTest {
private static final String NAME_SPACE = "orchestration";
private static final String PORTAL_URL = "http://127.0.0.1";
private static final String TOKEN = "testToken";
@Mock
private ApolloOpenApiClient client;
......@@ -53,12 +58,6 @@ public final class ApolloOpenApiWrapperTest {
private ApolloOpenApiWrapper apolloOpenApiWrapper;
private static final String NAME_SPACE = "orchestration";
private static final String PORTAL_URL = "http://127.0.0.1";
private static final String TOKEN = "testToken";
@SneakyThrows({NoSuchFieldException.class, SecurityException.class})
@Before
public void setUp() {
......@@ -77,32 +76,27 @@ public final class ApolloOpenApiWrapperTest {
@Test
public void getValue() {
apolloOpenApiWrapper.getValue(ConfigKeyUtils.pathToKey("/test/children/0"));
verify(client).getItem(ApolloPropertyKey.APP_ID.getDefaultValue() ,
ApolloPropertyKey.ENV.getDefaultValue(), ApolloPropertyKey.CLUSTER_NAME.getDefaultValue(), NAME_SPACE,
ConfigKeyUtils.pathToKey("/test/children/0"));
verify(client).getItem(ApolloPropertyKey.APP_ID.getDefaultValue(), ApolloPropertyKey.ENV.getDefaultValue(),
ApolloPropertyKey.CLUSTER_NAME.getDefaultValue(), NAME_SPACE, ConfigKeyUtils.pathToKey("/test/children/0"));
}
@Test
public void getValueNotNull() {
when(client.getItem(ApolloPropertyKey.APP_ID.getDefaultValue() ,
ApolloPropertyKey.ENV.getDefaultValue(), ApolloPropertyKey.CLUSTER_NAME.getDefaultValue(), NAME_SPACE,
ConfigKeyUtils.pathToKey("/test/children/0"))).thenReturn(openItemDTO);
when(client.getItem(ApolloPropertyKey.APP_ID.getDefaultValue(), ApolloPropertyKey.ENV.getDefaultValue(),
ApolloPropertyKey.CLUSTER_NAME.getDefaultValue(), NAME_SPACE, ConfigKeyUtils.pathToKey("/test/children/0"))).thenReturn(openItemDTO);
assertNull(apolloOpenApiWrapper.getValue(ConfigKeyUtils.pathToKey("/test/children/0")));
}
@Test
public void persist() {
apolloOpenApiWrapper.persist(ConfigKeyUtils.pathToKey("/test/children/0"), "value0");
verify(client).createOrUpdateItem(anyString() ,
anyString(), anyString(), anyString(), any(OpenItemDTO.class));
verify(client).publishNamespace(anyString() ,
anyString(), anyString(), anyString(), any(NamespaceReleaseDTO.class));
verify(client).createOrUpdateItem(anyString(), anyString(), anyString(), anyString(), any(OpenItemDTO.class));
verify(client).publishNamespace(anyString(), anyString(), anyString(), anyString(), any(NamespaceReleaseDTO.class));
}
@Test
public void remove() {
apolloOpenApiWrapper.remove(ConfigKeyUtils.pathToKey("/test/children/0"));
verify(client).removeItem(anyString() ,
anyString(), anyString(), anyString(), eq(ConfigKeyUtils.pathToKey("/test/children/0")) ,anyString());
verify(client).removeItem(anyString(), anyString(), anyString(), anyString(), eq(ConfigKeyUtils.pathToKey("/test/children/0")), anyString());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册