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

Application configuration to the new packages of spring and java 11 w… #13

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5b8cc8a
Application configuration to the new packages of spring and java 11 w…
berkson Jul 23, 2021
5242c92
All test updated to junit5
berkson Jul 23, 2021
f3e2c70
change ci config file
berkson Jul 23, 2021
b57ea5d
Add .circleci/config.yml
berkson Jul 23, 2021
17fbdd8
update README.md
berkson Jul 23, 2021
899cec4
Merge remote-tracking branch 'origin/master'
berkson Jul 23, 2021
7cda465
Running with mongodb in memory
berkson Jul 23, 2021
c9a7f2b
Tive que mudar de um hashSet para um arrayList os ingredientes e as c…
berkson Jul 24, 2021
8006d9f
fim da aula.
berkson Jul 24, 2021
803c2be
bootstrap só carrega se o banco estiver vazio, ou seja, primeira vez.…
berkson Jul 24, 2021
66c7c22
reconfigurando para programação reativa
berkson Jul 26, 2021
055876f
Criados testes reativos e configurado bootstrap reativo.
berkson Jul 26, 2021
3bfe2a3
criado teste de categoria
berkson Jul 26, 2021
023a39b
criado teste de categoria
berkson Jul 26, 2021
3173a27
Iniciando serviços reativos
berkson Jul 26, 2021
70c5070
Criados os controllers e serviços reativos, porém como os templates t…
berkson Jul 26, 2021
fd2be97
refatoração dos Flux
berkson Jul 26, 2021
d465476
Criados alguns testes e a aplicação está totalemente funcional.
berkson Jul 26, 2021
a96cbb1
Correção de testes com erro e colocação de retorno Mono<Void> na dele…
berkson Jul 26, 2021
eec1925
correcting ingredient's update
berkson Jul 27, 2021
96ce165
Upgrade in IngredientReactiveServiceImpl.java to reactive program
berkson Jul 27, 2021
0802142
Refactoring to use reactive stream api only.
berkson Jul 27, 2021
32eda8b
Generating controller test for the app
berkson Jul 27, 2021
da9f367
refactoring to remove dbrefs in mongo db cause the reactive mongo dri…
berkson Jul 27, 2021
f6f0af6
renaming and generating IndexReactiveControllerTest
berkson Jul 27, 2021
a8dc75a
Getting the description of the uom cause was showing null
berkson Jul 27, 2021
e218197
Created Reactive service test for image controller
berkson Jul 29, 2021
b5c04c5
updating after change directory
berkson Oct 5, 2021
01693a3
Merge branch 'master' of github.com:berkson/spring5-mongo-recipe-app
berkson Oct 5, 2021
e87dd36
updating after change directory
berkson Oct 5, 2021
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
8 changes: 3 additions & 5 deletions .circleci/config.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
version: 2.1
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
- image: cimg/openjdk:11.0

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down Expand Up @@ -54,6 +54,4 @@ jobs:
- store_artifacts:
path: ~/junit

