Passed
Push — master ( 7072a0...7d8832 )
by Kunal
03:50
created

com.base.Http.Server.Responses.ChannelMember.GetAllChannelMembersResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
dl 0
loc 34
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
getUsers 0 11 ?
A getUsers() 0 11 2
A GetAllChannelMembersResponse(String,String) 0 4 1
A getResponse(Request,Response) 0 4 1
A GetAllChannelMembersResponse() 0 ? 1
1
package com.base.Http.Server.Responses.ChannelMember;
2
3
import com.base.Http.Request.Request;
4
import com.base.Http.Response.Response;
5
import com.base.Http.Server.Responses.BaseResponse;
6
import com.base.Models.User;
7
8
import java.util.ArrayList;
9
import java.util.List;
10
11
public class GetAllChannelMembersResponse extends BaseResponse {
12
13
    public static String VALID_TEAM_SLUG = "twitter";
14
    public static String VALID_CHANNEL_SLUG = "design";
15
    public static int VALID_USER_ID = 0;
16
    public static String VALID_USER_NAME = "Sharvil";
17
18
    public GetAllChannelMembersResponse() {
19
        super();
20
    }
21
22
    public GetAllChannelMembersResponse(String teamSlug, String channelSlug) {
23
        super();
24
        VALID_TEAM_SLUG = teamSlug;
25
        VALID_CHANNEL_SLUG = channelSlug;
26
    }
27
28
    @Override
29
    public Response getResponse(Request request, Response response) {
30
        return response.setStatusCode(200)
31
                .setBody(generateResponseBody(getUsers()));
32
    }
33
34
    private List<User> getUsers() {
35
        List<User> users = new ArrayList<>();
36
37
        for (int i = 1; i <= 3; i++) {
38
            users.add((User) new User()
39
                    .setEmail(VALID_USER_NAME + i + "@gmail.com")
40
                    .setName(VALID_USER_NAME + "i")
41
                    .setId(VALID_USER_ID + i));
42
        }
43
44
        return users;
45
    }
46
}
47
48