Skip to content
Merged
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
4 changes: 2 additions & 2 deletions api/src/main/java/io/spine/protodata/ast/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
* with the structure of Protobuf files.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
@NullMarked
package io.spine.protodata.ast;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
4 changes: 2 additions & 2 deletions api/src/main/java/io/spine/protodata/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
*/

@CheckReturnValue
@ParametersAreNonnullByDefault
@NullMarked
@JvmLoggingDomain(Constants.LOGGING_DOMAIN)
package io.spine.protodata;

import com.google.errorprone.annotations.CheckReturnValue;
import io.spine.logging.JvmLoggingDomain;

import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
14 changes: 9 additions & 5 deletions api/src/main/kotlin/io/spine/protodata/plugin/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
package io.spine.protodata.plugin

import io.spine.annotation.Internal
import io.spine.base.EntityState
import io.spine.server.add
import io.spine.protodata.context.CodegenContext
import io.spine.protodata.render.Renderer
import io.spine.protodata.render.SourceFileSet
Expand Down Expand Up @@ -169,7 +171,7 @@ public fun MutableSet<Class<out View<*, *, *>>>.add(view: KClass<out View<*, *,
}

/**
* Adds specified entity class to this `BoundedContextBuilder`.
* Adds the specified entity class to this `BoundedContextBuilder`.
*
* A default repository instance will be created for this class.
* This instance will be added to the repository registration list for
Expand All @@ -178,7 +180,9 @@ public fun MutableSet<Class<out View<*, *, *>>>.add(view: KClass<out View<*, *,
* @param I The type of entity identifiers.
* @param E The type of entities.
*/
public inline fun <reified I, reified E : Entity<I, *>>
BoundedContextBuilder.add(entity: KClass<out E>) {
add(entity.java)
}
@Deprecated(
message = "Please use `add(KClass<out E>)` from `io.spine.server` instead.",
replaceWith = ReplaceWith(expression = "add(entity)", imports = ["io.spine.server.add"])
)
public inline fun <reified I : Any, reified S : EntityState<I>, reified E : Entity<I, out S>>
BoundedContextBuilder.add(entity: KClass<out E>) = add(entity)
4 changes: 2 additions & 2 deletions api/src/main/proto/spine/protodata/ast.proto
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ message Type {
option (is).java_type = "TypeBase";

oneof kind {
option (is_required) = true;
option (choice).required = true;

TypeName message = 1;

Expand All @@ -242,7 +242,7 @@ message FieldType {
option (is).java_type = "TypeBase";

oneof kind {
option (is_required) = true;
option (choice).required = true;

// The field holds a message.
TypeName message = 1;
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/proto/spine/protodata/file_pattern.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ option java_multiple_files = true;
message FilePattern {

oneof kind {
option (is_required) = true;
option (choice).required = true;

// The path must end with this string.
string suffix = 1;
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/proto/spine/protodata/settings.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ message Settings {
string consumer = 1;

oneof kind {
option (is_required) = true;
option (choice).required = true;

// No settings are supplied.
google.protobuf.Empty empty = 2;
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/proto/spine/protodata/value.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import "spine/protodata/ast.proto";
message Value {
// The kind of the value.
oneof kind {
option (is_required) = true;
option (choice).required = true;

// The `null` value.
NullValue null_value = 1;
Expand Down
4 changes: 2 additions & 2 deletions api/src/test/java/io/spine/protodata/plugin/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* Tests for Java API of {@link Policy}.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
@NullMarked
package io.spine.protodata.plugin;

import com.google.errorprone.annotations.CheckReturnValue;
import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import io.spine.protodata.context.CodegenContext;
import io.spine.protodata.render.SourceFile;
import io.spine.tools.code.Java;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jspecify.annotations.NonNull;

/**
* A stub rendering action implemented in Java which accepts no parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import io.spine.protodata.context.CodegenContext;
import io.spine.protodata.render.SourceFile;
import io.spine.tools.code.Java;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jspecify.annotations.NonNull;

/**
* A stub rendering action implemented in Java which accepts {@link StringValue} as the parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
* Stub types for testings the {@link io.spine.protodata.settings} package.
*/
@CheckReturnValue
@ParametersAreNonnullByDefault
@NullMarked
package io.spine.protodata.settings.given;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
28 changes: 15 additions & 13 deletions api/src/test/kotlin/io/spine/protodata/CompilationSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ internal class CompilationSpec {
val lineNumber = 100
val columnNumber = 500
val errorMessage = "Some error."
val exception = assertThrows<Compilation.Error> {
Compilation.error(file, lineNumber, columnNumber, errorMessage)
}
exception.message.let {
it shouldContain EMPTY_HOSTNAME_PREFIX
it shouldContain file.uriRef()
it shouldContain "$lineNumber:$columnNumber"
it shouldContain errorMessage
tapConsole {
val exception = assertThrows<Compilation.Error> {
Compilation.error(file, lineNumber, columnNumber, errorMessage)
}
exception.message.let {
it shouldContain EMPTY_HOSTNAME_PREFIX
it shouldContain file.uriRef()
it shouldContain "$lineNumber:$columnNumber"
it shouldContain errorMessage
}
}
}

Expand Down Expand Up @@ -149,12 +151,12 @@ internal class CompilationSpec {
val file = File("some/path/goes/here.proto").toAbsoluteFile()
val span = Span.getDefaultInstance()
val msg = TestValues.randomString()
val error = assertThrows<Compilation.Error> {
Compilation.check(condition = false, file, span) { msg }
tapConsole {
val error = assertThrows<Compilation.Error> {
Compilation.check(condition = false, file, span) { msg }
}
error.message shouldContain msg
}

error.message shouldContain msg

assertDoesNotThrow {
Compilation.check(condition = true, file, span) { msg }
}
Expand Down
6 changes: 3 additions & 3 deletions api/src/test/kotlin/io/spine/protodata/ast/OptionExtsSpec.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024, TeamDev. All rights reserved.
* Copyright 2025, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -123,15 +123,15 @@ internal class OptionExtsSpec {
val oneof = NotificationRequest.getDescriptor().oneofs.find { it.name == "channel" }!!
val options = oneof.options()

options.named("is_required").run {
options.named("choice").run {
doc.leadingComment shouldContain "A channel must be selected."
doc.trailingComment shouldContain "The trailing comment for the `oneof` option."

span.run {
startLine shouldBe 104
startColumn shouldBe 9
endLine shouldBe 104
endColumn shouldBe 37
endColumn shouldBe 46
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions api/src/test/kotlin/io/spine/protodata/value/OptionsSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import io.spine.protodata.protobuf.ProtoFileList
import io.spine.protodata.protobuf.toField
import io.spine.protodata.protobuf.toPbSourceFile
import io.spine.protodata.type.TypeSystem
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -86,6 +87,7 @@ internal class OptionsSpec {
}
}

@Disabled("Until the `Range` type gets its options back.")
@Test
fun `parse reference in the same type`() {
val field = Range.getDescriptor().fields[0].toField()
Expand All @@ -103,6 +105,7 @@ internal class OptionsSpec {
}

@Test
@Disabled("Until the `NumberGenerated` type gets its options back.")
fun `parse references to nested fields`() {
val field = NumberGenerated.getDescriptor().fields[0].toField()
val minOption = field.optionList.find<MinOption>()
Expand Down Expand Up @@ -132,6 +135,7 @@ internal class OptionsSpec {
}
}

@Disabled("Until the `Misreferences` type gets its options back.")
@Nested inner class
`prohibit missing references` {

Expand All @@ -158,6 +162,7 @@ internal class OptionsSpec {
}
}

@Disabled("Until the `Misreferences` type gets its options back.")
@Test
fun `require same field type for reference`() {
val field = Misreferences.getDescriptor().fields[2].toField()
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/proto/protodata/ast/option_exts_spec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ message NotificationRequest {
// A method of notification.
oneof channel {
// A channel must be selected.
option (is_required) = true;
option (choice) = { required: true };
// The trailing comment for the `oneof` option.

EmailNotification email = 2;
Expand Down
21 changes: 15 additions & 6 deletions api/src/test/proto/protodata/given/field_option_samples.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ message KelvinTemperature {
// The option here references the field in the same type.
//
message Range {
int32 min_value = 1 [(max).value = "max_value"];
//TODO:2025-05-08:alexander.yevsyukov: Uncomment after the issue below is resolved.
// https://github.com/SpineEventEngine/validation/issues/64
int32 min_value = 1 /*[(max).value = "max_value"]*/;
int32 max_value = 2;
}

Expand All @@ -64,7 +66,9 @@ message Range {
// The options here reference nested fields.
//
message NumberGenerated {
int32 number = 1 [(min).value = "range.min_value", (max).value = "range.max_value"];
//TODO:2025-05-08:alexander.yevsyukov: Uncomment after the issue below is resolved.
// https://github.com/SpineEventEngine/validation/issues/64
int32 number = 1 /*[(min).value = "range.min_value", (max).value = "range.max_value"]*/;
Range range = 2 [(required) = true];
}

Expand All @@ -74,16 +78,21 @@ message NumberGenerated {

// The cases of wrong field references.
message Misreferences {

//TODO:2025-05-08:alexander.yevsyukov: Uncomment after the issue below is resolved.
// https://github.com/SpineEventEngine/validation/issues/64
// Here the option references the field which is not declared in this message type.
int32 wrong_direct = 1 [(min).value = "missing"];
int32 wrong_direct = 1 /*[(min).value = "missing"]*/;

//TODO:2025-05-08:alexander.yevsyukov: Uncomment after the issue below is resolved.
// https://github.com/SpineEventEngine/validation/issues/64
// Here the option references the missing nested field.
int32 wrong_indirect = 2 [(max).value = "range.top"];
int32 wrong_indirect = 2 /*[(max).value = "range.top"]*/;

//TODO:2025-05-08:alexander.yevsyukov: Uncomment after the issue below is resolved.
// https://github.com/SpineEventEngine/validation/issues/64
// Even though the type of this field is wider than that of the referenced,
// this field should generate the error because we require same types.
int64 wrong_type = 3 [(max).value = "range.max_value"];
int64 wrong_type = 3 /*[(max).value = "range.max_value"]*/;

// The field for checking nested paths.
Range range = 10 [(required) = true];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
*/

@CheckReturnValue
@ParametersAreNonnullByDefault
@NullMarked
package io.spine.protodata.backend;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import io.spine.protodata.context.CodegenContext;
import io.spine.server.query.Querying;
import io.spine.server.query.QueryingClient;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jspecify.annotations.NonNull;

final class FakeQuerying implements Querying {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
*/

@CheckReturnValue
@ParametersAreNonnullByDefault
@NullMarked
package io.spine.protodata.type;

import com.google.errorprone.annotations.CheckReturnValue;

import javax.annotation.ParametersAreNonnullByDefault;
import org.jspecify.annotations.NullMarked;
Loading
Loading