Skip to content

Commit

Permalink
changes to POM files to include JDK17 e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaleotti committed Oct 20, 2023
1 parent b005199 commit 39508d4
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 1 deletion.
12 changes: 12 additions & 0 deletions e2e-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,16 @@
</pluginManagement>
</build>

<profiles>
<profile>
<id>Configs for JDK >= 17</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<modules>
<module>spring-rest-jakarta</module>
</modules>
</profile>
</profiles>

</project>
97 changes: 97 additions & 0 deletions e2e-tests/spring-rest-jakarta/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


<parent>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-e2e-tests</artifactId>
<version>2.0.1-SNAPSHOT</version>
</parent>


<modelVersion>4.0.0</modelVersion>

<artifactId>evomaster-e2e-tests-spring-rest-jakarta</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-e2e-tests-utils</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-client-java-controller</artifactId>
</dependency>
<dependency>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.evomaster</groupId>
<artifactId>evomaster-client-java-instrumentation</artifactId>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-web</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
</dependency>



</dependencies>

<profiles>
<profile>
<id>skipE2E_V2</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.foo.jakarta.entity;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class JakartaApplication extends SwaggerConfiguration {

public static void main(String[] args) {
SpringApplication.run(JakartaApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.foo.jakarta.entity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.core.MediaType;
import java.util.List;

@RestController
@RequestMapping(path = "/api/jakarta/person")
public class JakartaRest {

@Autowired
private PersonRepository repository;


@RequestMapping(
method = RequestMethod.POST
)
public ResponseEntity<Void> post(String name) {
PersonEntity entity = new PersonEntity();
entity.name = name;
repository.save(entity);
return ResponseEntity.status(200).build();
}


@RequestMapping(
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON
)
public ResponseEntity<Void> get(String name) {

List<PersonEntity> list = repository.findByName(name);
if (list.isEmpty()) {
return ResponseEntity.status(400).build();
} else {
return ResponseEntity.status(200).build();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.foo.jakarta.entity;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.validation.constraints.*;
import java.time.LocalDate;
import java.util.List;

@Entity
public class PersonEntity {

@Id
@GeneratedValue
private Long id;

@Min(value = 0)
public int age;

@Max(value = 200)
public int maxAge;

@NotBlank
public String name;

@Email
public String emailAddress;

@Negative
public int debt;

@NegativeOrZero
public int netWorth;

@Positive
public int income;

@PositiveOrZero
public int savings;

@Future
public LocalDate birthDate;

@FutureOrPresent
public LocalDate nextAppointment;

@Past
public LocalDate graduationDate;

@PastOrPresent
public LocalDate lastUpdate;

@Null
public Object nullField;

@DecimalMin(value = "0.0", message = "Value must be at least 0.0")
@DecimalMax(value = "1000000.0", message = "Value must be at most 1,000,000.0")
private Float annualIncome;

@Pattern(regexp = "^[A-Za-z]+$", message = "Only alphabetic characters are allowed")
private String nickname;

@Size(min = 0, max = 100, message = "Must contain between 0 and 100 items")
private List<String> otherDetails;

@Digits(integer = 6, fraction = 2, message = "Invalid format, max 6 digits with 2 decimal places")
private float weight;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.foo.jakarta.entity;

import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface PersonRepository extends CrudRepository<PersonEntity, Long> {

List<PersonEntity> findByName(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.foo.jakarta.entity;

import org.springframework.context.annotation.Bean;
import org.springframework.security.core.Authentication;
import org.springframework.web.context.request.WebRequest;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import static springfox.documentation.builders.PathSelectors.regex;

public class SwaggerConfiguration {

@Bean
public Docket docketApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.paths(regex("/api/.*"))
.build()
.ignoredParameterTypes(WebRequest.class, Authentication.class);
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("API")
.description("Some description")
.version("1.0")
.build();
}
}
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<micronaut.test.version>3.0.5</micronaut.test.version>
<org.mongodb.version>4.2.3</org.mongodb.version>
<org.locationtech.jts.version>1.19.0</org.locationtech.jts.version>

</properties>


Expand Down

0 comments on commit 39508d4

Please sign in to comment.