-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(spdx-utils): Support reading dashed reference category names
This is a follow-up to the unmerged changes from [1] to support reading dashed reference category names while still writing underscored names for backward compatibility with ORT's code base. [1]: https://github.com/oss-review-toolkit/ort/pull/7839/files#diff-d290822c4f4714ad4b5d29e52d75edfa3c70e3e80e258d69adf0f6a82d8ae9a4 Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
- Loading branch information
1 parent
c750cfd
commit 508dbfc
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
utils/spdx/src/test/kotlin/model/SpdxExternalReferenceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (C) 2023 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* License-Filename: LICENSE | ||
*/ | ||
|
||
package org.ossreviewtoolkit.utils.spdx.model | ||
|
||
import io.kotest.assertions.json.shouldEqualJson | ||
import io.kotest.core.spec.style.WordSpec | ||
import io.kotest.matchers.collections.shouldContainExactly | ||
|
||
import org.ossreviewtoolkit.utils.spdx.SpdxModelMapper | ||
|
||
class SpdxExternalReferenceTest : WordSpec({ | ||
"Serializing categories" should { | ||
"use underscores in names" { | ||
SpdxModelMapper.toJson(SpdxExternalReference.Category.entries) shouldEqualJson """ | ||
[ | ||
"SECURITY", | ||
"PACKAGE_MANAGER", | ||
"PERSISTENT_ID", | ||
"OTHER" | ||
] | ||
""".trimIndent() | ||
} | ||
} | ||
|
||
"Deserializing categories" should { | ||
"accept dashes in names" { | ||
SpdxModelMapper.fromJson<List<SpdxExternalReference.Category>>( | ||
""" | ||
[ | ||
"SECURITY", | ||
"PACKAGE-MANAGER", | ||
"PERSISTENT-ID", | ||
"OTHER" | ||
] | ||
""".trimIndent() | ||
) shouldContainExactly SpdxExternalReference.Category.entries | ||
} | ||
|
||
"accept underscores in names" { | ||
SpdxModelMapper.fromJson<List<SpdxExternalReference.Category>>( | ||
""" | ||
[ | ||
"SECURITY", | ||
"PACKAGE_MANAGER", | ||
"PERSISTENT_ID", | ||
"OTHER" | ||
] | ||
""".trimIndent() | ||
) shouldContainExactly SpdxExternalReference.Category.entries | ||
} | ||
} | ||
}) |