14
14
import com .crowdin .client .teams .model .ProjectTeamResources ;
15
15
import com .crowdin .client .teams .model .Team ;
16
16
import com .crowdin .client .teams .model .TeamMember ;
17
+ import com .crowdin .client .teams .model .GroupTeam ;
17
18
import com .crowdin .client .users .model .TranslatorRole ;
18
19
import com .crowdin .client .users .model .TranslatorRoleName ;
19
20
import com .crowdin .client .users .model .TranslatorRolePermissions ;
30
31
import java .util .Map ;
31
32
32
33
import static java .util .Collections .singletonList ;
34
+ import static java .util .Collections .singletonMap ;
33
35
import static org .junit .jupiter .api .Assertions .*;
34
36
35
37
public class TeamsApiTest extends TestClient {
36
38
37
39
private final Long projectId = 12L ;
38
40
private final Long userId = 3L ;
39
41
private final Long teamId = 1L ;
42
+ private final Long groupId = 27L ;
40
43
private final String name = "French" ;
41
44
42
45
@ Override
43
46
public List <RequestMock > getMocks () {
44
47
return Arrays .asList (
48
+ RequestMock .build (this .url + "/groups/" + groupId + "/teams" , HttpGet .METHOD_NAME , "api/teams/listGroupTeams.json" ),
49
+ RequestMock .build (this .url + "/groups/" + groupId + "/teams" , HttpPatch .METHOD_NAME , "api/teams/editGroupTeams.json" , "api/teams/listGroupTeams.json" ),
50
+ RequestMock .build (this .url + "/groups/" + groupId + "/teams/" + teamId , HttpGet .METHOD_NAME , "api/teams/groupTeam.json" ),
45
51
RequestMock .build (this .url + "/projects/" + projectId + "/teams" , HttpPost .METHOD_NAME , "api/teams/addTeamToProjectRequest.json" , "api/teams/projectTeamResources.json" ),
46
52
RequestMock .build (this .url + "/teams" , HttpGet .METHOD_NAME , "api/teams/listTeams.json" ),
47
53
RequestMock .build (this .url + "/teams" , HttpPost .METHOD_NAME , "api/teams/addTeamRequest.json" , "api/teams/team.json" ),
@@ -55,6 +61,43 @@ public List<RequestMock> getMocks() {
55
61
);
56
62
}
57
63
64
+ @ Test
65
+ public void listGroupTeamsTest () {
66
+ ResponseList <GroupTeam > response = this .getTeamsApi ().listGroupTeams (groupId , null );
67
+ assertNotNull (response );
68
+ assertEquals (1 , response .getData ().size ());
69
+ assertEquals (groupId , response .getData ().get (0 ).getData ().getId ());
70
+ assertEquals (teamId , response .getData ().get (0 ).getData ().getTeam ().getId ());
71
+ assertEquals (name , response .getData ().get (0 ).getData ().getTeam ().getName ());
72
+ }
73
+
74
+ @ Test
75
+ public void updateGroupTeamsTest () {
76
+ PatchRequest requestAdd = new PatchRequest ();
77
+ requestAdd .setOp (PatchOperation .ADD );
78
+ requestAdd .setPath ("/-" );
79
+ requestAdd .setValue (singletonMap ("teamId" , 1 ));
80
+
81
+ PatchRequest requestRemove = new PatchRequest ();
82
+ requestRemove .setOp (PatchOperation .REMOVE );
83
+ requestRemove .setPath ("/24" );
84
+
85
+ List <PatchRequest > requests = Arrays .asList (requestAdd , requestRemove );
86
+ ResponseList <GroupTeam > response = this .getTeamsApi ().updateGroupTeams (groupId , requests );
87
+ assertNotNull (response );
88
+ assertEquals (groupId , response .getData ().get (0 ).getData ().getId ());
89
+ assertEquals (teamId , response .getData ().get (0 ).getData ().getTeam ().getId ());
90
+ }
91
+
92
+ @ Test
93
+ public void getGroupTeamTest () {
94
+ ResponseObject <GroupTeam > response = this .getTeamsApi ().getGroupTeam (groupId , teamId );
95
+ assertNotNull (response );
96
+ assertEquals (groupId , response .getData ().getId ());
97
+ assertEquals (teamId , response .getData ().getTeam ().getId ());
98
+ assertEquals (name , response .getData ().getTeam ().getName ());
99
+ }
100
+
58
101
@ Test
59
102
public void addTeamToProjectTest () {
60
103
AddTeamToProjectRequest request = new AddTeamToProjectRequest ();
0 commit comments