From e75a8ef2372722c0b22669fb427d47bacc5b8d5e Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Thu, 7 Sep 2017 14:33:18 +0800 Subject: Fix java check style warning Change-Id: I98a6d7237a213d007ad4d954989cb0b0fa150a10 Issue-Id: MSB-67 Signed-off-by: HuabingZhao --- .../apiroute/wrapper/consulextend/ConsulTest.java | 239 ++++++++++----------- 1 file changed, 111 insertions(+), 128 deletions(-) (limited to 'apiroute/apiroute-service/src/test/java/org/onap/msb/apiroute/wrapper/consulextend/ConsulTest.java') diff --git a/apiroute/apiroute-service/src/test/java/org/onap/msb/apiroute/wrapper/consulextend/ConsulTest.java b/apiroute/apiroute-service/src/test/java/org/onap/msb/apiroute/wrapper/consulextend/ConsulTest.java index fcec469..71e6a84 100644 --- a/apiroute/apiroute-service/src/test/java/org/onap/msb/apiroute/wrapper/consulextend/ConsulTest.java +++ b/apiroute/apiroute-service/src/test/java/org/onap/msb/apiroute/wrapper/consulextend/ConsulTest.java @@ -1,17 +1,15 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. ******************************************************************************/ package org.onap.msb.apiroute.wrapper.consulextend; @@ -24,9 +22,6 @@ import org.junit.runner.RunWith; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.onap.msb.apiroute.wrapper.consulextend.CatalogClient; -import org.onap.msb.apiroute.wrapper.consulextend.Consul; -import org.onap.msb.apiroute.wrapper.consulextend.HealthClient; import org.onap.msb.apiroute.wrapper.consulextend.async.ConsulResponseCallback; import org.onap.msb.apiroute.wrapper.consulextend.async.OriginalConsulResponse; import org.onap.msb.apiroute.wrapper.consulextend.model.health.ServiceHealth; @@ -44,121 +39,109 @@ import com.orbitz.consul.option.CatalogOptions; import com.orbitz.consul.option.QueryOptions; @RunWith(PowerMockRunner.class) -@PrepareForTest({ Http.class }) -@PowerMockIgnore({ "javax.net.ssl.*" }) +@PrepareForTest({Http.class}) +@PowerMockIgnore({"javax.net.ssl.*"}) public class ConsulTest { - private static Consul consul10081; - private static Consul consul8500; - - private static final Logger LOGGER = LoggerFactory - .getLogger(ConsulTest.class); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @BeforeClass - public static void setUpBeforeClass() throws Exception { - - Http http = PowerMockito.mock(Http.class); - - PowerMockito - .doAnswer(new Answer() { - @Override - public Object answer(InvocationOnMock invocation) - throws Throwable { - Object[] args = invocation.getArguments(); - ((ConsulResponseCallback) args[2]).onComplete(null); - return null; - } - }) - .when(http) - .asyncGet(Mockito.anyString(), - Mockito.any(TypeReference.class), - Mockito.any(ConsulResponseCallback.class)); - - // - PowerMockito.spy(Http.class); - PowerMockito.when(Http.getInstance()).thenReturn(http); - - // - consul10081 = Consul.builder().withHostAndPort("10.74.148.111", 10081) - .build(); - consul8500 = Consul.builder().withHostAndPort("10.74.148.111", 8500) - .build(); - } - - @Test - public void testcatalogClient() { - - ConsulResponseCallback callback = new ConsulResponseCallback() { - - @Override - public void onComplete( - ConsulResponse consulResponse) { - LOGGER.info("service list complete!"); - } - - @Override - public void onFailure(Throwable throwable) { - LOGGER.info("service list failure!"); - } - - @Override - public void onDelayComplete( - OriginalConsulResponse originalConsulResponse) { - // TODO Auto-generated method stub - LOGGER.info("service list complete!"); - } - - }; - - // 10081 - CatalogClient catalogclient10081 = consul10081.catalogClient(); - catalogclient10081.getServices(CatalogOptions.BLANK, QueryOptions.BLANK, callback); - - // 8500 - CatalogClient catalogclient8500 = consul8500.catalogClient(); - catalogclient8500.getServices(CatalogOptions.BLANK, QueryOptions.BLANK, callback); - } - - @Test - public void testhealthClient() { - - ConsulResponseCallback> callback = new ConsulResponseCallback>() { - - @Override - public void onComplete( - ConsulResponse> consulResponse) { - LOGGER.info("health service complete!"); - - } - - @Override - public void onFailure(Throwable throwable) { - LOGGER.info("health service failure!"); - } - - @Override - public void onDelayComplete( - OriginalConsulResponse> originalConsulResponse) { - // TODO Auto-generated method stub - LOGGER.info("health service complete!"); - } - - }; - - // 10081 - HealthClient healthClient10081 = consul10081.healthClient(); - healthClient10081.getAllServiceInstances("apigateway-default", CatalogOptions.BLANK, - QueryOptions.BLANK, callback); - - healthClient10081.getHealthyServiceInstances("apigateway-default", - CatalogOptions.BLANK, QueryOptions.BLANK, callback); - - // 8500 - HealthClient healthClient8500 = consul8500.healthClient(); - healthClient8500.getAllServiceInstances("apigateway-default", CatalogOptions.BLANK, - QueryOptions.BLANK, callback); - healthClient8500.getHealthyServiceInstances("apigateway-default", CatalogOptions.BLANK, - QueryOptions.BLANK, callback); - - } + private static Consul consul10081; + private static Consul consul8500; + + private static final Logger LOGGER = LoggerFactory.getLogger(ConsulTest.class); + + @SuppressWarnings({"unchecked", "rawtypes"}) + @BeforeClass + public static void setUpBeforeClass() throws Exception { + + Http http = PowerMockito.mock(Http.class); + + PowerMockito.doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + Object[] args = invocation.getArguments(); + ((ConsulResponseCallback) args[2]).onComplete(null); + return null; + } + }).when(http).asyncGet(Mockito.anyString(), Mockito.any(TypeReference.class), + Mockito.any(ConsulResponseCallback.class)); + + // + PowerMockito.spy(Http.class); + PowerMockito.when(Http.getInstance()).thenReturn(http); + + // + consul10081 = Consul.builder().withHostAndPort("10.74.148.111", 10081).build(); + consul8500 = Consul.builder().withHostAndPort("10.74.148.111", 8500).build(); + } + + @Test + public void testcatalogClient() { + + ConsulResponseCallback callback = new ConsulResponseCallback() { + + @Override + public void onComplete(ConsulResponse consulResponse) { + LOGGER.info("service list complete!"); + } + + @Override + public void onFailure(Throwable throwable) { + LOGGER.info("service list failure!"); + } + + @Override + public void onDelayComplete(OriginalConsulResponse originalConsulResponse) { + // TODO Auto-generated method stub + LOGGER.info("service list complete!"); + } + + }; + + // 10081 + CatalogClient catalogclient10081 = consul10081.catalogClient(); + catalogclient10081.getServices(CatalogOptions.BLANK, QueryOptions.BLANK, callback); + + // 8500 + CatalogClient catalogclient8500 = consul8500.catalogClient(); + catalogclient8500.getServices(CatalogOptions.BLANK, QueryOptions.BLANK, callback); + } + + @Test + public void testhealthClient() { + + ConsulResponseCallback> callback = new ConsulResponseCallback>() { + + @Override + public void onComplete(ConsulResponse> consulResponse) { + LOGGER.info("health service complete!"); + + } + + @Override + public void onFailure(Throwable throwable) { + LOGGER.info("health service failure!"); + } + + @Override + public void onDelayComplete(OriginalConsulResponse> originalConsulResponse) { + // TODO Auto-generated method stub + LOGGER.info("health service complete!"); + } + + }; + + // 10081 + HealthClient healthClient10081 = consul10081.healthClient(); + healthClient10081.getAllServiceInstances("apigateway-default", CatalogOptions.BLANK, QueryOptions.BLANK, + callback); + + healthClient10081.getHealthyServiceInstances("apigateway-default", CatalogOptions.BLANK, QueryOptions.BLANK, + callback); + + // 8500 + HealthClient healthClient8500 = consul8500.healthClient(); + healthClient8500.getAllServiceInstances("apigateway-default", CatalogOptions.BLANK, QueryOptions.BLANK, + callback); + healthClient8500.getHealthyServiceInstances("apigateway-default", CatalogOptions.BLANK, QueryOptions.BLANK, + callback); + + } } -- cgit 1.2.3-korg