@@ -9,11 +9,13 @@ package com.owncloud.android.lib.resources.shares
99
1010import com.owncloud.android.AbstractIT
1111import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation
12+ import com.owncloud.android.lib.resources.shares.attributes.ShareAttributes
13+ import com.owncloud.android.lib.resources.shares.attributes.ShareAttributesJsonHandler
1214import com.owncloud.android.lib.resources.status.GetStatusRemoteOperation
1315import com.owncloud.android.lib.resources.status.NextcloudVersion
1416import com.owncloud.android.lib.resources.status.OwnCloudVersion
15- import org.junit.Assert
1617import org.junit.Assert.assertEquals
18+ import org.junit.Assert.assertTrue
1719import org.junit.Assume
1820import org.junit.Before
1921import org.junit.Test
@@ -22,41 +24,58 @@ class CreateShareRemoteOperationIT : AbstractIT() {
2224 @Before
2325 fun before () {
2426 val result = GetStatusRemoteOperation (context).execute(client)
25- Assert . assertTrue(result.isSuccess)
27+ assertTrue(result.isSuccess)
2628 val data = result.data as ArrayList <Any >
2729 val ownCloudVersion = data[0 ] as OwnCloudVersion
2830 Assume .assumeTrue(ownCloudVersion.isNewerOrEqual(NextcloudVersion .nextcloud_24))
2931 }
3032
3133 @Test
32- fun createShareWithNote () {
33- val note = " This is the note"
34-
35- Assert .assertTrue(
36- CreateFolderRemoteOperation (
37- " /share/" ,
38- true
39- ).execute(client).isSuccess
34+ fun createShareWithNoteAndAttributes () {
35+ val attributes = ShareAttributesJsonHandler .toJson(
36+ listOf (ShareAttributes .createDownloadAttributes(true ))
4037 )
38+ val note = " Note with attributes"
39+ val path = " /shareWithAttributes/"
4140
42- // share folder to user "admin"
43- val sut =
44- CreateShareRemoteOperation (
45- " /share/" ,
46- ShareType .USER ,
47- " admin" ,
48- false ,
49- " " ,
50- OCShare .MAXIMUM_PERMISSIONS_FOR_FOLDER ,
51- true ,
52- note,
53- null
54- ).execute(client)
55-
56- junit.framework.Assert .assertTrue(sut.isSuccess)
41+ createFolder(path)
42+ val share = createShare(path, " admin" , note, attributes)
43+ assertEquals(note, share.note)
44+ }
5745
58- val share = sut.resultData[0 ]
46+ @Test
47+ fun createShareWithNote () {
48+ val note = " This is the note"
49+ val path = " /share/"
5950
51+ createFolder(path)
52+ val share = createShare(path, " admin" , note)
6053 assertEquals(note, share.note)
6154 }
55+
56+ private fun createFolder (path : String ) {
57+ assertTrue(CreateFolderRemoteOperation (path, true ).execute(client).isSuccess)
58+ }
59+
60+ private fun createShare (
61+ path : String ,
62+ accountName : String ,
63+ note : String ,
64+ attributes : String? = null
65+ ): OCShare {
66+ val operation = CreateShareRemoteOperation (
67+ path,
68+ ShareType .USER ,
69+ accountName,
70+ false ,
71+ " " ,
72+ OCShare .MAXIMUM_PERMISSIONS_FOR_FOLDER ,
73+ true ,
74+ note,
75+ attributes
76+ )
77+ val result = operation.execute(client)
78+ assertTrue(result.isSuccess)
79+ return result.resultData[0 ]
80+ }
6281}
0 commit comments