优化
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
package com.baiyue.lastleg.client;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class DomesticWarehouseDirectoryClientContractTest {
|
||||
@Test
|
||||
void freezesActivePlatformWarehouseLookupAndDto() throws Exception {
|
||||
FeignClient feign = DomesticWarehouseDirectoryClient.class.getAnnotation(FeignClient.class);
|
||||
assertThat(feign.name()).isEqualTo("warehouse-service");
|
||||
assertThat(feign.contextId()).isEqualTo("domesticWarehouseDirectoryClient");
|
||||
assertThat(feign.url()).isEqualTo("${baiyue.clients.domestic-warehouse.url:}");
|
||||
|
||||
Method method = DomesticWarehouseDirectoryClient.class.getDeclaredMethod(
|
||||
"activeWarehouse", long.class, String.class);
|
||||
assertThat(method.getAnnotation(GetMapping.class).value())
|
||||
.containsExactly("/internal/warehouses/0/{warehouseId}/active");
|
||||
assertThat(method.getParameters()[0].getAnnotation(PathVariable.class).value())
|
||||
.isEqualTo("warehouseId");
|
||||
assertThat(method.getParameters()[1].getAnnotation(RequestHeader.class).value())
|
||||
.isEqualTo("X-Internal-Service-Token");
|
||||
assertThat(Arrays.stream(DomesticWarehouseDirectoryClient.Warehouse.class.getRecordComponents())
|
||||
.map(value -> value.getName() + ":" + value.getType().getSimpleName()))
|
||||
.containsExactly("id:Long", "tenantId:Long", "warehouseCode:String", "warehouseName:String",
|
||||
"warehouseType:String", "countryCode:String", "status:String");
|
||||
assertThat(Arrays.stream(DomesticWarehouseDirectoryClient.Address.class.getRecordComponents())
|
||||
.map(value -> value.getName() + ":" + value.getType().getSimpleName()))
|
||||
.containsExactly("stateProvince:String");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user