Skip to content

Commit

Permalink
bugfix: Migrate validation javax to jakarta
Browse files Browse the repository at this point in the history
Changes:
- fix tests;
- migrate from javax to jakarta;

Fixes eclipse-esmf#427
  • Loading branch information
Yauhenikapl committed Oct 19, 2023
1 parent 2ee959e commit 1f76305
Show file tree
Hide file tree
Showing 50 changed files with 164 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import java.math.BigInteger;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import jakarta.validation.constraints.NotNull;

@JsonTypeInfo( use = JsonTypeInfo.Id.NAME )
@JsonSubTypes( {
@JsonSubTypes.Type( value = ExtendingTestEntity.class, name = "ExtendingTestEntity" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

public class AspectWithAbstractEntity {

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

public class AspectWithAbstractSingleEntity {

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import java.util.Collection;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.eclipse.esmf.aspectmodel.java.CollectionAspect;

import jakarta.validation.constraints.NotNull;

public class AspectWithCollectionWithAbstractEntity implements CollectionAspect<Collection<AbstractTestEntity>, AbstractTestEntity> {

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import java.util.Objects;
import java.util.Set;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
* Generated class for Test Aspect. This is a test description
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import java.util.Objects;
import java.util.Set;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
* Generated class for Test Aspect. This is a test description
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
import java.util.List;
import java.util.Objects;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.eclipse.esmf.aspectmodel.java.customconstraint.DoubleMax;
import org.eclipse.esmf.aspectmodel.java.customconstraint.DoubleMin;
import org.eclipse.esmf.aspectmodel.java.customconstraint.FloatMax;
Expand All @@ -33,6 +25,14 @@
import org.eclipse.esmf.aspectmodel.java.customconstraint.IntegerMin;
import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;

/** Generated class for AspectWithConstraints. */
public class AspectWithConstraints {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@

import java.util.Objects;

import javax.validation.constraints.NotNull;
import javax.xml.datatype.XMLGregorianCalendar;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.eclipse.esmf.aspectmodel.java.customconstraint.GregorianCalendarMax;
import org.eclipse.esmf.aspectmodel.java.customconstraint.GregorianCalendarMin;
import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

/** Generated class for AspectWithGTypeForRangeConstraints. */
public class AspectWithGTypeForRangeConstraints {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

/**
* Class for testing aspects with variously typed and constrained numeric properties.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import java.util.Objects;

import javax.validation.constraints.NotNull;

import org.eclipse.esmf.metamodel.datatypes.LangString;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

/**
* Generated class for AspectWithMultilanguageExampleValue.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import java.math.BigInteger;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

/** Generated class for Test Aspect. */
public class AspectWithRangeConstraintWithoutMinMaxIntegerValue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

/** Generated class for AspectWithRecursivePropertyWithOptional. */
public class AspectWithRecursivePropertyWithOptional {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import java.math.BigInteger;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

public class ExtendingTestEntity extends AbstractTestEntity {

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.net.URI;
import java.util.Objects;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotNull;

/**
* Generated class for Unique Identifier.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,8 @@ public void testEnumComplexMapping( final KnownVersion metaModelVersion ) {
+ "['properties']['description']['enum'][0]" ) ).isEqualTo( "Result succeeded" );
assertThat( context.<String> read( "$['components']['schemas']['ResultGood']['properties']['details']"
+ "['properties']['message']['enum'][0]" ) ).isEqualTo( "Evaluation succeeded." );
assertThat( context.<Double> read( "$['components']['schemas']['ResultGood']['properties']['details']"
+ "['properties']['numericCode']['enum'][0]" ) ).isCloseTo( 10.0d, Percentage.withPercentage( 1.0d ) );
assertThat( context.<Integer> read( "$['components']['schemas']['ResultGood']['properties']['details']"
+ "['properties']['numericCode']['enum'][0]" ) ).isEqualTo( 10 );
}

@ParameterizedTest
Expand Down
4 changes: 2 additions & 2 deletions core/esmf-aspect-model-java-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<artifactId>esmf-aspect-model-generator</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.esmf</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
import java.math.BigInteger;
import java.util.Optional;

import javax.validation.constraints.Digits;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.apache.commons.text.StringEscapeUtils;

import org.eclipse.esmf.aspectmodel.java.rangeconstraint.AnnotationExpression;
Expand All @@ -33,8 +29,12 @@
import org.eclipse.esmf.metamodel.ScalarValue;
import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;

/**
* Provides functionality to create javax.validation.constraints that are displayed in the generated java class
* Provides functionality to create jakarta.validation.constraints that are displayed in the generated java class
*/
public class ConstraintAnnotationBuilder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

@Target( { FIELD, TYPE_USE } )
@Retention( RUNTIME )
@Constraint( validatedBy = { DoubleMaxValidator.class } )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

package org.eclipse.esmf.aspectmodel.java.customconstraint;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
* Validates assigned values of type {@link Double}, which must be below or equal to this limit depending on the
* provided {@link BoundDefinition}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

@Target( { FIELD, TYPE_USE } )
@Retention( RUNTIME )
@Constraint( validatedBy = DoubleMinValidator.class )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
*/

package org.eclipse.esmf.aspectmodel.java.customconstraint;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
* Validates assigned values of type {@link Double}, which must be above or equal to this limit depending on the
* provided {@link BoundDefinition}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

@Target( { FIELD, TYPE_USE } )
@Retention( RUNTIME )
@Constraint( validatedBy = { DurationMaxValidator.class } )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
*/

package org.eclipse.esmf.aspectmodel.java.customconstraint;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
* Validates assigned values of type {@link Duration}, which must be below or equal to this limit depending on the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import org.eclipse.esmf.metamodel.impl.BoundDefinition;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

@Target( { FIELD, TYPE_USE } )
@Retention( RUNTIME )
@Constraint( validatedBy = DurationMinValidator.class )
Expand Down
Loading

0 comments on commit 1f76305

Please sign in to comment.