Skip to content

Commit 9a60e7b

Browse files
committed
require groupTagWithoutCVS to work correct: instead of warning we now throw an exception.
1 parent 09bba95 commit 9a60e7b

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/main/kotlin/de/gmuth/ipp/iana/IppRegistrationsSection2.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ package de.gmuth.ipp.iana
44
* Copyright (c) 2020-2024 Gerhard Muth
55
*/
66

7-
import de.gmuth.ipp.core.IppAttribute
8-
import de.gmuth.ipp.core.IppCollection
9-
import de.gmuth.ipp.core.IppMessage
10-
import de.gmuth.ipp.core.IppTag
7+
import de.gmuth.ipp.core.*
118
import de.gmuth.ipp.core.IppTag.*
129
import java.util.logging.Logger.getLogger
1310

@@ -119,13 +116,15 @@ object IppRegistrationsSection2 {
119116

120117
fun selectGroupForAttribute(name: String) =
121118
getAttribute(name, false)?.collectionGroupTag().also {
122-
// Also lookup via hard coded list. In the future I might remove the rather large csv file.
119+
// Also lookup via hard coded list. In the future I might remove the rather large csv files.
123120
val groupTagWithoutCSV = if (attributesForGroupOperation.contains(name)) Operation else Job
124-
if (it != groupTagWithoutCSV) logger.warning {
125-
"Incorrect attribute group for attribute '$name': is $groupTagWithoutCSV, expected $it. " +
126-
if (it == null) "" else
127-
"This needs to be fixed in IppRegistrationSection2.attributesForGroupOperation!" +
128-
" (Please open a bug ticket on https://github.com/gmuth/ipp-client-kotlin/issues)."
121+
if (it != groupTagWithoutCSV) StringBuilder().run {
122+
append("Incorrect attribute group for attribute '$name': is $groupTagWithoutCSV, expected $it.")
123+
it?.run {
124+
append(" This needs to be fixed in IppRegistrationSection2.attributesForGroupOperation!")
125+
append(" Please open a bug ticket on https://github.com/gmuth/ipp-client-kotlin/issues.")
126+
}
127+
throw IppException(toString())
129128
}
130129
}
131130

@@ -234,9 +233,11 @@ object IppRegistrationsSection2 {
234233
"job-pages-col",
235234
"job-password",
236235
"job-password-encryption",
236+
"job-release-action",
237237
"job-state",
238238
"job-state-message",
239239
"job-state-reasons",
240+
"job-storage",
240241
"job-uri",
241242
"last-document",
242243
"limit",

src/test/kotlin/de/gmuth/ipp/iana/IppRegistrationSection2Tests.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ class IppRegistrationSection2Tests {
3131
.attributesMap
3232
.values
3333
.filter { it.collection == "Operation" }
34-
.map { "\"${it.name}\"" }
35-
.filter { it.matchesNot(".*(deprecated|obsolete).*") }
34+
.map { it.name }
35+
.filter { it.matchesNot(".*(deprecated|obsolete|extension).*") }
3636
.distinct()
3737
.sorted()
38-
.forEach { println("$it,") }
38+
.onEach { println("\"$it\",") }
3939
//.reduce { list, element -> "$list,$element" }
40+
.forEach {
41+
assertEquals(Operation, selectGroupForAttribute(it), "operation group required for $it")
42+
}
4043
}
4144

4245
@Test

0 commit comments

Comments
 (0)