-
Notifications
You must be signed in to change notification settings - Fork 0
Compile using the new package of ValidatingBuilder
#257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9697e31
ce0f52d
a454248
f9c7cb6
4e1e158
2773b5e
31387e3
7a06914
3237c8a
baf6a96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,11 +189,7 @@ private fun MessagePsiClass.declareSupportingMethods(methods: List<MethodDeclara | |
| * the provided [message] class name as its type parameter. | ||
| */ | ||
| private fun BuilderPsiClass.implementValidatingBuilder(message: PsiClass) { | ||
| // We use `ValidatingBuilder` at the old package to maintain backward compatibility | ||
| // for CoreJvm runtime. Once CoreJvm migrates to the new Validation Runtime, this | ||
| // line should be updated to use `io.spine.validation.ValidatingBuilder`. | ||
| @Suppress("DEPRECATION") | ||
| val qualifiedName = io.spine.validate.ValidatingBuilder::class.java.canonicalName | ||
| val qualifiedName = ValidatingBuilder::class.java.canonicalName | ||
| val genericParameter = message.qualifiedName!! | ||
| val reference = elementFactory.createInterfaceReference(qualifiedName, genericParameter) | ||
| implement(reference) | ||
|
Comment on lines
191
to
195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The generator now makes builders implement only Useful? React with 👍 / 👎. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * 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. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Redistribution and use in source and/or binary forms, with or without | ||
| * modification, must retain the above copyright notice and the following | ||
| * disclaimer. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| package io.spine.test; | ||
|
|
||
| import io.spine.test.protobuf.CardNumber; | ||
| import io.spine.type.TypeName; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| @DisplayName("Generated Java code for a message when called from Java should") | ||
| class JavaMessageJavaApiSmokeTest { | ||
|
|
||
| /** | ||
| * The builder which should produce a valid instance. | ||
| */ | ||
| private final CardNumber.Builder valid = | ||
| CardNumber.newBuilder() | ||
| .setDigits("0000 0000 0000 0000"); | ||
|
|
||
| @Test | ||
| @DisplayName("throw `NullPointerException` if given 'null' for the parent path") | ||
| @SuppressWarnings("DataFlowIssue" /* We pass `null` intentionally */) | ||
| void rejectNullParentPath() { | ||
| var message = valid.build(); | ||
| assertThrows(NullPointerException.class, () -> | ||
| message.validate(null, TypeName.of("Something")) | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * 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. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Redistribution and use in source and/or binary forms, with or without | ||
| * modification, must retain the above copyright notice and the following | ||
| * disclaimer. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| @CheckReturnValue | ||
| @NullMarked | ||
| package io.spine.test; | ||
|
|
||
| import com.google.errorprone.annotations.CheckReturnValue; | ||
| import org.jspecify.annotations.NullMarked; |
Uh oh!
There was an error while loading. Please reload this page.