66import static org .junit .jupiter .api .Assertions .assertTrue ;
77import static org .junit .jupiter .api .Assumptions .assumeTrue ;
88
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 ;
915import java .util .List ;
1016import java .util .Optional ;
1117import java .util .stream .Stream ;
2127import org .junit .jupiter .api .AfterAll ;
2228import org .junit .jupiter .api .BeforeAll ;
2329import org .junit .jupiter .api .BeforeEach ;
30+ import org .junit .jupiter .api .Disabled ;
2431import org .junit .jupiter .api .Tag ;
2532import org .junit .jupiter .api .Test ;
2633import org .junit .jupiter .api .extension .ExtendWith ;
@@ -46,6 +53,8 @@ public class TestGroupApi extends AbstractIntegrationTest {
4653 private static final String TEST_GROUP_MEMBER_USERNAME = HelperUtils .getProperty (GROUP_MEMBER_USERNAME_KEY );
4754 private static final String TEST_REQUEST_ACCESS_USERNAME = HelperUtils .getProperty (TEST_REQUEST_ACCESS_USERNAME_KEY );
4855
56+ private static final String AVATAR_FILENAME = "avatar.png" ;
57+
4958 private static GitLabApi gitLabApi ;
5059 private static Group testGroup ;
5160 private static User testUser ;
@@ -196,6 +205,25 @@ public void getOptionalGroup() {
196205 assertEquals (Response .Status .NOT_FOUND .getStatusCode (), GitLabApi .getOptionalException (optional ).getHttpStatus ());
197206 }
198207
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+
199227
200228 @ Test
201229 public void testRequestAccess () throws GitLabApiException {
0 commit comments