modify as review suggestions:change junit Assert to assertj Assetions...

pull/600/head
pandaapo 3 years ago
parent 2f77fa2b40
commit 342d53531f

@ -37,6 +37,7 @@ import com.tencent.cloud.common.util.JacksonUtils;
import com.tencent.cloud.common.util.expresstion.SpringWebExpressionLabelUtils;
import com.tencent.cloud.polaris.router.RouterRuleLabelResolver;
import com.tencent.cloud.polaris.router.spi.SpringWebRouterLabelResolver;
import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -149,7 +150,7 @@ public class PolarisLoadBalancerInterceptorTest {
catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported charset exception " + UTF_8);
}
Assert.assertEquals(mockedResponse.getHeaders().get(PolarisRouterContext.ROUTER_LABELS).get(0), encodedLabelsContent);
Assertions.assertThat(mockedResponse.getHeaders().get(PolarisRouterContext.ROUTER_LABELS).get(0)).isEqualTo(encodedLabelsContent);
}
}
}

@ -137,7 +137,7 @@ public class EnhancedRestTemplateReporter extends AbstractPolarisReporterAdapter
}
List<String> labels = response.getHeaders().get(PolarisRouterContext.ROUTER_LABELS);
if (CollectionUtils.isNotEmpty(labels) && labels.size() > 0) {
if (CollectionUtils.isNotEmpty(labels)) {
String label = labels.get(0);
try {
label = URLDecoder.decode(label, UTF_8);

@ -31,6 +31,7 @@ import com.tencent.cloud.common.util.ApplicationContextAwareUtils;
import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties;
import com.tencent.polaris.api.core.ConsumerAPI;
import com.tencent.polaris.api.rpc.ServiceCallResult;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
@ -133,7 +134,7 @@ public class EnhancedRestTemplateReporterTest {
verify(consumerAPI, times(2)).updateServiceCallResult((ServiceCallResult) captor.capture());
ServiceCallResult value = (ServiceCallResult) captor.getValue();
Assert.assertEquals(value.getLabels(), "k1:v1|k2:v2");
Assertions.assertThat(value.getLabels()).isEqualTo("k1:v1|k2:v2");
verify(delegate).handleError(uri, HttpMethod.GET, response);
}

Loading…
Cancel
Save