【发布时间】:2018-04-21 01:24:12
【问题描述】:
public List<Locatins> fetchLocations() {
BasicAuthRestTemplate restTemplate = new BasicAuthRestTemplate(config.getUsername(),config.getPassword());
String locationsOData = restTemplate.getForObject(config.getOdataUrl()+config.getLocations(), String.class);
String results = StringUtility.changeUIFieldCase(locations);
return map.Locations(results);
}
@Test
public void fetchLocationsTest() throws Exception {�
List<Locations> li = new ArrayList<>();
String locationData = "noting";
when(config.getUsername()).thenReturn(“test1”);
when(config.getPassword()).thenReturn("test12”);
when(config.getTdsOdataUrl()).thenReturn("https://localhost:8080");
when(config.getLocations()).thenReturn("/locations");
PowerMockito.mockStatic(BasicAuthRestTemplate.class);
PowerMockito.whenNew(BasicAuthRestTemplate.class).withArguments(config.getUsername(), config.getPassword()).thenReturn(restTemplate);
PowerMockito.when(restTemplate.getForObject("https://localhost:8080/locations",String.class)).thenReturn(locationData);
�
}
【问题讨论】: