1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

add changes according to review

This commit is contained in:
Christian Schabesberger 2020-10-19 15:10:41 +02:00 committed by Abel García de Prada
parent db478efedc
commit 76c55c9a9c
4 changed files with 27 additions and 39 deletions

View File

@ -16,12 +16,6 @@ dependencies {
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion" kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"
testImplementation 'junit:junit:4.13' testImplementation 'junit:junit:4.13'
testImplementation 'org.robolectric:robolectric:4.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:core:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:rules:1.3.0'
} }
android { android {
@ -48,10 +42,4 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
testOptions {
unitTests {
includeAndroidResources = true
}
}
} }

View File

@ -121,18 +121,6 @@ class GetRemoteShareesOperation
return RemoteOperationResult(method) return RemoteOperationResult(method)
} }
private fun flattenResultData(jsonResults: Array<JSONArray>):ArrayList<JSONObject> {
val data = ArrayList<JSONObject>() // For result data
for (i in 0..jsonResults.size) {
for (j in 0 until jsonResults[i].length()) {
val jsonResult = jsonResults[i].getJSONObject(j)
data.add(jsonResult)
Timber.d("*** Added item: ${jsonResult.getString(PROPERTY_LABEL)}")
}
}
return data
}
private fun onRequestSuccessful(response: String?): RemoteOperationResult<ShareeOcsResponse> { private fun onRequestSuccessful(response: String?): RemoteOperationResult<ShareeOcsResponse> {
val result = RemoteOperationResult<ShareeOcsResponse>(OK) val result = RemoteOperationResult<ShareeOcsResponse>(OK)
Timber.d("Successful response: $response") Timber.d("Successful response: $response")

View File

@ -32,13 +32,9 @@ import com.squareup.moshi.JsonClass
*/ */
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
data class ShareeOcsResponse( data class ShareeOcsResponse(
@Json(name = "exact")
val exact: ExactSharees?, val exact: ExactSharees?,
@Json(name = "groups")
val groups: List<ShareeItem>, val groups: List<ShareeItem>,
@Json(name = "remotes")
val remotes: List<ShareeItem>, val remotes: List<ShareeItem>,
@Json(name = "users")
val users: List<ShareeItem> val users: List<ShareeItem>
) { ) {
fun getFlatRepresentationWithoutExact() = ArrayList<ShareeItem>().apply { fun getFlatRepresentationWithoutExact() = ArrayList<ShareeItem>().apply {
@ -50,11 +46,8 @@ data class ShareeOcsResponse(
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
data class ExactSharees( data class ExactSharees(
@Json(name = "groups")
val groups: List<ShareeItem>, val groups: List<ShareeItem>,
@Json(name = "remotes")
val remotes: List<ShareeItem>, val remotes: List<ShareeItem>,
@Json(name = "users")
val users: List<ShareeItem> val users: List<ShareeItem>
) { ) {
fun getFlatRepresentation() = ArrayList<ShareeItem>().apply { fun getFlatRepresentation() = ArrayList<ShareeItem>().apply {
@ -66,17 +59,13 @@ data class ExactSharees(
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
data class ShareeItem( data class ShareeItem(
@Json(name = "label")
val label: String, val label: String,
@Json(name = "value")
val value: ShareeValue val value: ShareeValue
) )
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
data class ShareeValue( data class ShareeValue(
@Json(name = "shareType")
val shareType: Int, val shareType: Int,
@Json(name = "shareWith")
val shareWith: String, val shareWith: String,
@Json(name = "shareWithAdditionalInfo") @Json(name = "shareWithAdditionalInfo")
val additionalInfo: String? val additionalInfo: String?

View File

@ -1,12 +1,35 @@
package com.owncloud.android.lib /* ownCloud Android Library is available under MIT license
* Copyright (C) 2020 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.resources.shares.responses
import com.owncloud.android.lib.resources.CommonOcsResponse import com.owncloud.android.lib.resources.CommonOcsResponse
import com.owncloud.android.lib.resources.shares.responses.ShareeOcsResponse
import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import com.squareup.moshi.Types import com.squareup.moshi.Types
import junit.framework.Assert.assertEquals import org.junit.Assert.assertEquals
import junit.framework.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Assert.assertNotEquals import org.junit.Assert.assertNotEquals
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test