com.base.Services.UserServiceTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 3
c 5
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetUser() 0 8 2
A testGetUserThrowsNotFound() 0 3 1
testGetUser 0 8 ?
testGetUserThrowsNotFound 0 3 ?
1
package com.base.Services;
2
3
import com.base.AbstractBaseTest;
4
import com.base.Exceptions.UserNotFound;
5
import com.base.Http.Server.Responses.User.GetUserResponse;
6
import com.base.Models.User;
7
import org.junit.Assert;
8
import org.junit.Test;
9
10
public class UserServiceTest extends AbstractBaseTest {
11
12
    /**
13
     * Test case for Get User
14
     *
15
     * @throws UserNotFound
16
     */
17
    @Test
18
    public void testGetUser() throws UserNotFound {
19
        try {
20
            User user = base.userService().getUser(String.valueOf(GetUserResponse.VALID_USER_ID));
21
            Assert.assertEquals(user.getName(), GetUserResponse.USER_NAME);
22
            Assert.assertEquals(user.getEmail(), GetUserResponse.USER_EMAIL);
23
        } catch (UserNotFound e) {
24
            Assert.fail(e.getMessage());
25
        }
26
    }
27
28
    /**
29
     * Test case for Get User that throws UserNotFound exception.
30
     *
31
     * @throws UserNotFound
32
     */
33
    @Test(expected = UserNotFound.class)
34
    public void testGetUserThrowsNotFound() throws UserNotFound {
35
        User user = base.userService().getUser("20000");
36
    }
37
}
38