Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3c365c8
feat: add Mockserver setup
Aug 15, 2025
772fd8a
ci: renamed GA workflows
Aug 15, 2025
30d10be
feat(contracts): UserContact modeled
Aug 16, 2025
70a233c
feat(contracts): add Service models
Aug 16, 2025
37c2cad
feat(contracts): add Subscription model
Aug 17, 2025
b76b5ce
feat: add configuration class
Aug 18, 2025
5d20c20
feat(contracts): check username in build method
Aug 18, 2025
96a438c
feat(contracts): serialize UserContact as json
Aug 18, 2025
0fe455b
feat(contracts): add usage level
Aug 19, 2025
2f769db
feat(contracts): add subscription history
Aug 19, 2025
0a9e38b
feat(contracts): add subscription usage levels
Aug 19, 2025
cb23e58
feat(contracts): extract subscription billing period
Aug 19, 2025
f6531a7
feat(contracts): parse json to billing period
Aug 20, 2025
491c825
feat(contracts): parse json to user contact
Aug 20, 2025
d163840
fix(contracts): incorrect UserContact json parsing
Aug 20, 2025
d37b5c9
feat(contracts): parse subscription json to Subscription
Aug 20, 2025
1534a2c
feat(contracts): change date types to represent time zone
Aug 20, 2025
43ba799
feat(contracts): raw json to Subscription
Aug 21, 2025
99ebd1c
chore: bad naming serializers folder
Aug 21, 2025
f4f7fae
fix(contracts): deserializers package not renamed
Aug 21, 2025
4fa4dcb
feat: replace Jsonable interface
Aug 22, 2025
06719e2
chore: json identation
Aug 22, 2025
420617f
feat: migrate MockServer to WireMock
Aug 22, 2025
2d6e9f2
fix: deleted MockServer example
Aug 22, 2025
d181b60
feat: add Contracts endpoints domain models
Aug 22, 2025
4af5355
feat(contracts): add serializers to domain models
Aug 22, 2025
52b591b
feat(contracts): contracts endpoints implemented
Aug 23, 2025
6f3a7b1
ci(sonar): disable CI analysis
Aug 23, 2025
5bc32f9
ci(sonar): upload JaCoCo to Sonarcloud
Aug 23, 2025
4755719
ci(sonar): enabled automatic analysis
Aug 23, 2025
2f3debe
feat(contracts): do not catch IOException
Aug 23, 2025
1c1d6eb
fix: remove stacktrace
Aug 23, 2025
4c58a16
fix: wrong date comparisons
Aug 23, 2025
cbb3044
feat: extract statusCode
Aug 23, 2025
18db024
feat: inmediately return
Aug 23, 2025
62aab08
feat: renamed SubscriptionRequest methods
Aug 23, 2025
b35d88d
feat: add fluent assertions
Aug 23, 2025
145441a
fix: high mantainability issues
Aug 23, 2025
9f453e9
fix: minor issues sonar
Aug 23, 2025
bac35aa
feat(contracts): add service creation corner cases
Aug 24, 2025
8240a44
fix: missing parameter method in addOn
Aug 24, 2025
0d5be99
feat(sonar): fix test issues Sonarcloud
Aug 24, 2025
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
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ indent_size = 4
indent_style = space
indent_size = 2

[*.json]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{pom.xml}]
indent_style = tab
indent_size = 4
indent_size = 4
39 changes: 0 additions & 39 deletions .github/workflows/code-analysis.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Run tests
on: push
jobs:
build:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -12,4 +12,4 @@ jobs:
java-version: '11'
distribution: 'temurin'
- name: Run tests
run: mvn test
run: mvn test
109 changes: 12 additions & 97 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,51 +137,28 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter-no-dependencies</artifactId>
<version>5.14.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.26.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.6.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.26.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.13</version>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.9.3.2</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.9.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.27.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -246,68 +223,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>google_checks.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>1.12.0</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<includeXmlInReports>true</includeXmlInReports>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>cpd-check</id>
<goals>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
98 changes: 98 additions & 0 deletions src/main/java/io/github/pgmarc/space/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package io.github.pgmarc.space;

import java.time.Duration;
import java.util.Objects;

import okhttp3.HttpUrl;

public final class Config {

private static final String DEFAULT_SCHEME = "http";

private final String apiKey;
private final String host;
private final int port;
private final String prefixPath;
private final Duration readTimeout;
private final Duration writeTimeout;

private Config(Builder builder) {
this.host = builder.host;
this.apiKey = builder.apiKey;
this.port = builder.port;
this.prefixPath = builder.prefixPath;
this.readTimeout = builder.readTimeout;
this.writeTimeout = builder.writeTimeout;
}

public String getApiKey() {
return apiKey;
}

public Duration getReadTimeout() {
return readTimeout;
}

public Duration getWriteTimeout() {
return writeTimeout;
}

public HttpUrl getUrl() {
return new HttpUrl.Builder().scheme(DEFAULT_SCHEME)
.host(this.host).port(this.port)
.addPathSegments(prefixPath).build();
}

public static Builder builder(String host, String apiKey) {
return new Builder(host, apiKey);
}

public static final class Builder {

private final String host;
private final String apiKey;
private int port = 5403;
private String prefixPath = "api/v1";
private Duration readTimeout;
private Duration writeTimeout;

private Builder(String host, String apiKey) {
this.host = host;
this.apiKey = apiKey;
}

public Builder port(int port) {
this.port = port;
return this;
}

public Builder readTimeout(Duration duration) {
if (duration != null) {
this.readTimeout = duration;
}
return this;
}

public Builder writeTimeout(Duration duration) {
if (duration != null) {
this.writeTimeout = duration;
}
return this;
}

public Builder prefixPath(String prefixPath) {
if (prefixPath != null) {
this.prefixPath = prefixPath;
}
return this;
}

public Config build() {
Objects.requireNonNull(this.host, "host must not be null");
Objects.requireNonNull(this.apiKey, "api key must not be null");
return new Config(this);
}

}

}
46 changes: 46 additions & 0 deletions src/main/java/io/github/pgmarc/space/contracts/AddOn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.github.pgmarc.space.contracts;

public final class AddOn {

private final String name;
private final long quantity;

AddOn(String name, long quantity) {
this.name = name;
this.quantity = quantity;
}

public String getName() {
return name;
}

public long getQuantity() {
return quantity;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AddOn other = (AddOn) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}

}
Loading