- run:
name: Send to CodeCov
command: bash <(curl -s https://codecov.io/bash)
#removed codecov it does not work with java 11
Empty file modified .gitignore
100644 → 100755
Empty file.
8 changes: 3 additions & 5 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[![CircleCI](https://circleci.com/gh/springframeworkguru/spring5-mongo-recipe-app.svg?style=svg)](https://circleci.com/gh/springframeworkguru/spring5-mongo-recipe-app)

[![codecov](https://codecov.io/gh/springframeworkguru/spring5-mongo-recipe-app/branch/master/graph/badge.svg)](https://codecov.io/gh/springframeworkguru/spring5-mongo-recipe-app)
[![CircleCI](https://circleci.com/gh/berkson/spring5-mongo-recipe-app/tree/master.svg?style=svg)](https://circleci.com/gh/berkson/spring5-mongo-recipe-app/tree/master)

# spring5-mongo-recipe-app
Recipe Application Using MongoDB

This repository is for an example application built in my Spring Framework 5 - Beginner to Guru
This repository is a fork of an application built at Spring Framework 5 - Beginner to Guru course

You can learn about my Spring Framework 5 Online course [here.](http://courses.springframework.guru/p/spring-framework-5-begginer-to-guru/?product_id=363173)
You can learn about the Spring Framework 5 Online course [here.](http://courses.springframework.guru/p/spring-framework-5-begginer-to-guru/?product_id=363173)
58 changes: 36 additions & 22 deletions build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buildscript {
ext {
springBootVersion = '2.1.0.RELEASE'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
ext {
springBootVersion = '2.5.2'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
Expand All @@ -19,23 +19,37 @@ apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}


dependencies {
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.springframework.boot:spring-boot-devtools')
compile 'org.webjars:bootstrap:3.3.7-1'
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
implementation('org.springframework.boot:spring-boot-starter-data-mongodb')
implementation('org.springframework.boot:spring-boot-starter-data-mongodb-reactive')
implementation('org.springframework.boot:spring-boot-starter-thymeleaf')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-validation')
//needed to get an Constant value when testing
implementation('com.google.code.findbugs:jsr305:3.0.2')
runtimeOnly('org.springframework.boot:spring-boot-devtools')
implementation 'org.webjars:bootstrap:3.3.7-1'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('io.projectreactor:reactor-test')
implementation('de.flapdoodle.embed:de.flapdoodle.embed.mongo')
}

test {
useJUnitPlatform()
}

//export test coverage
Expand Down
Empty file modified gradle/wrapper/gradle-wrapper.jar
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
Empty file modified gradlew.bat
100644 → 100755
Empty file.
Empty file.
36 changes: 23 additions & 13 deletions src/main/java/guru/springframework/bootstrap/RecipeBootstrap.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import guru.springframework.repositories.UnitOfMeasureRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Profile;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -20,6 +21,7 @@
*/
@Slf4j
@Component
@Profile("notReactive")
public class RecipeBootstrap implements ApplicationListener<ContextRefreshedEvent> {

private final CategoryRepository categoryRepository;
Expand All @@ -36,13 +38,21 @@ public RecipeBootstrap(CategoryRepository categoryRepository,
@Override
@Transactional
public void onApplicationEvent(ContextRefreshedEvent event) {
loadCategories();
loadUom();
recipeRepository.saveAll(getRecipes());
//only bootstraps if the database is empty.

if (categoryRepository.count() == 0) {
loadCategories();
loadUom();
}

if (recipeRepository.count() == 0) {
recipeRepository.saveAll(getRecipes());
}

log.debug("Loading Bootstrap Data");
}

private void loadCategories(){
private void loadCategories() {
Category cat1 = new Category();
cat1.setDescription("American");
categoryRepository.save(cat1);
Expand All @@ -60,7 +70,7 @@ private void loadCategories(){
categoryRepository.save(cat4);
}

private void loadUom(){
private void loadUom() {
UnitOfMeasure uom1 = new UnitOfMeasure();
uom1.setDescription("Teaspoon");
unitOfMeasureRepository.save(uom1);
Expand Down Expand Up @@ -101,37 +111,37 @@ private List<Recipe> getRecipes() {
//get UOMs
Optional<UnitOfMeasure> eachUomOptional = unitOfMeasureRepository.findByDescription("Each");

if(!eachUomOptional.isPresent()){
if (!eachUomOptional.isPresent()) {
throw new RuntimeException("Expected UOM Not Found");
}

Optional<UnitOfMeasure> tableSpoonUomOptional = unitOfMeasureRepository.findByDescription("Tablespoon");

if(!tableSpoonUomOptional.isPresent()){
if (!tableSpoonUomOptional.isPresent()) {
throw new RuntimeException("Expected UOM Not Found");
}

Optional<UnitOfMeasure> teaSpoonUomOptional = unitOfMeasureRepository.findByDescription("Teaspoon");

if(!teaSpoonUomOptional.isPresent()){
if (!teaSpoonUomOptional.isPresent()) {
throw new RuntimeException("Expected UOM Not Found");
}

Optional<UnitOfMeasure> dashUomOptional = unitOfMeasureRepository.findByDescription("Dash");

if(!dashUomOptional.isPresent()){
if (!dashUomOptional.isPresent()) {
throw new RuntimeException("Expected UOM Not Found");
}

Optional<UnitOfMeasure> pintUomOptional = unitOfMeasureRepository.findByDescription("Pint");

if(!pintUomOptional.isPresent()){
if (!pintUomOptional.isPresent()) {
throw new RuntimeException("Expected UOM Not Found");
}

Optional<UnitOfMeasure> cupsUomOptional = unitOfMeasureRepository.findByDescription("Cup");

if(!cupsUomOptional.isPresent()){
if (!cupsUomOptional.isPresent()) {
throw new RuntimeException("Expected UOM Not Found");
}

Expand All @@ -146,13 +156,13 @@ private List<Recipe> getRecipes() {
//get Categories
Optional<Category> americanCategoryOptional = categoryRepository.findByDescription("American");

if(!americanCategoryOptional.isPresent()){
if (!americanCategoryOptional.isPresent()) {
throw new RuntimeException("Expected Category Not Found");
}

Optional<Category> mexicanCategoryOptional = categoryRepository.findByDescription("Mexican");

if(!mexicanCategoryOptional.isPresent()){
if (!mexicanCategoryOptional.isPresent()) {
throw new RuntimeException("Expected Category Not Found");
}

Expand Down
Loading