Add tests for userService
This commit is contained in:
@@ -10,6 +10,9 @@ import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UserServiceTest {
|
||||
|
||||
@@ -51,6 +54,38 @@ public class UserServiceTest {
|
||||
Assert.assertEquals(estimate, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveFootprint() throws Exception {
|
||||
Float estimate = new Float(5);
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/saveFootprint?name=Eric"),
|
||||
Float.class))
|
||||
.thenReturn(estimate);
|
||||
Float result = userService.saveFootprint("Eric");
|
||||
Assert.assertEquals(estimate, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFriendNamesTest() throws Exception {
|
||||
List<String> estimate = new ArrayList<String>();
|
||||
estimate.add("alex");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/getFriends?name=Eric"),
|
||||
List.class))
|
||||
.thenReturn(estimate);
|
||||
List<String> result = userService.getFriendNames("Eric");
|
||||
Assert.assertEquals(estimate, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllUsers() throws Exception {
|
||||
List<String> estimate = new ArrayList<String>();
|
||||
estimate.add("alex");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/getAllUsers"),
|
||||
List.class))
|
||||
.thenReturn(estimate);
|
||||
List<String> result = userService.getAllUsers();
|
||||
Assert.assertEquals(estimate, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setInputTest() throws Exception {
|
||||
userService.updateInput("Eric", "input_size", "5");
|
||||
|
||||
Reference in New Issue
Block a user