Skip to content
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

Fix parameters to builder #1571

Merged
merged 3 commits into from
Jan 9, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ public Builder toBuilder() {
.type(getType())
.name(getName())
.builtIn(builtIn)
.value(value)
.required(required)
.sourceLocation(sourceLocation)
.deprecated(deprecated)
.documentation(documentation)
.value(value);
.defaultValue(defaultValue);
}

public String template() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import software.amazon.smithy.model.traits.AbstractTraitBuilder;
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.utils.BuilderRef;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.SmithyUnstableApi;
import software.amazon.smithy.utils.ToSmithyBuilder;

Expand Down Expand Up @@ -58,7 +57,7 @@ protected Node createNode() {
}

@Override
public SmithyBuilder<ClientContextParamsTrait> toBuilder() {
public Builder toBuilder() {
return builder()
.sourceLocation(getSourceLocation())
.parameters(getParameters());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package software.amazon.smithy.rulesengine.language.syntax;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import software.amazon.smithy.model.node.Node;
import software.amazon.smithy.rulesengine.language.eval.Value;
import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter;
import software.amazon.smithy.rulesengine.language.syntax.parameters.ParameterType;

public class ParameterTest {
kstich marked this conversation as resolved.
Show resolved Hide resolved
@Test
void parameterToBuilderRoundTrips() {
Parameter p = Parameter.builder()
.name("test")
.builtIn("Test::BuiltIn")
.required(true)
.defaultValue(Value.bool(true))
.type(ParameterType.BOOLEAN)
.deprecated(new Parameter.Deprecated("message", "I wrote this test"))
.value(Node.from(true))
.documentation("here are some docs")
.build();
assertEquals(p, p.toBuilder().build());
}
}