6
6
import static org .junit .jupiter .api .Assertions .assertTrue ;
7
7
import static org .junit .jupiter .api .Assumptions .assumeTrue ;
8
8
9
+ import java .io .File ;
10
+ import java .io .IOException ;
11
+ import java .io .InputStream ;
12
+ import java .nio .file .Files ;
13
+ import java .nio .file .Path ;
14
+ import java .nio .file .StandardCopyOption ;
9
15
import java .util .List ;
10
16
import java .util .Optional ;
11
17
import java .util .stream .Stream ;
21
27
import org .junit .jupiter .api .AfterAll ;
22
28
import org .junit .jupiter .api .BeforeAll ;
23
29
import org .junit .jupiter .api .BeforeEach ;
30
+ import org .junit .jupiter .api .Disabled ;
24
31
import org .junit .jupiter .api .Tag ;
25
32
import org .junit .jupiter .api .Test ;
26
33
import org .junit .jupiter .api .extension .ExtendWith ;
@@ -46,6 +53,8 @@ public class TestGroupApi extends AbstractIntegrationTest {
46
53
private static final String TEST_GROUP_MEMBER_USERNAME = HelperUtils .getProperty (GROUP_MEMBER_USERNAME_KEY );
47
54
private static final String TEST_REQUEST_ACCESS_USERNAME = HelperUtils .getProperty (TEST_REQUEST_ACCESS_USERNAME_KEY );
48
55
56
+ private static final String AVATAR_FILENAME = "avatar.png" ;
57
+
49
58
private static GitLabApi gitLabApi ;
50
59
private static Group testGroup ;
51
60
private static User testUser ;
@@ -196,6 +205,25 @@ public void getOptionalGroup() {
196
205
assertEquals (Response .Status .NOT_FOUND .getStatusCode (), GitLabApi .getOptionalException (optional ).getHttpStatus ());
197
206
}
198
207
208
+ @ Test
209
+ @ Disabled ("Required Gitlab version not less then 14.0" )
210
+ public void testGetAvatar () throws GitLabApiException , IOException {
211
+
212
+ assumeTrue (testGroup != null );
213
+
214
+ File avatarFile = new File ("src/test/resources/org/gitlab4j/api" , AVATAR_FILENAME );
215
+ gitLabApi .getGroupApi ().setGroupAvatar (testGroup .getId (), avatarFile );
216
+
217
+ // Get the avatar of the test Group
218
+ InputStream in = gitLabApi .getGroupApi ().getAvatar (testGroup );
219
+
220
+ Path target = Files .createTempFile (TEST_PROJECT_NAME + "-avatar" , "png" );
221
+ Files .copy (in , target , StandardCopyOption .REPLACE_EXISTING );
222
+
223
+ assertTrue (target .toFile ().length () > 0 );
224
+ Files .delete (target );
225
+ }
226
+
199
227
200
228
@ Test
201
229
public void testRequestAccess () throws GitLabApiException {
0 commit comments