@@ -171,9 +171,9 @@ public void itShouldReturnTheUserMemberShipList() throws IOException {
171
171
.thenReturn (jsonUserGroupsPayload2 )
172
172
.thenReturn (jsonUserGroupsPayload3 );
173
173
174
- UserGroup userGroup1 = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 22 ));
175
- UserGroup userGroup2 = new UserGroupEntity ("project_admins" , new ProjectEntity ("coincoin" , 22 ));
176
- UserGroup userGroup3 = new UserGroupEntity ("project_members" , new ProjectEntity ("git-test" , 33 ));
174
+ UserGroup userGroup1 = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 22 , "projects/106" , "coincoin" ));
175
+ UserGroup userGroup2 = new UserGroupEntity ("project_admins" , new ProjectEntity ("coincoin" , 22 , "projects/106" , "coincoin" ));
176
+ UserGroup userGroup3 = new UserGroupEntity ("project_members" , new ProjectEntity ("git-test" , 33 , "projects/113" , "git-test" ));
177
177
178
178
List <UserGroup > expectedList = Arrays .asList (userGroup1 , userGroup2 , userGroup3 );
179
179
@@ -210,7 +210,7 @@ public void itShouldCallGetUserMembershipNameIfTheServerReturns400() throws IOEx
210
210
.thenReturn (jsonUserMembershipPayload )
211
211
.thenReturn (jsonUserGroupsPayload1 );
212
212
213
- UserGroup userGroup1 = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 22 ));
213
+ UserGroup userGroup1 = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 22 , "projects/106" , "coincoin" ));
214
214
List <UserGroup > expectedList = Arrays .asList (userGroup1 );
215
215
216
216
List <UserGroup > resultList = this .tuleapApiClient .getUserMembership (this .accessToken );
@@ -235,8 +235,8 @@ public void itShouldReturnUserMembership() throws IOException {
235
235
when (responseBody .string ())
236
236
.thenReturn (projectMembershipPayload );
237
237
238
- UserGroup userMembership1 = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 106 ));
239
- UserGroup userMembership2 = new UserGroupEntity ("atchoum" , new ProjectEntity ("git-test" , 113 ));
238
+ UserGroup userMembership1 = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 106 , "projects/106" , "coincoin" ));
239
+ UserGroup userMembership2 = new UserGroupEntity ("atchoum" , new ProjectEntity ("git-test" , 113 , "projects/113" , "git-test" ));
240
240
241
241
List <UserGroup > expectedList = Arrays .asList (userMembership1 , userMembership2 );
242
242
@@ -290,7 +290,7 @@ public void itReturnsTheUserGroup() throws IOException {
290
290
when (responseBody .string ())
291
291
.thenReturn (jsonUserGroupsPayload );
292
292
293
- UserGroup expectedUserGroup = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 22 ));
293
+ UserGroup expectedUserGroup = new UserGroupEntity ("project_members" , new ProjectEntity ("coincoin" , 22 , "projects/106" , "coincoin" ));
294
294
UserGroup resultUserGroup = tuleapApiClient .getUserGroup ("106_3" , accessToken );
295
295
assertEquals (expectedUserGroup .getGroupName (), resultUserGroup .getGroupName ());
296
296
assertEquals (expectedUserGroup .getProjectName (), resultUserGroup .getProjectName ());
@@ -679,4 +679,41 @@ public CredentialsDescriptor getDescriptor() {
679
679
}
680
680
};
681
681
}
682
+
683
+ @ Test (expected = RuntimeException .class )
684
+ public void itThrowsExceptionWhenTheProjectCannotBeRetrieved () throws IOException , FileContentNotFoundException {
685
+ TuleapAccessToken tuleapAccessToken = this .getTuleapAccessTokenStubClass ();
686
+ Call call = mock (Call .class );
687
+ Response response = mock (Response .class );
688
+
689
+ when (client .newCall (any ())).thenReturn (call );
690
+ when (call .execute ()).thenReturn (response );
691
+ when (response .code ()).thenReturn (400 );
692
+ when (response .isSuccessful ()).thenReturn (false );
693
+
694
+ tuleapApiClient .getProjectById ("10" , tuleapAccessToken );
695
+ }
696
+
697
+ @ Test
698
+ public void itReturnsTheWantedGivenIdProject () throws IOException {
699
+ TuleapAccessToken tuleapAccessToken = this .getTuleapAccessTokenStubClass ();
700
+ Call call = mock (Call .class );
701
+ Response response = mock (Response .class );
702
+ ResponseBody responseBody = mock (ResponseBody .class );
703
+ String payload = IOUtils .toString (TuleapApiClientTest .class .getResourceAsStream ("single_project_payload.json" ), UTF_8 );
704
+
705
+ when (client .newCall (any ())).thenReturn (call );
706
+ when (call .execute ()).thenReturn (response );
707
+ when (response .isSuccessful ()).thenReturn (true );
708
+ when (response .body ()).thenReturn (responseBody );
709
+ when (responseBody .string ()).thenReturn (payload );
710
+
711
+ Project project = tuleapApiClient .getProjectById ("use-me" , tuleapAccessToken );
712
+
713
+ assertEquals ("use-me" , project .getShortname ());
714
+ Integer expectedId = 118 ;
715
+ assertEquals (expectedId , project .getId ());
716
+ assertEquals ("Use Me" , project .getLabel ());
717
+ assertEquals ("projects/118" , project .getUri ());
718
+ }
682
719
}
0 commit comments