Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
package com.owncloud.android.lib.resources.status

enum class E2EVersion(
val value: String
val values: List<String>
) {
V1_0("1.0"),
V1_1("1.1"),
V1_2("1.2"),
V2_0("2.0"),
V2_1("2.1"),
UNKNOWN("");
V1_0(listOf("1", "1.0")),
V1_1(listOf("1.1")),
V1_2(listOf("1.2")),
V2_0(listOf("2", "2.0")),
V2_1(listOf("2.1")),
UNKNOWN(listOf(""));

val value: String = values.last()

companion object {
@JvmStatic
fun fromValue(v: String): E2EVersion = entries.firstOrNull { it.value == v } ?: UNKNOWN
fun fromValue(v: String?): E2EVersion = entries.find { v in it.values } ?: UNKNOWN
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android.lib.resources.status

import org.junit.Assert.assertEquals
import org.junit.Test

class E2EVersionTests {
@Test
fun testFromValueWhenGiven1ShouldReturnTrue() {
assertEquals(E2EVersion.V1_0, E2EVersion.fromValue("1"))
}

@Test
fun testFromValueWhenGiven1Dot0ShouldReturnTrue() {
assertEquals(E2EVersion.V1_0, E2EVersion.fromValue("1.0"))
}

@Test
fun testFromValueWhenGiven1Dot1ShouldReturnTrue() {
assertEquals(E2EVersion.V1_1, E2EVersion.fromValue("1.1"))
}

@Test
fun testFromValueWhenGiven1Dot2ShouldReturnTrue() {
assertEquals(E2EVersion.V1_2, E2EVersion.fromValue("1.2"))
}

@Test
fun testFromValueWhenGiven2ShouldReturnTrue() {
assertEquals(E2EVersion.V2_0, E2EVersion.fromValue("2"))
}

@Test
fun testFromValueWhenGiven2Dot0ShouldReturnTrue() {
assertEquals(E2EVersion.V2_0, E2EVersion.fromValue("2.0"))
}

@Test
fun testFromValueWhenGiven2Dot1ShouldReturnTrue() {
assertEquals(E2EVersion.V2_1, E2EVersion.fromValue("2.1"))
}

@Test
fun testFromValueWhenGivenEmptyShouldReturnTrue() {
assertEquals(E2EVersion.UNKNOWN, E2EVersion.fromValue(""))
}

@Test
fun testFromValueWhenGivenUnknownShouldReturnTrue() {
assertEquals(E2EVersion.UNKNOWN, E2EVersion.fromValue("3"))
}

@Test
fun testFromValueWhenGivenNullShouldReturnTrue() {
assertEquals(E2EVersion.UNKNOWN, E2EVersion.fromValue(null))
}

@Test
fun testValues() {
assertEquals(E2EVersion.V1_0.value, "1.0")
assertEquals(E2EVersion.V1_1.value, "1.1")
assertEquals(E2EVersion.V1_2.value, "1.2")
assertEquals(E2EVersion.V2_0.value, "2.0")
assertEquals(E2EVersion.V2_1.value, "2.1")
assertEquals(E2EVersion.UNKNOWN.value, "")
}
}
Loading