Skip to content

Commit 65df6ae

Browse files
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 3c945f6 commit 65df6ae

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

app/src/main/java/com/owncloud/android/ui/adapter/OCShareToOCFileConverter.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ object OCShareToOCFileConverter {
6262
// don't have file length or mod timestamp
6363
fileLength = -1
6464
modificationTimestamp = -1
65+
isFavorite = firstShare.isFavorite
6566
}
6667
if (shares.any { it.shareType in listOf(ShareType.PUBLIC_LINK, ShareType.EMAIL) }) {
6768
file.isSharedViaLink = true

app/src/test/java/com/owncloud/android/ui/adapter/OCShareToOCFileConverterTest.kt

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package com.owncloud.android.ui.adapter
2323

2424
import com.owncloud.android.lib.resources.shares.OCShare
2525
import com.owncloud.android.lib.resources.shares.ShareType
26-
import org.junit.Assert
26+
import org.junit.Assert.assertEquals
2727
import org.junit.Test
2828

2929
class OCShareToOCFileConverterTest {
@@ -34,16 +34,18 @@ class OCShareToOCFileConverterTest {
3434
OCShare("/foo")
3535
.apply {
3636
shareType = ShareType.PUBLIC_LINK
37+
isFavorite = true
3738
}
3839
)
3940

4041
val result = OCShareToOCFileConverter.buildOCFilesFromShares(shares)
4142

42-
Assert.assertEquals("Wrong file list size", 1, result.size)
43+
assertEquals("Wrong file list size", 1, result.size)
4344
val ocFile = result[0]
44-
Assert.assertEquals("Wrong file path", "/foo", ocFile.remotePath)
45-
Assert.assertEquals("File should have link attribute", true, ocFile.isSharedViaLink)
46-
Assert.assertEquals("File should not have sharee attribute", false, ocFile.isSharedWithSharee)
45+
assertEquals("Wrong file path", "/foo", ocFile.remotePath)
46+
assertEquals("File should have link attribute", true, ocFile.isSharedViaLink)
47+
assertEquals("File should not have sharee attribute", false, ocFile.isSharedWithSharee)
48+
assertEquals("Wrong favorite status", true, ocFile.isFavorite)
4749
}
4850

4951
@Test
@@ -70,13 +72,14 @@ class OCShareToOCFileConverterTest {
7072

7173
val result = OCShareToOCFileConverter.buildOCFilesFromShares(shares)
7274

73-
Assert.assertEquals("Wrong file list size", 1, result.size)
75+
assertEquals("Wrong file list size", 1, result.size)
7476
val ocFile = result[0]
75-
Assert.assertEquals("Wrong file path", "/foo", ocFile.remotePath)
76-
Assert.assertEquals("File should have link attribute", true, ocFile.isSharedViaLink)
77-
Assert.assertEquals("File should have sharee attribute", true, ocFile.isSharedWithSharee)
78-
Assert.assertEquals("Wrong name of sharees", 1, ocFile.sharees.size)
79-
Assert.assertEquals("Wrong shared timestamp", 10000, ocFile.firstShareTimestamp)
77+
assertEquals("Wrong file path", "/foo", ocFile.remotePath)
78+
assertEquals("File should have link attribute", true, ocFile.isSharedViaLink)
79+
assertEquals("File should have sharee attribute", true, ocFile.isSharedWithSharee)
80+
assertEquals("Wrong name of sharees", 1, ocFile.sharees.size)
81+
assertEquals("Wrong shared timestamp", 10000, ocFile.firstShareTimestamp)
82+
assertEquals("Wrong favorite status", false, ocFile.isFavorite)
8083
}
8184

8285
@Test
@@ -112,18 +115,18 @@ class OCShareToOCFileConverterTest {
112115

113116
val result = OCShareToOCFileConverter.buildOCFilesFromShares(shares)
114117

115-
Assert.assertEquals("Wrong file list size", 2, result.size)
118+
assertEquals("Wrong file list size", 2, result.size)
116119

117120
val ocFile = result[0]
118-
Assert.assertEquals("Wrong file path", "/foo", ocFile.remotePath)
119-
Assert.assertEquals("File should have no link attribute", false, ocFile.isSharedViaLink)
120-
Assert.assertEquals("File should have sharee attribute", true, ocFile.isSharedWithSharee)
121-
Assert.assertEquals("Wrong name of sharees", 3, ocFile.sharees.size)
122-
Assert.assertEquals("Wrong shared timestamp", 10000, ocFile.firstShareTimestamp)
121+
assertEquals("Wrong file path", "/foo", ocFile.remotePath)
122+
assertEquals("File should have no link attribute", false, ocFile.isSharedViaLink)
123+
assertEquals("File should have sharee attribute", true, ocFile.isSharedWithSharee)
124+
assertEquals("Wrong name of sharees", 3, ocFile.sharees.size)
125+
assertEquals("Wrong shared timestamp", 10000, ocFile.firstShareTimestamp)
123126

124127
val ocFile2 = result[1]
125-
Assert.assertEquals("Wrong file path", "/bar", ocFile2.remotePath)
126-
Assert.assertEquals("File should have link attribute", true, ocFile2.isSharedViaLink)
127-
Assert.assertEquals("File should have no sharee attribute", false, ocFile2.isSharedWithSharee)
128+
assertEquals("Wrong file path", "/bar", ocFile2.remotePath)
129+
assertEquals("File should have link attribute", true, ocFile2.isSharedViaLink)
130+
assertEquals("File should have no sharee attribute", false, ocFile2.isSharedWithSharee)
128131
}
129132
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
daggerVersion = "2.44.2"
77
markwonVersion = "4.6.2"
88
prismVersion = "2.0.0"
9-
androidLibraryVersion = "master-SNAPSHOT"
9+
androidLibraryVersion = "shareAPIfavorite-SNAPSHOT"
1010
mockitoVersion = "4.9.0"
1111
mockitoKotlinVersion = "4.1.0"
1212
mockkVersion = "1.13.3"

0 commit comments

Comments
 (0)