Skip to content

Commit

Permalink
Merge pull request #1 from maoudia/feature/upgrade-to-latest
Browse files Browse the repository at this point in the history
  • Loading branch information
aoudiamoncef authored Nov 10, 2023
2 parents 391d468 + 8bc6ae6 commit eb3993b
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 31 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/bulk-update-with-spring-data-mongodb-reactive" # Location of package manifests
schedule:
interval: "monthly" # Check for updates every month
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch:

env:
COMMIT_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
BRANCH: ${{ github.event_name == 'pull_request' && format('refs/heads/{0}', github.event.pull_request.head.ref) || github.ref }}

jobs:
build:
name: Build code.maoudia.com
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4
- run: 'wget https://github.com/docker/compose/releases/download/v2.22.0/docker-compose-linux-x86_64'
- run: 'sudo mv docker-compose-linux-x86_64 /usr/libexec/docker/cli-plugins/docker-compose'
- run: 'sudo chmod +x /usr/libexec/docker/cli-plugins/docker-compose'
- name: Set up JDK 21 for x64
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
architecture: x64
cache: maven
- name: Build and test Maven projects
run: |
for project in $(find . -name "pom.xml" -exec dirname {} \;); do
echo "Building and testing project in folder: $project"
(cd "$project" && mvn --batch-mode --update-snapshots --no-transfer-progress verify -Dspring.profiles.active=test)
if [ $? -ne 0 ]; then
echo "Failed to build or test project in folder: $project"
exit 1
fi
done
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,37 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
29 changes: 28 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
= code.maoudia.com

Some of the source code for https://www.maoudia.com/[maoudia.com]
// Settings:
:idprefix:
:idseparator: -
ifndef::env-github[:icons: font]
ifdef::env-github,env-browser[]
:toc: macro
:toclevels: 1
endif::[]
ifdef::env-github[]
:branch: main
:status:
:outfilesuffix: .adoc
:!toc-title:
:caution-caption: :fire:
:important-caption: :exclamation:
:note-caption: :paperclip:
:tip-caption: :bulb:
:warning-caption: :warning:
endif::[]

// URIs:
:url-repo: https://github.com/maoudia/code.maoudia.com
ifdef::status[]
image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License, link=#copyright-and-license]
image:{url-repo}/actions/workflows/ci.yml/badge.svg?branch={branch}[Build Status (GitHub Actions),link={url-repo}/actions/workflows/ci.yml?query=branch%3A{branch}]
endif::[]

Some of the source code for https://www.maoudia.com/[maoudia.com]
6 changes: 3 additions & 3 deletions bulk-update-with-spring-data-mongodb-reactive/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The following guides illustrate how to use some features concretely:
For further reference, please consider the following sections:

* https://maven.apache.org/guides/index.html/[Official Apache Maven documentation]
* https://docs.spring.io/spring-boot/docs/2.7.0/maven-plugin/reference/html/[Spring Boot Maven Plugin Reference Guide]
* https://docs.spring.io/spring-boot/docs/2.7.0/maven-plugin/reference/html/#build-image/[Create an OCI image]
* https://docs.spring.io/spring-boot/docs/3.1.5/maven-plugin/reference/html/[Spring Boot Maven Plugin Reference Guide]
* https://docs.spring.io/spring-boot/docs/3.1.5/maven-plugin/reference/html/#build-image/[Create an OCI image]
* https://www.testcontainers.org/modules/databases/mongodb/[Testcontainers MongoDB Module Reference Guide]
* https://docs.spring.io/spring-boot/docs/2.7.0/reference/htmlsingle/#data.nosql.mongodb/[Spring Data Reactive MongoDB]
* https://docs.spring.io/spring-boot/docs/3.1.5/reference/htmlsingle/#data.nosql.mongodb/[Spring Data Reactive MongoDB]
* https://www.testcontainers.org/[Testcontainers]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: '3.1'
services:
mongodb:
container_name: maoudia-mongodb
image: mongo:5.0.8
image: mongo:7.0.2
environment:
- MONGO_INITDB_DATABASE=test
- MONGO_INITDB_ROOT_USERNAME=admin
Expand All @@ -15,7 +16,7 @@ services:

mongo-express:
container_name: maoudia-mongo-express
image: mongo-express:0.54.0
image: mongo-express:1.0.0
depends_on:
- mongodb
networks:
Expand All @@ -24,6 +25,8 @@ services:
- ME_CONFIG_MONGODB_SERVER=maoudia-mongodb
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=password
- ME_CONFIG_BASICAUTH_USERNAME=admin
- ME_CONFIG_BASICAUTH_PASSWORD=password
ports:
- 1515:8081
volumes:
Expand Down
17 changes: 2 additions & 15 deletions bulk-update-with-spring-data-mongodb-reactive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<version>3.1.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.maoudia</groupId>
Expand All @@ -14,8 +14,7 @@
<name>Bulk Update with Spring data MongoDB Reactive</name>
<description>Bulk Update with Spring data MongoDB Reactive</description>
<properties>
<java.version>1.8</java.version>
<testcontainers.version>1.17.2</testcontainers.version>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -48,17 +47,6 @@
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
Expand All @@ -67,5 +55,4 @@
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
package com.maoudia.tutorial;

import com.mongodb.bulk.BulkWriteResult;
import com.mongodb.bulk.BulkWriteUpsert;
import com.mongodb.internal.bulk.WriteRequest;
import org.bson.BsonValue;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.junit.ClassRule;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MongoDBContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import reactor.test.StepVerifier;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Profile("test")
@SpringBootTest
@Testcontainers
class CollectionServiceTest {


@Container
public static GenericContainer<?> jsonServerContainer = new GenericContainer<>("clue/json-server:latest")
.withExposedPorts(80)
.withFileSystemBind("./data/product/db.json", "/data/db.json");

@Container
private static final MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:5.0.8")
.withReuse(true);
private static final MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:7.0.2");

@DynamicPropertySource
private static void setProperties(DynamicPropertyRegistry registry) {
registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl);
registry.add("app.enriching-uri", () -> "http://" + jsonServerContainer.getHost() + ":" + jsonServerContainer.getMappedPort(80) + "/products/1");
}

@Autowired
Expand Down Expand Up @@ -62,7 +64,7 @@ void multipleBulkWriteResultsAreReturned() {
BulkWriteResult expectedBulkWriteResult2 = BulkWriteResult.acknowledged(WriteRequest.Type.REPLACE, 1, 1, Collections.emptyList(),
Collections.emptyList());

command.enrichAll( properties.getCollectionName(), properties.getEnrichingKey() , properties.getEnrichingUri())
command.enrichAll(properties.getCollectionName(), properties.getEnrichingKey() , properties.getEnrichingUri())
.as(StepVerifier::create)
.expectNext(expectedBulkWriteResult1)
.expectNext(expectedBulkWriteResult2)
Expand Down

0 comments on commit eb3993b

Please sign in to comment.