Skip to content

Conversation

@ypiel-talend
Copy link
Contributor

Requirements

  • Any code change adding any logic MUST be tested through a unit test executed with the default build
  • Any API addition MUST be done with a documentation update if relevant

Why this PR is needed?

What does this PR adds (design/code thoughts)?

Copy link
Contributor Author

@ypiel-talend ypiel-talend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have misled you with the code generation for Schema/ Entry. We should simplify hem more. I think we need a builder etc... Simply need to be able to deserialize json->instance.


<build>
<plugins>
<plugin>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this configuration has been added ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because Entry need more than 10 parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, usually we can do some exception by configuration but it seems not possible for number of parameter as you probably already checked. I had the same issue few days ago, and instead of duplicate all the configuration from the parent I have simply deactivate checkstyle on the methode. In the Entry class you can do:

    @ConstructorProperties({ "name", "rawName", "type", "nullable", "metadata", "errorCapable",
            "valid", "elementSchema", "comment", "props", "internalDefaultValue" })
    // Checkstyle off to let have 11 parameters to this constructor (normally 10 max)
    // CHECKSTYLE:OFF
    public Entry(
            final String name,
            final String rawName,
            final Schema.Type type,
            final boolean nullable,
            final boolean metadata,
            final boolean errorCapable,
            final boolean valid,
            final Schema elementSchema,
            final String comment,
            final Map<String, String> props,
            final Object internalDefaultValue) {
        // CHECKSTYLE:ON

It is to authorize an exception, the issue with copying the whole configuration is that if we change something the parent, it will not be reflected in this module.

if (this.name.equals(newValue)) {
return this;
}
return new Entry(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that really needed ? Maybe just simple setter ? what do you think ?

if (this.rawName.equals(newValue)) {
return this;
}
return new Entry(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that really needed ? Maybe just simple setter ? what do you think ?

if (this.type == newValue) {
return this;
}
return new Entry(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem...

}

@Override
public String toString() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use lombok @DaTa it will automaticall y getter/setter/toString/hashCode et...

.build();
}

public static Builder builder() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is need. The goal is just to have a simple java POJO to desrialize a json to a java instance


@Test
void deserializeEntryFromJson() throws Exception {
String json = """
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add component-runtime-impl in scope test, create entry/schema instances, then serialize them to json, and deserialize to the new class. We have to check it is compatible with Entry/Schema defined in component-runtime-impl at test test.

yyin-talend and others added 5 commits January 12, 2026 14:33
…ent-runtime into ypiel/QTDI-2215-JsonSchema

# Conflicts:
#	component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/front/SchemaTest.java
Copy link
Contributor Author

@ypiel-talend ypiel-talend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add some comment and did few commit mainly to improve unit tests


<build>
<plugins>
<plugin>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, usually we can do some exception by configuration but it seems not possible for number of parameter as you probably already checked. I had the same issue few days ago, and instead of duplicate all the configuration from the parent I have simply deactivate checkstyle on the methode. In the Entry class you can do:

    @ConstructorProperties({ "name", "rawName", "type", "nullable", "metadata", "errorCapable",
            "valid", "elementSchema", "comment", "props", "internalDefaultValue" })
    // Checkstyle off to let have 11 parameters to this constructor (normally 10 max)
    // CHECKSTYLE:OFF
    public Entry(
            final String name,
            final String rawName,
            final Schema.Type type,
            final boolean nullable,
            final boolean metadata,
            final boolean errorCapable,
            final boolean valid,
            final Schema elementSchema,
            final String comment,
            final Map<String, String> props,
            final Object internalDefaultValue) {
        // CHECKSTYLE:ON

It is to authorize an exception, the issue with copying the whole configuration is that if we change something the parent, it will not be reflected in this module.

private final Map<String, String> props;

@ConstructorProperties({"type", "elementSchema", "entries", "metadata", "props"})
public Schema(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a java doc to explain that this class is only for deserialization usage and should be used as a DTO not as a real TCK schema since it doesn't implement SChama interface and doesn't have some business rule as the SchemaImpl from component-runtime-impl has.

@sonar-eks
Copy link

sonar-eks bot commented Jan 13, 2026

Failed Quality Gate failed

  • 0.00% Coverage on New Code (is less than 80.00%)
  • 2 New Issues (is greater than 0)

Project ID: org.talend.sdk.component:component-runtime

View in SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants