Skip to content
Open
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
28 changes: 27 additions & 1 deletion diffblue-cover/diffblue-legal-age-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,34 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
<version>20231013</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.2.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
<output>${project.build.directory}/site/openapi</output>
<generatorName>html2</generatorName>
<configOptions>
<allowUnicodeIdentifiers>false</allowUnicodeIdentifiers>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
29 changes: 0 additions & 29 deletions diffblue-cover/diffblue-legal-age-web/src/bank.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import diffblue.legalage.LegalAgePredicate;

import org.restlet.data.Status;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.json.JSONObject;
Expand All @@ -22,6 +23,7 @@ public String legalAgeValidator() {
birthday = LocalDate.parse(birthdayString, DateTimeFormatter.ISO_DATE);
} catch (DateTimeParseException e) {
response.put("error", "Invalid birthday format. Use yyyy-mm-dd.");
setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
return response.toString();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
openapi: 3.0.0
info:
title: Sample of Bank API
description: >-
Sample of Bank API with only one end-point
version: 1.0.0
servers:
- url: 'http://localhost:8182'
description: Local server
paths:
/age:
get:
summary: Validate that person is legal age
description: >-
Verifies the person has reached the age of 18 years.
It returns a boolean value `true` if the answer is positive.

operationId: legalAgeValidator
parameters:
- $ref: '#/components/parameters/BirthDate'
responses:
200:
$ref: '#/components/responses/LegalAgeResponse'
400:
$ref: '#/components/responses/ErrorResponse'

components:
parameters:
BirthDate:
name: birthDate
in: query
description: >-
Birth date of person
required: true
schema:
type: string
format: date
example: 2000-01-01
schemas:
LegalAgeInfo:
type: object
properties:
message:
type: string
description: Birthday message and legal age status
birthday:
type: string
format: date
description: The birthday in yyyy-mm-dd format
isLegalAge:
type: boolean
description: Indicates if the person is of legal age
required:
- message
- birthday
- isLegalAge
responses:
LegalAgeResponse:
description: Legal age validation response
content:
application/json:
schema:
$ref: '#/components/schemas/LegalAgeInfo'
ErrorResponse:
description: Error response
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error message
required:
- error
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
###

GET {{host}}/age?birthday=xxx

> {%
const data = JSON.parse(response.body.toString());
client.test("Returns 400 - Bad Request", function() {
client.assert(response.status === 400, "Response status is not 400");
});
client.test("Error message is correct", function() {
client.assert(data.error === "Invalid birthday format. Use yyyy-mm-dd.", "error message is incorrect");
});
%}
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.4.0</version>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -139,7 +139,7 @@
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.16</version>
<version>4.0.17</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -180,7 +180,7 @@
<!-- Testing related plugins -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
<configuration>
<useFile>false</useFile>
<includes>
Expand All @@ -200,13 +200,13 @@
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
</plugin>

<!-- Test report related plugins -->
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.3</version>
</plugin>

<!-- Plugins to document and inspect -->
Expand All @@ -224,7 +224,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.2</version>
<version>3.6.3</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down Expand Up @@ -254,7 +254,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.1.0</version>
<version>4.8.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -264,7 +264,7 @@
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>9.0.2</version>
<version>9.0.7</version>
<executions>
<execution>
<goals>
Expand All @@ -278,7 +278,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.41.0</version>
<version>2.41.1</version>
<configuration>
<!-- optional: limit format enforcement to just the files changed by this feature branch -->
<ratchetFrom>origin/main</ratchetFrom>
Expand Down