修复由于resttemplate返回的list元素为linkedhashmap导致的获取基础数据失败的问题。
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.manager.OrmsStandManager;
|
||||
import com.gzzn.omms.msgexchangeapi.config.TestRestTemplateConfig;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes=TestRestTemplateConfig.class)
|
||||
public class OrmsStandManagerTest {
|
||||
|
||||
@Test
|
||||
public void testFindAll()
|
||||
{
|
||||
OrmsStand ormsStand = OrmsStandManager.getInstance().getOrmsStandByStandCode("140");
|
||||
assertThat(ormsStand).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,9 +12,10 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.service.IOrmsStandService;
|
||||
import com.gzzn.omms.msgexchangeapi.config.TestRestTemplateConfig;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(classes=TestRestTemplateConfig.class)
|
||||
public class OrmsStandServiceImplTest {
|
||||
|
||||
@Autowired
|
||||
@@ -26,4 +27,7 @@ public class OrmsStandServiceImplTest {
|
||||
List<OrmsStand> lsOrmsStands = ormsStandService.findAll();
|
||||
assertThat(lsOrmsStands).isNotEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.gzzn.omms.msgexchangeapi.config;
|
||||
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@TestConfiguration
|
||||
public class TestRestTemplateConfig {
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(5000);//单位为ms
|
||||
factory.setConnectTimeout(5000);//单位为ms
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user