Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
add changes according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Oct 20, 2020
1 parent 3278e6f commit b74e4cc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 39 deletions.
12 changes: 0 additions & 12 deletions owncloudComLibrary/build.gradle
Expand Up @@ -16,12 +16,6 @@ dependencies {
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"

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 {
Expand All @@ -48,10 +42,4 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests {
includeAndroidResources = true
}
}
}
Expand Up @@ -121,18 +121,6 @@ class GetRemoteShareesOperation
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> {
val result = RemoteOperationResult<ShareeOcsResponse>(OK)
Timber.d("Successful response: $response")
Expand Down
Expand Up @@ -32,13 +32,9 @@ import com.squareup.moshi.JsonClass
*/
@JsonClass(generateAdapter = true)
data class ShareeOcsResponse(
@Json(name = "exact")
val exact: ExactSharees?,
@Json(name = "groups")
val groups: List<ShareeItem>,
@Json(name = "remotes")
val remotes: List<ShareeItem>,
@Json(name = "users")
val users: List<ShareeItem>
) {
fun getFlatRepresentationWithoutExact() = ArrayList<ShareeItem>().apply {
Expand All @@ -50,11 +46,8 @@ data class ShareeOcsResponse(

@JsonClass(generateAdapter = true)
data class ExactSharees(
@Json(name = "groups")
val groups: List<ShareeItem>,
@Json(name = "remotes")
val remotes: List<ShareeItem>,
@Json(name = "users")
val users: List<ShareeItem>
) {
fun getFlatRepresentation() = ArrayList<ShareeItem>().apply {
Expand All @@ -66,17 +59,13 @@ data class ExactSharees(

@JsonClass(generateAdapter = true)
data class ShareeItem(
@Json(name = "label")
val label: String,
@Json(name = "value")
val value: ShareeValue
)

@JsonClass(generateAdapter = true)
data class ShareeValue(
@Json(name = "shareType")
val shareType: Int,
@Json(name = "shareWith")
val shareWith: String,
@Json(name = "shareWithAdditionalInfo")
val additionalInfo: String?
Expand Down
@@ -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.shares.responses.ShareeOcsResponse
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertTrue
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Assert.assertNotEquals
import org.junit.Before
import org.junit.Test
Expand Down

0 comments on commit b74e4cc

Please sign in to comment.