Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency io.micronaut:micronaut-inject-java to v4 #45

Merged
merged 9 commits into from
May 6, 2024
Merged
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
81 changes: 72 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,91 @@ version: 2.1
jobs:
analyze:
docker:
- image: 'cimg/openjdk:20.0'
- image: 'cimg/openjdk:21.0.2'
steps:
- checkout
- run:
name: Analyze on SonarCloud
command: mvn verify sonar:sonar -DskipTests
deploy-k8s:
executor: machine_executor_amd64
steps:
- checkout
- run:
name: Install Kubectl
command: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- run:
name: Install Skaffold
command: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
- run:
name: Install Kind
command: |
[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- run:
name: Install OpenJDK 21
command: |
java -version
sudo apt-get update && sudo apt-get install openjdk-21-jdk
sudo update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-21-openjdk-amd64/bin/javac
java -version
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
- run:
name: Create Kind Cluster
command: |
kind create cluster --name c1
- run:
name: Deploy to K8s
command: |
skaffold run
- run:
name: Delete Kind Cluster
command: |
kind delete cluster --name c1
test:
executor: machine_executor_amd64
steps:
- checkout
- run:
name: Install OpenJDK 21
command: |
java -version
sudo apt-get update && sudo apt-get install openjdk-21-jdk
sudo update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-21-openjdk-amd64/bin/javac
java -version
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
- run:
name: Maven Tests
command: mvn test

orbs:
maven: circleci/maven@1.4.1

executors:
linux:
machine_executor_amd64:
machine:
image: ubuntu-2204:2022.04.2
image: ubuntu-2204:2023.10.1
environment:
architecture: "amd64"
platform: "linux/amd64"

orbs:
maven: circleci/maven@1.4.1

workflows:
maven_test:
jobs:
- maven/test:
executor: linux
# - maven/test:
# executor: machine_executor_amd64
- test
- analyze:
context: SonarCloud
context: SonarCloud
- deploy-k8s:
requires:
- test
39 changes: 25 additions & 14 deletions department-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<artifactId>sample-micronaut-kubernetes</artifactId>
<groupId>pl.piomin.services</groupId>
<version>1.0</version>
<version>1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>department-service</artifactId>

<properties>
<exec.mainClass>pl.piomin.services.employee.DepartmentApplication</exec.mainClass>
<sonar.moduleKey>${artifactId}</sonar.moduleKey>
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
<micronaut.test.resources.enabled>true</micronaut.test.resources.enabled>
</properties>

Expand All @@ -22,6 +22,11 @@
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-server-netty</artifactId>
</dependency>
<dependency>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-jackson</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
Expand All @@ -47,6 +52,11 @@
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.micronaut.testresources</groupId>
<artifactId>micronaut-test-resources-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-junit5</artifactId>
Expand All @@ -69,18 +79,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -106,6 +106,17 @@
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-processor</artifactId>
<version>${micronaut.serialization.version}</version>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
</exclusion>
</exclusions>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion department-service/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v2alpha1
apiVersion: skaffold/v4beta10
kind: Config
build:
artifacts:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package pl.piomin.services.department.model;

import io.micronaut.serde.annotation.Serdeable;

import java.util.ArrayList;
import java.util.List;

@Serdeable
public class Department {

private Long id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package pl.piomin.services.department.model;

import io.micronaut.serde.annotation.Serdeable;

@Serdeable
public class Employee {

private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.testcontainers.junit.jupiter.Testcontainers;
import pl.piomin.services.department.model.Department;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@MicronautTest
@Testcontainers
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class DepartmentControllerTests {

Expand Down
12 changes: 12 additions & 0 deletions department-service/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
mongodb:
database: test
collection: department

micronaut:
netty:
event-loops:
default:
num-threads: 3
httpclient:
num-threads: 3
http:
client:
read-timeout: 20s
event-loop-group: httpclient
47 changes: 24 additions & 23 deletions employee-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<artifactId>sample-micronaut-kubernetes</artifactId>
<groupId>pl.piomin.services</groupId>
<version>1.0</version>
<version>1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>employee-service</artifactId>

<properties>
<exec.mainClass>pl.piomin.services.employee.EmployeeApplication</exec.mainClass>
<sonar.moduleKey>${artifactId}</sonar.moduleKey>
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
<micronaut.test.resources.enabled>true</micronaut.test.resources.enabled>
</properties>

Expand All @@ -34,10 +34,10 @@
<groupId>io.micronaut</groupId>
<artifactId>micronaut-management</artifactId>
</dependency>
<dependency>
<groupId>io.micronaut.data</groupId>
<artifactId>micronaut-data-mongodb</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.micronaut.data</groupId>-->
<!-- <artifactId>micronaut-data-mongodb</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.micronaut.mongodb</groupId>
<artifactId>micronaut-mongo-sync</artifactId>
Expand All @@ -51,6 +51,11 @@
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.micronaut.testresources</groupId>
<artifactId>micronaut-test-resources-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.micronaut.test</groupId>
<artifactId>micronaut-test-junit5</artifactId>
Expand All @@ -73,18 +78,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-http-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -110,11 +105,17 @@
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<!-- <path>-->
<!-- <groupId>io.micronaut.data</groupId>-->
<!-- <artifactId>micronaut-data-document-processor</artifactId>-->
<!-- <version>${micronaut.data.version}</version>-->
<!-- </path>-->
<path>
<groupId>io.micronaut.serde</groupId>
<artifactId>micronaut-serde-processor</artifactId>
<version>${micronaut.serialization.version}</version>
<exclusions>
<exclusion>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject</artifactId>
</exclusion>
</exclusions>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion employee-service/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v2alpha1
apiVersion: skaffold/v4beta10
kind: Config
build:
artifacts:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package pl.piomin.services.employee.model;

import io.micronaut.serde.annotation.Serdeable;

@Serdeable
public class Employee {

private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EmployeeInMemoryRepository implements EmployeeRepository {
@Inject
private EmployeesInitialList employeesInitialList;

private List<Employee> employees = new ArrayList<>();
private final List<Employee> employees = new ArrayList<>();

@Override
public Employee add(Employee employee) {
Expand All @@ -43,19 +43,19 @@ public List<Employee> findAll() {
public List<Employee> findByDepartment(Long departmentId) {
return employees.stream()
.filter(employee -> employee.getDepartmentId().equals(departmentId))
.collect(Collectors.toList());
.toList();
}

@Override
public List<Employee> findByOrganization(Long organizationId) {
return employees.stream()
.filter(employee -> employee.getOrganizationId().equals(organizationId))
.collect(Collectors.toList());
.toList();
}

@PostConstruct
public void init() {
employeesInitialList.getEmployees().forEach(employee -> employees.add(employee));
employees.addAll(employeesInitialList.getEmployees());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import org.instancio.Instancio;
import org.instancio.Select;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Testcontainers;
import pl.piomin.services.employee.model.Employee;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@MicronautTest
@Testcontainers
@Property(name = "in-memory-store.enabled", value = "true")
public class EmployeeControllerTests {

Expand Down
Loading